@typescript-deploys/pr-build 4.6.0-pr-47400-2 → 4.6.0-pr-47552-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220113";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220122";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -7004,11 +7004,15 @@ var ts;
7004
7004
  ts.getFileWatcherEventKind = getFileWatcherEventKind;
7005
7005
  /*@internal*/
7006
7006
  ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
7007
+ var curSysLog = ts.noop; // eslint-disable-line prefer-const
7007
7008
  /*@internal*/
7008
- ts.sysLog = ts.noop; // eslint-disable-line prefer-const
7009
+ function sysLog(s) {
7010
+ return curSysLog(s);
7011
+ }
7012
+ ts.sysLog = sysLog;
7009
7013
  /*@internal*/
7010
7014
  function setSysLog(logger) {
7011
- ts.sysLog = logger;
7015
+ curSysLog = logger;
7012
7016
  }
7013
7017
  ts.setSysLog = setSysLog;
7014
7018
  /**
@@ -7143,7 +7147,7 @@ var ts;
7143
7147
  }
7144
7148
  function onTimerToUpdateChildWatches() {
7145
7149
  timerToUpdateChildWatches = undefined;
7146
- ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
7150
+ sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
7147
7151
  var start = ts.timestamp();
7148
7152
  var invokeMap = new ts.Map();
7149
7153
  while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
@@ -7156,7 +7160,7 @@ var ts;
7156
7160
  var hasChanges = updateChildWatches(dirName, dirPath, options);
7157
7161
  invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames);
7158
7162
  }
7159
- ts.sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
7163
+ sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
7160
7164
  callbackCache.forEach(function (callbacks, rootDirName) {
7161
7165
  var existing = invokeMap.get(rootDirName);
7162
7166
  if (existing) {
@@ -7172,7 +7176,7 @@ var ts;
7172
7176
  }
7173
7177
  });
7174
7178
  var elapsed = ts.timestamp() - start;
7175
- ts.sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
7179
+ sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
7176
7180
  }
7177
7181
  function removeChildWatches(parentWatcher) {
7178
7182
  if (!parentWatcher)
@@ -7759,7 +7763,7 @@ var ts;
7759
7763
  * @param createWatcher
7760
7764
  */
7761
7765
  function invokeCallbackAndUpdateWatcher(createWatcher) {
7762
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7766
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
7763
7767
  // Call the callback for current directory
7764
7768
  callback("rename", "");
7765
7769
  // If watcher is not closed, update it
@@ -7784,7 +7788,7 @@ var ts;
7784
7788
  }
7785
7789
  }
7786
7790
  if (hitSystemWatcherLimit) {
7787
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7791
+ sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
7788
7792
  return watchPresentFileSystemEntryWithFsWatchFile();
7789
7793
  }
7790
7794
  try {
@@ -7800,7 +7804,7 @@ var ts;
7800
7804
  // 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
7801
7805
  // so instead of throwing error, use fs.watchFile
7802
7806
  hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
7803
- ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7807
+ sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
7804
7808
  return watchPresentFileSystemEntryWithFsWatchFile();
7805
7809
  }
7806
7810
  }
@@ -8399,6 +8403,7 @@ var ts;
8399
8403
  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"),
8400
8404
  The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
8401
8405
  Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
8406
+ catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8402
8407
  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."),
8403
8408
  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."),
8404
8409
  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),
@@ -8482,7 +8487,7 @@ var ts;
8482
8487
  Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."),
8483
8488
  Duplicate_index_signature_for_type_0: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."),
8484
8489
  Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2375, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2375", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
8485
- A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."),
8490
+ A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_2376", "A 'super' call must be the first statement in the constructor to refer to 'super' or 'this' when a derived class contains initialized properties, parameter properties, or private identifiers."),
8486
8491
  Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."),
8487
8492
  A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."),
8488
8493
  Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2379, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379", "Argument of type '{0}' is not assignable to parameter of type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
@@ -8505,6 +8510,7 @@ var ts;
8505
8510
  constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, ts.DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."),
8506
8511
  Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."),
8507
8512
  Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."),
8513
+ A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2401, ts.DiagnosticCategory.Error, "A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_in_2401", "A 'super' call must be a root-level statement within a constructor of a derived class that contains initialized properties, parameter properties, or private identifiers."),
8508
8514
  Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."),
8509
8515
  Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."),
8510
8516
  The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."),
@@ -8885,6 +8891,7 @@ var ts;
8885
8891
  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."),
8886
8892
  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}'?"),
8887
8893
  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."),
8894
+ 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."),
8888
8895
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8889
8896
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8890
8897
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -9278,7 +9285,7 @@ var ts;
9278
9285
  Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
9279
9286
  _0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file: diag(6258, ts.DiagnosticCategory.Error, "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258", "'{0}' should be set inside the 'compilerOptions' object of the config json file"),
9280
9287
  Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
9281
- Found_0_errors_in_1_file: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_file_6260", "Found {0} errors in 1 file."),
9288
+ Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
9282
9289
  Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
9283
9290
  Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
9284
9291
  Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
@@ -9654,6 +9661,8 @@ var ts;
9654
9661
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9655
9662
  Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
9656
9663
  Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
9664
+ Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
9665
+ Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
9657
9666
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9658
9667
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9659
9668
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -15665,6 +15674,34 @@ var ts;
15665
15674
  }
15666
15675
  }
15667
15676
  ts.getThisContainer = getThisContainer;
15677
+ /**
15678
+ * @returns Whether the node creates a new 'this' scope for its children.
15679
+ */
15680
+ function isThisContainerOrFunctionBlock(node) {
15681
+ switch (node.kind) {
15682
+ // Arrow functions use the same scope, but may do so in a "delayed" manner
15683
+ // For example, `const getThis = () => this` may be before a super() call in a derived constructor
15684
+ case 213 /* ArrowFunction */:
15685
+ case 255 /* FunctionDeclaration */:
15686
+ case 212 /* FunctionExpression */:
15687
+ case 166 /* PropertyDeclaration */:
15688
+ return true;
15689
+ case 234 /* Block */:
15690
+ switch (node.parent.kind) {
15691
+ case 170 /* Constructor */:
15692
+ case 168 /* MethodDeclaration */:
15693
+ case 171 /* GetAccessor */:
15694
+ case 172 /* SetAccessor */:
15695
+ // Object properties can have computed names; only method-like bodies start a new scope
15696
+ return true;
15697
+ default:
15698
+ return false;
15699
+ }
15700
+ default:
15701
+ return false;
15702
+ }
15703
+ }
15704
+ ts.isThisContainerOrFunctionBlock = isThisContainerOrFunctionBlock;
15668
15705
  function isInTopLevelContext(node) {
15669
15706
  // The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
15670
15707
  if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
@@ -16023,7 +16060,7 @@ var ts;
16023
16060
  }
16024
16061
  ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
16025
16062
  function getExternalModuleRequireArgument(node) {
16026
- return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
16063
+ return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
16027
16064
  }
16028
16065
  ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
16029
16066
  function isInternalModuleImportEqualsDeclaration(node) {
@@ -16081,17 +16118,29 @@ var ts;
16081
16118
  * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`).
16082
16119
  * This function does not test if the node is in a JavaScript file or not.
16083
16120
  */
16084
- function isRequireVariableDeclaration(node) {
16121
+ function isVariableDeclarationInitializedToRequire(node) {
16122
+ return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false);
16123
+ }
16124
+ ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire;
16125
+ /**
16126
+ * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`.
16127
+ */
16128
+ function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
16129
+ return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true);
16130
+ }
16131
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16132
+ function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16085
16133
  if (node.kind === 202 /* BindingElement */) {
16086
16134
  node = node.parent.parent;
16087
16135
  }
16088
- return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true);
16136
+ return ts.isVariableDeclaration(node) &&
16137
+ !!node.initializer &&
16138
+ isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
16089
16139
  }
16090
- ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
16091
16140
  function isRequireVariableStatement(node) {
16092
16141
  return ts.isVariableStatement(node)
16093
16142
  && node.declarationList.declarations.length > 0
16094
- && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); });
16143
+ && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); });
16095
16144
  }
16096
16145
  ts.isRequireVariableStatement = isRequireVariableStatement;
16097
16146
  function isSingleOrDoubleQuote(charCode) {
@@ -19578,7 +19627,7 @@ var ts;
19578
19627
  getSourceMapSourceConstructor: function () { return SourceMapSource; },
19579
19628
  };
19580
19629
  function setObjectAllocator(alloc) {
19581
- ts.objectAllocator = alloc;
19630
+ Object.assign(ts.objectAllocator, alloc);
19582
19631
  }
19583
19632
  ts.setObjectAllocator = setObjectAllocator;
19584
19633
  function formatStringFromArgs(text, args, baseIndex) {
@@ -19586,13 +19635,22 @@ var ts;
19586
19635
  return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
19587
19636
  }
19588
19637
  ts.formatStringFromArgs = formatStringFromArgs;
19638
+ var localizedDiagnosticMessages;
19589
19639
  /* @internal */
19590
19640
  function setLocalizedDiagnosticMessages(messages) {
19591
- ts.localizedDiagnosticMessages = messages;
19641
+ localizedDiagnosticMessages = messages;
19592
19642
  }
19593
19643
  ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
19644
+ /* @internal */
19645
+ // If the localized messages json is unset, and if given function use it to set the json
19646
+ function maybeSetLocalizedDiagnosticMessages(getMessages) {
19647
+ if (!localizedDiagnosticMessages && getMessages) {
19648
+ localizedDiagnosticMessages = getMessages();
19649
+ }
19650
+ }
19651
+ ts.maybeSetLocalizedDiagnosticMessages = maybeSetLocalizedDiagnosticMessages;
19594
19652
  function getLocaleSpecificMessage(message) {
19595
- return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
19653
+ return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
19596
19654
  }
19597
19655
  ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
19598
19656
  function createDetachedDiagnostic(fileName, start, length, message) {
@@ -26251,7 +26309,7 @@ var ts;
26251
26309
  * @param visitor Optional callback used to visit any custom prologue directives.
26252
26310
  */
26253
26311
  function copyPrologue(source, target, ensureUseStrict, visitor) {
26254
- var offset = copyStandardPrologue(source, target, ensureUseStrict);
26312
+ var offset = copyStandardPrologue(source, target, 0, ensureUseStrict);
26255
26313
  return copyCustomPrologue(source, target, offset, visitor);
26256
26314
  }
26257
26315
  function isUseStrictPrologue(node) {
@@ -26264,12 +26322,14 @@ var ts;
26264
26322
  * Copies only the standard (string-expression) prologue-directives into the target statement-array.
26265
26323
  * @param source origin statements array
26266
26324
  * @param target result statements array
26325
+ * @param statementOffset The offset at which to begin the copy.
26267
26326
  * @param ensureUseStrict boolean determining whether the function need to add prologue-directives
26327
+ * @returns Count of how many directive statements were copied.
26268
26328
  */
26269
- function copyStandardPrologue(source, target, ensureUseStrict) {
26329
+ function copyStandardPrologue(source, target, statementOffset, ensureUseStrict) {
26330
+ if (statementOffset === void 0) { statementOffset = 0; }
26270
26331
  ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
26271
26332
  var foundUseStrict = false;
26272
- var statementOffset = 0;
26273
26333
  var numStatements = source.length;
26274
26334
  while (statementOffset < numStatements) {
26275
26335
  var statement = source[statementOffset];
@@ -27692,7 +27752,7 @@ var ts;
27692
27752
  importName: "__createBinding",
27693
27753
  scoped: false,
27694
27754
  priority: 1,
27695
- text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n }) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n }));"
27755
+ text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n }) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n }));"
27696
27756
  };
27697
27757
  ts.setModuleDefaultHelper = {
27698
27758
  name: "typescript:commonjscreatevalue",
@@ -35199,7 +35259,7 @@ var ts;
35199
35259
  // one out no matter what.
35200
35260
  var finallyBlock;
35201
35261
  if (!catchClause || token() === 96 /* FinallyKeyword */) {
35202
- parseExpected(96 /* FinallyKeyword */);
35262
+ parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected);
35203
35263
  finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
35204
35264
  }
35205
35265
  return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc);
@@ -36243,7 +36303,7 @@ var ts;
36243
36303
  var pos = getNodePos();
36244
36304
  var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
36245
36305
  parseExpected(58 /* ColonToken */);
36246
- var value = parseLiteralLikeNode(10 /* StringLiteral */);
36306
+ var value = parseAssignmentExpressionOrHigher();
36247
36307
  return finishNode(factory.createAssertEntry(name, value), pos);
36248
36308
  }
36249
36309
  function parseAssertClause() {
@@ -41327,7 +41387,7 @@ var ts;
41327
41387
  ? 1 /* Recursive */ : 0 /* None */
41328
41388
  };
41329
41389
  }
41330
- if (ts.isImplicitGlob(spec)) {
41390
+ if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
41331
41391
  return {
41332
41392
  key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
41333
41393
  flags: 1 /* Recursive */
@@ -44660,7 +44720,7 @@ var ts;
44660
44720
  maybeBindExpressionFlowIfCall(node.expression);
44661
44721
  }
44662
44722
  function maybeBindExpressionFlowIfCall(node) {
44663
- // A top level or LHS of comma expression call expression with a dotted function name and at least one argument
44723
+ // A top level or comma expression call expression with a dotted function name and at least one argument
44664
44724
  // is potentially an assertion and is therefore included in the control flow.
44665
44725
  if (node.kind === 207 /* CallExpression */) {
44666
44726
  var call = node;
@@ -44828,22 +44888,27 @@ var ts;
44828
44888
  }
44829
44889
  return state;
44830
44890
  }
44831
- function onLeft(left, state, _node) {
44891
+ function onLeft(left, state, node) {
44832
44892
  if (!state.skip) {
44833
- return maybeBind(left);
44893
+ var maybeBound = maybeBind(left);
44894
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44895
+ maybeBindExpressionFlowIfCall(left);
44896
+ }
44897
+ return maybeBound;
44834
44898
  }
44835
44899
  }
44836
- function onOperator(operatorToken, state, node) {
44900
+ function onOperator(operatorToken, state, _node) {
44837
44901
  if (!state.skip) {
44838
- if (operatorToken.kind === 27 /* CommaToken */) {
44839
- maybeBindExpressionFlowIfCall(node.left);
44840
- }
44841
44902
  bind(operatorToken);
44842
44903
  }
44843
44904
  }
44844
- function onRight(right, state, _node) {
44905
+ function onRight(right, state, node) {
44845
44906
  if (!state.skip) {
44846
- return maybeBind(right);
44907
+ var maybeBound = maybeBind(right);
44908
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44909
+ maybeBindExpressionFlowIfCall(right);
44910
+ }
44911
+ return maybeBound;
44847
44912
  }
44848
44913
  }
44849
44914
  function onExit(node, state) {
@@ -45586,6 +45651,8 @@ var ts;
45586
45651
  return;
45587
45652
  }
45588
45653
  ts.setParent(node, parent);
45654
+ if (ts.tracing)
45655
+ node.tracingPath = file.path;
45589
45656
  var saveInStrictMode = inStrictMode;
45590
45657
  // Even though in the AST the jsdoc @typedef node belongs to the current node,
45591
45658
  // its symbol might be in the same scope with the current node's symbol. Consider:
@@ -46406,7 +46473,7 @@ var ts;
46406
46473
  checkStrictModeEvalOrArguments(node, node.name);
46407
46474
  }
46408
46475
  if (!ts.isBindingPattern(node.name)) {
46409
- if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) {
46476
+ if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
46410
46477
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
46411
46478
  }
46412
46479
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -46917,6 +46984,9 @@ var ts;
46917
46984
  TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
46918
46985
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
46919
46986
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
46987
+ // Masks
46988
+ TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
46989
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
46920
46990
  })(TypeFacts || (TypeFacts = {}));
46921
46991
  var typeofEQFacts = new ts.Map(ts.getEntries({
46922
46992
  string: 1 /* TypeofEQString */,
@@ -49189,7 +49259,7 @@ var ts;
49189
49259
  && isAliasableOrJsExpression(node.parent.right)
49190
49260
  || node.kind === 295 /* ShorthandPropertyAssignment */
49191
49261
  || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
49192
- || ts.isRequireVariableDeclaration(node);
49262
+ || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
49193
49263
  }
49194
49264
  function isAliasableOrJsExpression(e) {
49195
49265
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -49977,8 +50047,14 @@ var ts;
49977
50047
  var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49978
50048
  var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
49979
50049
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
49980
- var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
50050
+ var sourceFile = resolvedModule
50051
+ && (!resolutionDiagnostic || resolutionDiagnostic === ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set)
50052
+ && host.getSourceFile(resolvedModule.resolvedFileName);
49981
50053
  if (sourceFile) {
50054
+ // If there's a resolutionDiagnostic we need to report it even if a sourceFile is found.
50055
+ if (resolutionDiagnostic) {
50056
+ error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
50057
+ }
49982
50058
  if (sourceFile.symbol) {
49983
50059
  if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
49984
50060
  errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
@@ -51120,6 +51196,7 @@ var ts;
51120
51196
  getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
51121
51197
  getCurrentDirectory: function () { return host.getCurrentDirectory(); },
51122
51198
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
51199
+ getPackageJsonInfoCache: function () { var _a; return (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host); },
51123
51200
  useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
51124
51201
  redirectTargetsMap: host.redirectTargetsMap,
51125
51202
  getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
@@ -68051,10 +68128,23 @@ var ts;
68051
68128
  // When an intersection contains a primitive type we ignore object type constituents as they are
68052
68129
  // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
68053
68130
  ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
68054
- return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */);
68131
+ return getIntersectionTypeFacts(type, ignoreObjects);
68055
68132
  }
68056
68133
  return 16777215 /* All */;
68057
68134
  }
68135
+ function getIntersectionTypeFacts(type, ignoreObjects) {
68136
+ // When computing the type facts of an intersection type, certain type facts are computed as `and`
68137
+ // and others are computed as `or`.
68138
+ var oredFacts = 0 /* None */;
68139
+ var andedFacts = 16777215 /* All */;
68140
+ for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
68141
+ var t = _a[_i];
68142
+ var f = getTypeFacts(t, ignoreObjects);
68143
+ oredFacts |= f;
68144
+ andedFacts &= f;
68145
+ }
68146
+ return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68147
+ }
68058
68148
  function getTypeWithFacts(type, include) {
68059
68149
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
68060
68150
  }
@@ -73058,9 +73148,6 @@ var ts;
73058
73148
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
73059
73149
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
73060
73150
  }
73061
- if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
73062
- addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
73063
- }
73064
73151
  }
73065
73152
  else {
73066
73153
  if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) {
@@ -78069,7 +78156,7 @@ var ts;
78069
78156
  }
78070
78157
  }
78071
78158
  function checkExpression(node, checkMode, forceTuple) {
78072
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
78159
+ 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 });
78073
78160
  var saveCurrentNode = currentNode;
78074
78161
  currentNode = node;
78075
78162
  instantiationCount = 0;
@@ -78715,32 +78802,38 @@ var ts;
78715
78802
  if (classExtendsNull) {
78716
78803
  error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
78717
78804
  }
78718
- // The first statement in the body of a constructor (excluding prologue directives) must be a super call
78719
- // if both of the following are true:
78805
+ // A super call must be root-level in a constructor if both of the following are true:
78720
78806
  // - The containing class is a derived class.
78721
78807
  // - The constructor declares parameter properties
78722
78808
  // or the containing class declares instance member variables with initializers.
78723
- var superCallShouldBeFirst = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
78809
+ var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
78724
78810
  (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
78725
78811
  ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
78726
- // Skip past any prologue directives to find the first statement
78727
- // to ensure that it was a super call.
78728
- if (superCallShouldBeFirst) {
78729
- var statements = node.body.statements;
78730
- var superCallStatement = void 0;
78731
- for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
78732
- var statement = statements_4[_i];
78733
- if (statement.kind === 237 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) {
78734
- superCallStatement = statement;
78735
- break;
78812
+ if (superCallShouldBeRootLevel) {
78813
+ // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
78814
+ // See GH #8277
78815
+ if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
78816
+ error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
78817
+ }
78818
+ // Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
78819
+ else {
78820
+ var superCallStatement = void 0;
78821
+ for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
78822
+ var statement = _a[_i];
78823
+ if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
78824
+ superCallStatement = statement;
78825
+ break;
78826
+ }
78827
+ if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
78828
+ break;
78829
+ }
78736
78830
  }
78737
- if (!ts.isPrologueDirective(statement)) {
78738
- break;
78831
+ // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
78832
+ // See GH #8277
78833
+ if (superCallStatement === undefined) {
78834
+ error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
78739
78835
  }
78740
78836
  }
78741
- if (!superCallStatement) {
78742
- error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
78743
- }
78744
78837
  }
78745
78838
  }
78746
78839
  else if (!classExtendsNull) {
@@ -78748,6 +78841,19 @@ var ts;
78748
78841
  }
78749
78842
  }
78750
78843
  }
78844
+ function superCallIsRootLevelInConstructor(superCall, body) {
78845
+ var superCallParent = ts.walkUpParenthesizedExpressions(superCall.parent);
78846
+ return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body;
78847
+ }
78848
+ function nodeImmediatelyReferencesSuperOrThis(node) {
78849
+ if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) {
78850
+ return true;
78851
+ }
78852
+ if (ts.isThisContainerOrFunctionBlock(node)) {
78853
+ return false;
78854
+ }
78855
+ return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
78856
+ }
78751
78857
  function checkAccessorDeclaration(node) {
78752
78858
  if (produceDiagnostics) {
78753
78859
  // Grammar checking accessors
@@ -80731,7 +80837,7 @@ var ts;
80731
80837
  }
80732
80838
  // For a commonjs `const x = require`, validate the alias and exit
80733
80839
  var symbol = getSymbolOfNode(node);
80734
- if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) {
80840
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
80735
80841
  checkAliasSymbol(node);
80736
80842
  return;
80737
80843
  }
@@ -80809,7 +80915,7 @@ var ts;
80809
80915
  return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
80810
80916
  }
80811
80917
  function checkVariableDeclaration(node) {
80812
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
80918
+ 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 });
80813
80919
  checkGrammarVariableDeclaration(node);
80814
80920
  checkVariableLikeDeclaration(node);
80815
80921
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -83199,6 +83305,17 @@ var ts;
83199
83305
  return false;
83200
83306
  }
83201
83307
  }
83308
+ if (!ts.isImportEqualsDeclaration(node) && node.assertClause) {
83309
+ var hasError = false;
83310
+ for (var _i = 0, _a = node.assertClause.elements; _i < _a.length; _i++) {
83311
+ var clause = _a[_i];
83312
+ if (!ts.isStringLiteral(clause.value)) {
83313
+ hasError = true;
83314
+ error(clause.value, ts.Diagnostics.Import_assertion_values_must_be_string_literal_expressions);
83315
+ }
83316
+ }
83317
+ return !hasError;
83318
+ }
83202
83319
  return true;
83203
83320
  }
83204
83321
  function checkAliasSymbol(node) {
@@ -83892,7 +84009,7 @@ var ts;
83892
84009
  }
83893
84010
  }
83894
84011
  function checkDeferredNode(node) {
83895
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
84012
+ 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 });
83896
84013
  var saveCurrentNode = currentNode;
83897
84014
  currentNode = node;
83898
84015
  instantiationCount = 0;
@@ -87826,7 +87943,7 @@ var ts;
87826
87943
  return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine);
87827
87944
  case 293 /* AssertEntry */:
87828
87945
  ts.Debug.type(node);
87829
- return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isStringLiteral));
87946
+ return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode));
87830
87947
  case 266 /* ImportClause */:
87831
87948
  ts.Debug.type(node);
87832
87949
  return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
@@ -88870,34 +88987,31 @@ var ts;
88870
88987
  }
88871
88988
  ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
88872
88989
  /**
88873
- * Adds super call and preceding prologue directives into the list of statements.
88874
- *
88875
- * @param ctor The constructor node.
88876
- * @param result The list of statements.
88877
- * @param visitor The visitor to apply to each node added to the result array.
88878
- * @returns index of the statement that follows super call
88990
+ * @returns Contained super() call from descending into the statement ignoring parentheses, if that call exists.
88991
+ */
88992
+ function getSuperCallFromStatement(statement) {
88993
+ if (!ts.isExpressionStatement(statement)) {
88994
+ return undefined;
88995
+ }
88996
+ var expression = ts.skipParentheses(statement.expression);
88997
+ return ts.isSuperCall(expression)
88998
+ ? expression
88999
+ : undefined;
89000
+ }
89001
+ ts.getSuperCallFromStatement = getSuperCallFromStatement;
89002
+ /**
89003
+ * @returns The index (after prologue statements) of a super call, or -1 if not found.
88879
89004
  */
88880
- function addPrologueDirectivesAndInitialSuperCall(factory, ctor, result, visitor) {
88881
- if (ctor.body) {
88882
- var statements = ctor.body.statements;
88883
- // add prologue directives to the list (if any)
88884
- var index = factory.copyPrologue(statements, result, /*ensureUseStrict*/ false, visitor);
88885
- if (index === statements.length) {
88886
- // list contains nothing but prologue directives (or empty) - exit
88887
- return index;
88888
- }
88889
- var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
88890
- if (superIndex > -1) {
88891
- for (var i = index; i <= superIndex; i++) {
88892
- result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
88893
- }
88894
- return superIndex + 1;
89005
+ function findSuperStatementIndex(statements, indexAfterLastPrologueStatement) {
89006
+ for (var i = indexAfterLastPrologueStatement; i < statements.length; i += 1) {
89007
+ var statement = statements[i];
89008
+ if (getSuperCallFromStatement(statement)) {
89009
+ return i;
88895
89010
  }
88896
- return index;
88897
89011
  }
88898
- return 0;
89012
+ return -1;
88899
89013
  }
88900
- ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
89014
+ ts.findSuperStatementIndex = findSuperStatementIndex;
88901
89015
  function getProperties(node, requireInitializer, isStatic) {
88902
89016
  return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
88903
89017
  }
@@ -90796,6 +90910,7 @@ var ts;
90796
90910
  case 176 /* TypePredicate */:
90797
90911
  case 133 /* BooleanKeyword */:
90798
90912
  return factory.createIdentifier("Boolean");
90913
+ case 197 /* TemplateLiteralType */:
90799
90914
  case 149 /* StringKeyword */:
90800
90915
  return factory.createIdentifier("String");
90801
90916
  case 147 /* ObjectKeyword */:
@@ -91134,10 +91249,14 @@ var ts;
91134
91249
  return ts.visitFunctionBody(body, visitor, context);
91135
91250
  }
91136
91251
  var statements = [];
91137
- var indexOfFirstStatement = 0;
91138
91252
  resumeLexicalEnvironment();
91139
- indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
91140
- // Add parameters with property assignments. Transforms this:
91253
+ var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
91254
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
91255
+ // If there was a super call, visit existing statements up to and including it
91256
+ if (superStatementIndex >= 0) {
91257
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
91258
+ }
91259
+ // Transform parameters into property assignments. Transforms this:
91141
91260
  //
91142
91261
  // constructor (public x, public y) {
91143
91262
  // }
@@ -91149,9 +91268,17 @@ var ts;
91149
91268
  // this.y = y;
91150
91269
  // }
91151
91270
  //
91152
- ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
91153
- // Add the existing statements, skipping the initial super call.
91154
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
91271
+ var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment);
91272
+ // If there is a super() call, the parameter properties go immediately after it
91273
+ if (superStatementIndex >= 0) {
91274
+ ts.addRange(statements, parameterPropertyAssignments);
91275
+ }
91276
+ // Since there was no super() call, parameter properties are the first statements in the constructor
91277
+ else {
91278
+ statements = ts.addRange(parameterPropertyAssignments, statements);
91279
+ }
91280
+ // Add remaining statements from the body, skipping the super() call if it was found
91281
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
91155
91282
  // End the lexical environment.
91156
91283
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
91157
91284
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -93049,6 +93176,7 @@ var ts;
93049
93176
  /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
93050
93177
  }
93051
93178
  function transformConstructorBody(node, constructor, isDerivedClass) {
93179
+ var _a;
93052
93180
  var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false);
93053
93181
  if (!useDefineForClassFields) {
93054
93182
  properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
@@ -93060,9 +93188,21 @@ var ts;
93060
93188
  return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
93061
93189
  }
93062
93190
  resumeLexicalEnvironment();
93063
- var indexOfFirstStatement = 0;
93191
+ var needsSyntheticConstructor = !constructor && isDerivedClass;
93192
+ var indexOfFirstStatementAfterSuper = 0;
93193
+ var prologueStatementCount = 0;
93194
+ var superStatementIndex = -1;
93064
93195
  var statements = [];
93065
- if (!constructor && isDerivedClass) {
93196
+ if ((_a = constructor === null || constructor === void 0 ? void 0 : constructor.body) === null || _a === void 0 ? void 0 : _a.statements) {
93197
+ prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, /*ensureUseStrict*/ false, visitor);
93198
+ superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
93199
+ // If there was a super call, visit existing statements up to and including it
93200
+ if (superStatementIndex >= 0) {
93201
+ indexOfFirstStatementAfterSuper = superStatementIndex + 1;
93202
+ 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);
93203
+ }
93204
+ }
93205
+ if (needsSyntheticConstructor) {
93066
93206
  // Add a synthetic `super` call:
93067
93207
  //
93068
93208
  // super(...arguments);
@@ -93070,9 +93210,6 @@ var ts;
93070
93210
  statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(),
93071
93211
  /*typeArguments*/ undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
93072
93212
  }
93073
- if (constructor) {
93074
- indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
93075
- }
93076
93213
  // Add the property initializers. Transforms this:
93077
93214
  //
93078
93215
  // public x = 1;
@@ -93083,31 +93220,59 @@ var ts;
93083
93220
  // this.x = 1;
93084
93221
  // }
93085
93222
  //
93223
+ // If we do useDefineForClassFields, they'll be converted elsewhere.
93224
+ // We instead *remove* them from the transformed output at this stage.
93225
+ var parameterPropertyDeclarationCount = 0;
93086
93226
  if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
93087
- var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
93088
- if (afterParameterProperties === -1) {
93089
- afterParameterProperties = constructor.body.statements.length;
93227
+ if (useDefineForClassFields) {
93228
+ statements = statements.filter(function (statement) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor); });
93090
93229
  }
93091
- if (afterParameterProperties > indexOfFirstStatement) {
93092
- if (!useDefineForClassFields) {
93093
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
93230
+ else {
93231
+ for (var _i = 0, _b = constructor.body.statements; _i < _b.length; _i++) {
93232
+ var statement = _b[_i];
93233
+ if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
93234
+ parameterPropertyDeclarationCount++;
93235
+ }
93236
+ }
93237
+ if (parameterPropertyDeclarationCount > 0) {
93238
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
93239
+ // If there was a super() call found, add parameter properties immediately after it
93240
+ if (superStatementIndex >= 0) {
93241
+ ts.addRange(statements, parameterProperties);
93242
+ }
93243
+ // If a synthetic super() call was added, add them just after it
93244
+ else if (needsSyntheticConstructor) {
93245
+ statements = __spreadArray(__spreadArray([
93246
+ statements[0]
93247
+ ], parameterProperties, true), statements.slice(1), true);
93248
+ }
93249
+ // Since there wasn't a super() call, add them to the top of the constructor
93250
+ else {
93251
+ statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
93252
+ }
93253
+ indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
93094
93254
  }
93095
- indexOfFirstStatement = afterParameterProperties;
93096
93255
  }
93097
93256
  }
93098
93257
  var receiver = factory.createThis();
93099
93258
  // private methods can be called in property initializers, they should execute first.
93100
93259
  addMethodStatements(statements, privateMethodsAndAccessors, receiver);
93101
93260
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
93102
- // Add existing statements, skipping the initial super call.
93261
+ // Add existing statements after the initial prologues and super call
93103
93262
  if (constructor) {
93104
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
93263
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
93105
93264
  }
93106
93265
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
93107
93266
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
93108
93267
  /*location*/ constructor ? constructor.body.statements : node.members),
93109
93268
  /*multiLine*/ true),
93110
93269
  /*location*/ constructor ? constructor.body : undefined);
93270
+ function visitBodyStatement(statement) {
93271
+ if (useDefineForClassFields && ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
93272
+ return undefined;
93273
+ }
93274
+ return visitor(statement);
93275
+ }
93111
93276
  }
93112
93277
  /**
93113
93278
  * Generates assignment statements for property initializers.
@@ -95628,10 +95793,19 @@ var ts;
95628
95793
  var _a;
95629
95794
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95630
95795
  var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
95631
- var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
95796
+ var args = [tagName, objectProperties];
95797
+ // function jsx(type, config, maybeKey) {}
95798
+ // "maybeKey" is optional. It is acceptable to use "_jsx" without a third argument
95799
+ if (keyAttr) {
95800
+ args.push(transformJsxAttributeInitializer(keyAttr.initializer));
95801
+ }
95632
95802
  if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
95633
95803
  var originalFile = ts.getOriginalNode(currentSourceFile);
95634
95804
  if (originalFile && ts.isSourceFile(originalFile)) {
95805
+ // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature
95806
+ if (keyAttr === undefined) {
95807
+ args.push(factory.createVoidZero());
95808
+ }
95635
95809
  // isStaticChildren development flag
95636
95810
  args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
95637
95811
  // __source development flag
@@ -96899,37 +97073,39 @@ var ts;
96899
97073
  var prologue = [];
96900
97074
  var statements = [];
96901
97075
  resumeLexicalEnvironment();
97076
+ // In derived classes, there may be code before the necessary super() call
97077
+ // We'll remove pre-super statements to be tacked on after the rest of the body
97078
+ var existingPrologue = ts.takeWhile(constructor.body.statements, ts.isPrologueDirective);
97079
+ var _a = findSuperCallAndStatementIndex(constructor.body.statements, existingPrologue), superCall = _a.superCall, superStatementIndex = _a.superStatementIndex;
97080
+ var postSuperStatementsStart = superStatementIndex === -1 ? existingPrologue.length : superStatementIndex + 1;
96902
97081
  // If a super call has already been synthesized,
96903
97082
  // we're going to assume that we should just transform everything after that.
96904
97083
  // The assumption is that no prior step in the pipeline has added any prologue directives.
96905
- var statementOffset = 0;
97084
+ var statementOffset = postSuperStatementsStart;
96906
97085
  if (!hasSynthesizedSuper)
96907
- statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, /*ensureUseStrict*/ false);
96908
- addDefaultValueAssignmentsIfNeeded(statements, constructor);
96909
- addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
97086
+ statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, statementOffset, /*ensureUseStrict*/ false);
96910
97087
  if (!hasSynthesizedSuper)
96911
- statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
96912
- // If the first statement is a call to `super()`, visit the statement directly
97088
+ statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor, /*filter*/ undefined);
97089
+ // If there already exists a call to `super()`, visit the statement directly
96913
97090
  var superCallExpression;
96914
97091
  if (hasSynthesizedSuper) {
96915
97092
  superCallExpression = createDefaultSuperCallOrThis();
96916
97093
  }
96917
- else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
96918
- var firstStatement = constructor.body.statements[statementOffset];
96919
- if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
96920
- superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
96921
- }
97094
+ else if (superCall) {
97095
+ superCallExpression = visitSuperCallInBody(superCall);
96922
97096
  }
96923
97097
  if (superCallExpression) {
96924
97098
  hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
96925
- statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
96926
97099
  }
97100
+ // Add parameter defaults at the beginning of the output, with prologue statements
97101
+ addDefaultValueAssignmentsIfNeeded(prologue, constructor);
97102
+ addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
96927
97103
  // visit the remaining statements
96928
97104
  ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset));
96929
97105
  factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
96930
97106
  insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
96931
- if (isDerivedClass) {
96932
- if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
97107
+ if (isDerivedClass || superCallExpression) {
97108
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
96933
97109
  // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
96934
97110
  // following representation:
96935
97111
  //
@@ -96949,10 +97125,10 @@ var ts;
96949
97125
  // return C;
96950
97126
  // })(Base);
96951
97127
  // ```
96952
- var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
97128
+ var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
96953
97129
  var returnStatement = factory.createReturnStatement(superCallExpression);
96954
- ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
96955
- ts.setEmitFlags(superCall, 1536 /* NoComments */);
97130
+ ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1));
97131
+ ts.setEmitFlags(superCall_1, 1536 /* NoComments */);
96956
97132
  statements.push(returnStatement);
96957
97133
  }
96958
97134
  else {
@@ -96977,9 +97153,19 @@ var ts;
96977
97153
  // return C;
96978
97154
  // })(Base);
96979
97155
  // ```
96980
- // Since the `super()` call was the first statement, we insert the `this` capturing call to
96981
- // `super()` at the top of the list of `statements` (after any pre-existing custom prologues).
96982
- insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
97156
+ // If the super() call is the first statement, we can directly create and assign its result to `_this`
97157
+ if (superStatementIndex <= existingPrologue.length) {
97158
+ insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
97159
+ }
97160
+ // Since the `super()` call isn't the first statement, it's split across 1-2 statements:
97161
+ // * A prologue `var _this = this;`, in case the constructor accesses this before super()
97162
+ // * If it exists, a reassignment to that `_this` of the super() call
97163
+ else {
97164
+ insertCaptureThisForNode(prologue, constructor, createActualThis());
97165
+ if (superCallExpression) {
97166
+ insertSuperThisCaptureThisForNode(statements, superCallExpression);
97167
+ }
97168
+ }
96983
97169
  if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
96984
97170
  statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
96985
97171
  }
@@ -97002,11 +97188,27 @@ var ts;
97002
97188
  // ```
97003
97189
  insertCaptureThisForNodeIfNeeded(prologue, constructor);
97004
97190
  }
97005
- var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)),
97191
+ 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)),
97006
97192
  /*location*/ constructor.body.statements),
97007
97193
  /*multiLine*/ true);
97008
- ts.setTextRange(block, constructor.body);
97009
- return block;
97194
+ ts.setTextRange(body, constructor.body);
97195
+ return body;
97196
+ }
97197
+ function findSuperCallAndStatementIndex(originalBodyStatements, existingPrologue) {
97198
+ for (var i = existingPrologue.length; i < originalBodyStatements.length; i += 1) {
97199
+ var superCall = ts.getSuperCallFromStatement(originalBodyStatements[i]);
97200
+ if (superCall) {
97201
+ // With a super() call, split the statements into pre-super() and 'body' (post-super())
97202
+ return {
97203
+ superCall: superCall,
97204
+ superStatementIndex: i,
97205
+ };
97206
+ }
97207
+ }
97208
+ // Since there was no super() call found, consider all statements to be in the main 'body' (post-super())
97209
+ return {
97210
+ superStatementIndex: -1,
97211
+ };
97010
97212
  }
97011
97213
  /**
97012
97214
  * We want to try to avoid emitting a return statement in certain cases if a user already returned something.
@@ -97235,6 +97437,18 @@ var ts;
97235
97437
  }
97236
97438
  return false;
97237
97439
  }
97440
+ /**
97441
+ * Assigns the `this` in a constructor to the result of its `super()` call.
97442
+ *
97443
+ * @param statements Statements in the constructor body.
97444
+ * @param superExpression Existing `super()` call for the constructor.
97445
+ */
97446
+ function insertSuperThisCaptureThisForNode(statements, superExpression) {
97447
+ enableSubstitutionsForCapturedThis();
97448
+ var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression));
97449
+ ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression);
97450
+ ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent);
97451
+ }
97238
97452
  function insertCaptureThisForNode(statements, node, initializer) {
97239
97453
  enableSubstitutionsForCapturedThis();
97240
97454
  var captureThisStatement = factory.createVariableStatement(
@@ -97544,7 +97758,7 @@ var ts;
97544
97758
  if (ts.isBlock(body)) {
97545
97759
  // ensureUseStrict is false because no new prologue-directive should be added.
97546
97760
  // addStandardPrologue will put already-existing directives at the beginning of the target statement-array
97547
- statementOffset = factory.copyStandardPrologue(body.statements, prologue, /*ensureUseStrict*/ false);
97761
+ statementOffset = factory.copyStandardPrologue(body.statements, prologue, 0, /*ensureUseStrict*/ false);
97548
97762
  statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
97549
97763
  statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
97550
97764
  }
@@ -98915,7 +99129,7 @@ var ts;
98915
99129
  /*type*/ undefined, factory.updateBlock(func.body, statements))),
98916
99130
  /*typeArguments*/ undefined, call.arguments))));
98917
99131
  }
98918
- function visitImmediateSuperCallInBody(node) {
99132
+ function visitSuperCallInBody(node) {
98919
99133
  return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false);
98920
99134
  }
98921
99135
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
@@ -119456,11 +119670,12 @@ var ts;
119456
119670
  };
119457
119671
  }
119458
119672
  function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
119673
+ var _a;
119459
119674
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
119460
119675
  && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
119461
119676
  return false;
119462
119677
  }
119463
- return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119678
+ return ts.getImpliedNodeFormatForFile(importingSourceFileName, (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host), getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119464
119679
  }
119465
119680
  function getModuleResolutionHost(host) {
119466
119681
  var _a;
@@ -120020,11 +120235,13 @@ var ts;
120020
120235
  // For classic resolution, only allow importing from node_modules/@types, not other node_modules
120021
120236
  return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
120022
120237
  function tryDirectoryWithPackageJson(packageRootIndex) {
120238
+ var _a, _b;
120023
120239
  var packageRootPath = path.substring(0, packageRootIndex);
120024
120240
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
120025
120241
  var moduleFileToTry = path;
120026
- if (host.fileExists(packageJsonPath)) {
120027
- var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
120242
+ var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
120243
+ if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
120244
+ var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
120028
120245
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
120029
120246
  // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
120030
120247
  // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
@@ -120324,22 +120541,31 @@ var ts;
120324
120541
  ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
120325
120542
  }
120326
120543
  ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
120544
+ function prettyPathForFileError(error, cwd) {
120545
+ var line = ts.formatColorAndReset(":" + error.line, ts.ForegroundColorEscapeSequences.Grey);
120546
+ if (ts.pathIsAbsolute(error.fileName) && ts.pathIsAbsolute(cwd)) {
120547
+ return ts.getRelativePathFromDirectory(cwd, error.fileName, /* ignoreCase */ false) + line;
120548
+ }
120549
+ return error.fileName + line;
120550
+ }
120327
120551
  function getErrorSummaryText(errorCount, filesInError, newLine, host) {
120328
120552
  if (errorCount === 0)
120329
120553
  return "";
120330
120554
  var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
120331
120555
  var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; })
120332
120556
  .filter(function (value, index, self) { return self.indexOf(value) === index; });
120557
+ var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory());
120333
120558
  var d = errorCount === 1 ?
120334
120559
  ts.createCompilerDiagnostic(filesInError[0] !== undefined ?
120335
120560
  ts.Diagnostics.Found_1_error_in_1 :
120336
- ts.Diagnostics.Found_1_error, errorCount, distinctFileNamesWithLines[0]) :
120561
+ ts.Diagnostics.Found_1_error, errorCount, firstFileReference) :
120337
120562
  ts.createCompilerDiagnostic(distinctFileNamesWithLines.length === 0 ?
120338
120563
  ts.Diagnostics.Found_0_errors :
120339
120564
  distinctFileNamesWithLines.length === 1 ?
120340
- ts.Diagnostics.Found_0_errors_in_1_file :
120341
- ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
120342
- return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
120565
+ ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 :
120566
+ ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length);
120567
+ var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "";
120568
+ return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix;
120343
120569
  }
120344
120570
  ts.getErrorSummaryText = getErrorSummaryText;
120345
120571
  function createTabularErrorsDisplay(filesInError, host) {
@@ -120361,8 +120587,8 @@ var ts;
120361
120587
  var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
120362
120588
  " ".repeat(leftPaddingGoal - errorCountDigitsLength)
120363
120589
  : "";
120364
- var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
120365
- tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
120590
+ var fileRef = prettyPathForFileError(file, host.getCurrentDirectory());
120591
+ tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n";
120366
120592
  });
120367
120593
  return tabularData;
120368
120594
  }
@@ -120863,6 +121089,7 @@ var ts;
120863
121089
  var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
120864
121090
  var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
120865
121091
  var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
121092
+ var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
120866
121093
  var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
120867
121094
  var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files
120868
121095
  var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations
@@ -121025,14 +121252,21 @@ var ts;
121025
121252
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
121026
121253
  if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
121027
121254
  if (hasChangedConfigFileParsingErrors) {
121255
+ if (reportFileChangeDetectedOnCreateProgram) {
121256
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121257
+ }
121028
121258
  builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
121029
121259
  hasChangedConfigFileParsingErrors = false;
121030
121260
  }
121031
121261
  }
121032
121262
  else {
121263
+ if (reportFileChangeDetectedOnCreateProgram) {
121264
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121265
+ }
121033
121266
  createNewProgram(hasInvalidatedResolution);
121034
121267
  }
121035
121268
  changesAffectResolution = false; // reset for next sync
121269
+ reportFileChangeDetectedOnCreateProgram = false;
121036
121270
  if (host.afterProgramCreate && program !== builderProgram) {
121037
121271
  host.afterProgramCreate(builderProgram);
121038
121272
  }
@@ -121234,7 +121468,7 @@ var ts;
121234
121468
  }
121235
121469
  function updateProgramWithWatchStatus() {
121236
121470
  timerToUpdateProgram = undefined;
121237
- reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121471
+ reportFileChangeDetectedOnCreateProgram = true;
121238
121472
  updateProgram();
121239
121473
  }
121240
121474
  function updateProgram() {
@@ -123758,6 +123992,7 @@ var ts;
123758
123992
  ScriptElementKind["externalModuleName"] = "external module name";
123759
123993
  /**
123760
123994
  * <JsxTagName attribute1 attribute2={0} />
123995
+ * @deprecated
123761
123996
  */
123762
123997
  ScriptElementKind["jsxAttribute"] = "JSX attribute";
123763
123998
  /** String literal */
@@ -125083,7 +125318,7 @@ var ts;
125083
125318
  isWhiteSpaceOnlyJsxText(child);
125084
125319
  if (lookInPreviousChild) {
125085
125320
  // actual start of the node is past the position - previous token should be at the end of previous child
125086
- var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile);
125321
+ var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind);
125087
125322
  return candidate_1 && findRightmostToken(candidate_1, sourceFile);
125088
125323
  }
125089
125324
  else {
@@ -125097,7 +125332,7 @@ var ts;
125097
125332
  // the only known case is when position is at the end of the file.
125098
125333
  // Try to find the rightmost token in the file without filtering.
125099
125334
  // Namely we are skipping the check: 'position < node.end'
125100
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
125335
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
125101
125336
  return candidate && findRightmostToken(candidate, sourceFile);
125102
125337
  }
125103
125338
  }
@@ -125113,17 +125348,19 @@ var ts;
125113
125348
  if (children.length === 0) {
125114
125349
  return n;
125115
125350
  }
125116
- var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
125351
+ var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
125117
125352
  return candidate && findRightmostToken(candidate, sourceFile);
125118
125353
  }
125119
125354
  /**
125120
125355
  * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens.
125121
125356
  */
125122
- function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) {
125357
+ function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) {
125123
125358
  for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
125124
125359
  var child = children[i];
125125
125360
  if (isWhiteSpaceOnlyJsxText(child)) {
125126
- ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
125361
+ if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) {
125362
+ ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
125363
+ }
125127
125364
  }
125128
125365
  else if (nodeHasTokens(children[i], sourceFile)) {
125129
125366
  return children[i];
@@ -125649,6 +125886,7 @@ var ts;
125649
125886
  useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
125650
125887
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache,
125651
125888
  getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache),
125889
+ getPackageJsonInfoCache: function () { var _a; return (_a = program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); },
125652
125890
  getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation),
125653
125891
  redirectTargetsMap: program.redirectTargetsMap,
125654
125892
  getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); },
@@ -129335,6 +129573,8 @@ var ts;
129335
129573
  CompletionSource["ThisProperty"] = "ThisProperty/";
129336
129574
  /** Auto-import that comes attached to a class member snippet */
129337
129575
  CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
129576
+ /** A type-only import that needs to be promoted in order to be used at the completion location */
129577
+ CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
129338
129578
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
129339
129579
  var SymbolOriginInfoKind;
129340
129580
  (function (SymbolOriginInfoKind) {
@@ -129344,6 +129584,7 @@ var ts;
129344
129584
  SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
129345
129585
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
129346
129586
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
129587
+ SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
129347
129588
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
129348
129589
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
129349
129590
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -129371,6 +129612,9 @@ var ts;
129371
129612
  function originIsNullableMember(origin) {
129372
129613
  return !!(origin.kind & 16 /* Nullable */);
129373
129614
  }
129615
+ function originIsTypeOnlyAlias(origin) {
129616
+ return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
129617
+ }
129374
129618
  var KeywordCompletionFilters;
129375
129619
  (function (KeywordCompletionFilters) {
129376
129620
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -129393,6 +129637,7 @@ var ts;
129393
129637
  function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
129394
129638
  var _a, _b, _c;
129395
129639
  var start = ts.timestamp();
129640
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
129396
129641
  var resolutionLimitExceeded = false;
129397
129642
  var ambientCount = 0;
129398
129643
  var resolvedCount = 0;
@@ -129415,7 +129660,7 @@ var ts;
129415
129660
  var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
129416
129661
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
129417
129662
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
129418
- ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, shouldGetModuleSpecifierFromCache)
129663
+ ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
129419
129664
  : undefined;
129420
129665
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
129421
129666
  resolutionLimitExceeded = true;
@@ -129589,7 +129834,7 @@ var ts;
129589
129834
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
129590
129835
  }
129591
129836
  function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
129592
- 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, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
129837
+ 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, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
129593
129838
  // Verify if the file is JSX language variant
129594
129839
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
129595
129840
  var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
@@ -129600,7 +129845,7 @@ var ts;
129600
129845
  var entries = ts.createSortedArray();
129601
129846
  if (isUncheckedFile(sourceFile, compilerOptions)) {
129602
129847
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
129603
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129848
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
129604
129849
  getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
129605
129850
  }
129606
129851
  else {
@@ -129608,7 +129853,7 @@ var ts;
129608
129853
  return undefined;
129609
129854
  }
129610
129855
  getCompletionEntriesFromSymbols(symbols, entries,
129611
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129856
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
129612
129857
  }
129613
129858
  if (keywordFilters !== 0 /* None */) {
129614
129859
  var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
@@ -129714,7 +129959,7 @@ var ts;
129714
129959
  function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
129715
129960
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
129716
129961
  }
129717
- function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
129962
+ function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
129718
129963
  var _a, _b;
129719
129964
  var insertText;
129720
129965
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
@@ -129774,6 +130019,9 @@ var ts;
129774
130019
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
129775
130020
  }
129776
130021
  }
130022
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130023
+ hasAction = true;
130024
+ }
129777
130025
  if (preferences.includeCompletionsWithClassMemberSnippets &&
129778
130026
  preferences.includeCompletionsWithInsertText &&
129779
130027
  completionKind === 3 /* MemberLike */ &&
@@ -129785,8 +130033,7 @@ var ts;
129785
130033
  source = CompletionSource.ClassMemberSnippet;
129786
130034
  }
129787
130035
  }
129788
- var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
129789
- if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
130036
+ if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
129790
130037
  var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
129791
130038
  var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
129792
130039
  // If is boolean like or undefined, don't return a snippet we want just to return the completion.
@@ -129824,7 +130071,7 @@ var ts;
129824
130071
  // entries (like JavaScript identifier entries).
129825
130072
  return {
129826
130073
  name: name,
129827
- kind: kind,
130074
+ kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
129828
130075
  kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
129829
130076
  sortText: sortText,
129830
130077
  source: source,
@@ -130119,8 +130366,11 @@ var ts;
130119
130366
  if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
130120
130367
  return CompletionSource.ThisProperty;
130121
130368
  }
130369
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130370
+ return CompletionSource.TypeOnlyAlias;
130371
+ }
130122
130372
  }
130123
- function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
130373
+ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
130124
130374
  var _a;
130125
130375
  var start = ts.timestamp();
130126
130376
  var variableDeclaration = getVariableDeclaration(location);
@@ -130141,12 +130391,12 @@ var ts;
130141
130391
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
130142
130392
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
130143
130393
  var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
130144
- var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
130394
+ var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
130145
130395
  if (!entry) {
130146
130396
  continue;
130147
130397
  }
130148
130398
  /** True for locals; false for globals, module exports from other files, `this.` completions. */
130149
- var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130399
+ var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130150
130400
  uniques.set(name, shouldShadowLaterSymbols);
130151
130401
  ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
130152
130402
  }
@@ -130159,6 +130409,7 @@ var ts;
130159
130409
  add: function (name) { return uniques.set(name, true); },
130160
130410
  };
130161
130411
  function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
130412
+ var allFlags = symbol.flags;
130162
130413
  if (!ts.isSourceFile(location)) {
130163
130414
  // export = /**/ here we want to get all meanings, so any symbol is ok
130164
130415
  if (ts.isExportAssignment(location.parent)) {
@@ -130184,11 +130435,10 @@ var ts;
130184
130435
  || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
130185
130436
  return false;
130186
130437
  }
130187
- // Continue with origin symbol
130188
- symbol = symbolOrigin;
130438
+ allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
130189
130439
  // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
130190
130440
  if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
130191
- return !!(symbol.flags & 1920 /* Namespace */);
130441
+ return !!(allFlags & 1920 /* Namespace */);
130192
130442
  }
130193
130443
  if (isTypeOnlyLocation) {
130194
130444
  // It's a type, but you can reach it by namespace.type as well
@@ -130196,7 +130446,7 @@ var ts;
130196
130446
  }
130197
130447
  }
130198
130448
  // expressions are value space (which includes the value namespaces)
130199
- return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */);
130449
+ return !!(allFlags & 111551 /* Value */);
130200
130450
  }
130201
130451
  }
130202
130452
  Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
@@ -130349,6 +130599,11 @@ var ts;
130349
130599
  };
130350
130600
  }
130351
130601
  }
130602
+ if (originIsTypeOnlyAlias(origin)) {
130603
+ var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
130604
+ ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
130605
+ return { codeActions: [codeAction_1], sourceDisplay: undefined };
130606
+ }
130352
130607
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
130353
130608
  return { codeActions: undefined, sourceDisplay: undefined };
130354
130609
  }
@@ -130735,6 +130990,7 @@ var ts;
130735
130990
  symbolToSortTextIdMap: symbolToSortTextIdMap,
130736
130991
  isTypeOnlyLocation: isTypeOnlyLocation,
130737
130992
  isJsxIdentifierExpected: isJsxIdentifierExpected,
130993
+ isRightOfOpenTag: isRightOfOpenTag,
130738
130994
  importCompletionNode: importCompletionNode,
130739
130995
  hasUnresolvedAutoImports: hasUnresolvedAutoImports,
130740
130996
  };
@@ -130813,9 +131069,7 @@ var ts;
130813
131069
  // GH#39946. Pulling on the type of a node inside of a function with a contextual `this` parameter can result in a circularity
130814
131070
  // if the `node` is part of the exprssion of a `yield` or `return`. This circularity doesn't exist at compile time because
130815
131071
  // we will check (and cache) the type of `this` *before* checking the type of the node.
130816
- var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
130817
- if (!ts.isSourceFile(container) && container.parent)
130818
- typeChecker.getTypeAtLocation(container);
131072
+ typeChecker.tryGetThisTypeAt(node, /*includeGlobalThis*/ false);
130819
131073
  var type = typeChecker.getTypeAtLocation(node).getNonOptionalType();
130820
131074
  var insertQuestionDot = false;
130821
131075
  if (type.isNullableType()) {
@@ -131026,21 +131280,29 @@ var ts;
131026
131280
  var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
131027
131281
  isInSnippetScope = isSnippetScope(scopeNode);
131028
131282
  var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
131283
+ var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
131029
131284
  symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
131030
131285
  ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
131031
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
131032
- var symbol = symbols_1[_i];
131286
+ for (var i = 0; i < symbols.length; i++) {
131287
+ var symbol = symbols[i];
131033
131288
  if (!typeChecker.isArgumentsSymbol(symbol) &&
131034
131289
  !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
131035
131290
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
131036
131291
  }
131292
+ if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
131293
+ var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
131294
+ if (typeOnlyAliasDeclaration) {
131295
+ var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
131296
+ symbolToOriginInfoMap[i] = origin;
131297
+ }
131298
+ }
131037
131299
  }
131038
131300
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
131039
131301
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
131040
131302
  var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
131041
131303
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
131042
- for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
131043
- var symbol = _b[_a];
131304
+ for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
131305
+ var symbol = _a[_i];
131044
131306
  symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
131045
131307
  symbols.push(symbol);
131046
131308
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
@@ -132439,10 +132701,14 @@ var ts;
132439
132701
  /** True if symbol is a type or a module containing at least one type. */
132440
132702
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
132441
132703
  if (seenModules === void 0) { seenModules = new ts.Map(); }
132442
- var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker);
132443
- return !!(sym.flags & 788968 /* Type */) || checker.isUnknownSymbol(sym) ||
132444
- !!(sym.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(sym)) &&
132445
- checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132704
+ // Since an alias can be merged with a local declaration, we need to test both the alias and its target.
132705
+ // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
132706
+ return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
132707
+ function nonAliasCanBeReferencedAtTypeLocation(symbol) {
132708
+ return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
132709
+ !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
132710
+ checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132711
+ }
132446
132712
  }
132447
132713
  function isDeprecated(symbol, checker) {
132448
132714
  var declarations = ts.skipAlias(symbol, checker).declarations;
@@ -133670,7 +133936,7 @@ var ts;
133670
133936
  ts.Debug.assert(parent.name === node);
133671
133937
  return true;
133672
133938
  case 202 /* BindingElement */:
133673
- return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent);
133939
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
133674
133940
  default:
133675
133941
  return false;
133676
133942
  }
@@ -134151,7 +134417,7 @@ var ts;
134151
134417
  function getTextSpan(node, sourceFile, endNode) {
134152
134418
  var start = node.getStart(sourceFile);
134153
134419
  var end = (endNode || node).getEnd();
134154
- if (ts.isStringLiteralLike(node)) {
134420
+ if (ts.isStringLiteralLike(node) && (end - start) > 2) {
134155
134421
  ts.Debug.assert(endNode === undefined);
134156
134422
  start += 1;
134157
134423
  end -= 1;
@@ -134696,8 +134962,8 @@ var ts;
134696
134962
  var sourceId = ts.getNodeId(sourceFile);
134697
134963
  var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
134698
134964
  var anyNewSymbols = false;
134699
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
134700
- var sym = symbols_2[_i];
134965
+ for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
134966
+ var sym = symbols_1[_i];
134701
134967
  anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
134702
134968
  }
134703
134969
  return anyNewSymbols;
@@ -135070,7 +135336,7 @@ var ts;
135070
135336
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
135071
135337
  if (ts.isInJSFile(referenceLocation)
135072
135338
  && referenceLocation.parent.kind === 202 /* BindingElement */
135073
- && ts.isRequireVariableDeclaration(referenceLocation.parent)) {
135339
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
135074
135340
  referenceSymbol = referenceLocation.parent.symbol;
135075
135341
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
135076
135342
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -136671,7 +136937,7 @@ var ts;
136671
136937
  return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false };
136672
136938
  }
136673
136939
  if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size()) {
136674
- var node = ts.getTokenAtPosition(sourceFile, position);
136940
+ var node = ts.getTouchingToken(sourceFile, position);
136675
136941
  if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, ts.getModeForUsageLocation(sourceFile, node))) {
136676
136942
  var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
136677
136943
  var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text);
@@ -136781,7 +137047,7 @@ var ts;
136781
137047
  return declaration.parent.kind === 268 /* NamedImports */;
136782
137048
  case 202 /* BindingElement */:
136783
137049
  case 253 /* VariableDeclaration */:
136784
- return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration);
137050
+ return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
136785
137051
  default:
136786
137052
  return false;
136787
137053
  }
@@ -137471,7 +137737,7 @@ var ts;
137471
137737
  textSpan: ts.createTextSpanFromNode(declaration),
137472
137738
  // TODO(jfreeman): What should be the containerName when the container has a computed name?
137473
137739
  containerName: containerName ? containerName.text : "",
137474
- containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, // TODO: GH#18217 Just use `container ? ...`
137740
+ containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */,
137475
137741
  };
137476
137742
  }
137477
137743
  })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {}));
@@ -141685,18 +141951,7 @@ var ts;
141685
141951
  }
141686
141952
  return unionPropertyKind;
141687
141953
  }
141688
- // If we requested completions after `x.` at the top-level, we may be at a source file location.
141689
- switch (location.parent && location.parent.kind) {
141690
- // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'.
141691
- case 279 /* JsxOpeningElement */:
141692
- case 277 /* JsxElement */:
141693
- case 278 /* JsxSelfClosingElement */:
141694
- return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */;
141695
- case 284 /* JsxAttribute */:
141696
- return "JSX attribute" /* jsxAttribute */;
141697
- default:
141698
- return "property" /* memberVariableElement */;
141699
- }
141954
+ return "property" /* memberVariableElement */;
141700
141955
  }
141701
141956
  return "" /* unknown */;
141702
141957
  }
@@ -145560,6 +145815,7 @@ var ts;
145560
145815
  ChangeTracker.prototype.delete = function (sourceFile, node) {
145561
145816
  this.deletedNodes.push({ sourceFile: sourceFile, node: node });
145562
145817
  };
145818
+ /** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
145563
145819
  ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
145564
145820
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
145565
145821
  this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
@@ -145714,7 +145970,11 @@ var ts;
145714
145970
  oldTags[i] = merged;
145715
145971
  return !!merged;
145716
145972
  }); });
145717
- var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true)));
145973
+ var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
145974
+ var jsDoc = ts.singleOrUndefined(parent.jsDoc);
145975
+ var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
145976
+ ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
145977
+ var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
145718
145978
  var host = updateJSDocHost(parent);
145719
145979
  this.insertJsdocCommentBefore(sourceFile, host, tag);
145720
145980
  };
@@ -145959,6 +146219,15 @@ var ts;
145959
146219
  ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
145960
146220
  this.insertText(sourceFile, node.getStart(sourceFile), "export ");
145961
146221
  };
146222
+ ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
146223
+ var prevSpecifier = namedImports.elements[index - 1];
146224
+ if (prevSpecifier) {
146225
+ this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
146226
+ }
146227
+ else {
146228
+ this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
146229
+ }
146230
+ };
145962
146231
  /**
145963
146232
  * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
145964
146233
  * i.e. arguments in arguments lists, parameters in parameter lists etc.
@@ -146144,6 +146413,8 @@ var ts;
146144
146413
  }
146145
146414
  case 339 /* JSDocReturnTag */:
146146
146415
  return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146416
+ case 341 /* JSDocTypeTag */:
146417
+ return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146147
146418
  }
146148
146419
  }
146149
146420
  // find first non-whitespace position in the leading trivia of the node
@@ -146844,20 +147115,31 @@ var ts;
146844
147115
  codefix.registerCodeFix({
146845
147116
  errorCodes: errorCodes,
146846
147117
  getCodeActions: function getCodeActionsToAddConvertToUnknownForNonOverlappingTypes(context) {
146847
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); });
147118
+ var assertion = getAssertion(context.sourceFile, context.span.start);
147119
+ if (assertion === undefined)
147120
+ return undefined;
147121
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, assertion); });
146848
147122
  return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, ts.Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)];
146849
147123
  },
146850
147124
  fixIds: [fixId],
146851
- getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); },
147125
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
147126
+ var assertion = getAssertion(diag.file, diag.start);
147127
+ if (assertion) {
147128
+ makeChange(changes, diag.file, assertion);
147129
+ }
147130
+ }); },
146852
147131
  });
146853
- function makeChange(changeTracker, sourceFile, pos) {
146854
- var token = ts.getTokenAtPosition(sourceFile, pos);
146855
- var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression");
147132
+ function makeChange(changeTracker, sourceFile, assertion) {
146856
147133
  var replacement = ts.isAsExpression(assertion)
146857
147134
  ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */))
146858
147135
  : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */), assertion.expression);
146859
147136
  changeTracker.replaceNode(sourceFile, assertion.expression, replacement);
146860
147137
  }
147138
+ function getAssertion(sourceFile, pos) {
147139
+ if (ts.isInJSFile(sourceFile))
147140
+ return undefined;
147141
+ return ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); });
147142
+ }
146861
147143
  })(codefix = ts.codefix || (ts.codefix = {}));
146862
147144
  })(ts || (ts = {}));
146863
147145
  /* @internal */
@@ -149448,7 +149730,8 @@ var ts;
149448
149730
  ts.Diagnostics.Cannot_find_namespace_0.code,
149449
149731
  ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
149450
149732
  ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
149451
- ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
149733
+ ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
149734
+ ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
149452
149735
  ];
149453
149736
  codefix.registerCodeFix({
149454
149737
  errorCodes: errorCodes,
@@ -149553,6 +149836,9 @@ var ts;
149553
149836
  }
149554
149837
  break;
149555
149838
  }
149839
+ case 4 /* PromoteTypeOnly */:
149840
+ // Excluding from fix-all
149841
+ break;
149556
149842
  default:
149557
149843
  ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
149558
149844
  }
@@ -149644,6 +149930,7 @@ var ts;
149644
149930
  ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
149645
149931
  ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
149646
149932
  ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
149933
+ ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
149647
149934
  })(ImportFixKind || (ImportFixKind = {}));
149648
149935
  // These should not be combined as bitflags, but are given powers of 2 values to
149649
149936
  // easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
@@ -149669,9 +149956,17 @@ var ts;
149669
149956
  };
149670
149957
  }
149671
149958
  codefix.getImportCompletionAction = getImportCompletionAction;
149959
+ function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
149960
+ var compilerOptions = program.getCompilerOptions();
149961
+ var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
149962
+ var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
149963
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
149964
+ }
149965
+ codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
149672
149966
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149673
149967
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149674
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, host, preferences);
149968
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
149969
+ return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
149675
149970
  }
149676
149971
  function codeFixActionToCodeAction(_a) {
149677
149972
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -149726,12 +150021,12 @@ var ts;
149726
150021
  return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
149727
150022
  }
149728
150023
  }
149729
- function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, fromCacheOnly) {
150024
+ function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
149730
150025
  var _a = getNewImportFixes(program, importingFile,
149731
150026
  /*position*/ undefined,
149732
150027
  /*isValidTypeOnlyUseSite*/ false,
149733
150028
  /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
149734
- var result = getBestFix(fixes, importingFile, program, host, preferences);
150029
+ var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
149735
150030
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
149736
150031
  }
149737
150032
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
@@ -149865,7 +150160,7 @@ var ts;
149865
150160
  var importKind = getImportKind(importingFile, exportKind, compilerOptions);
149866
150161
  return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
149867
150162
  var i = ts.importFromModuleSpecifier(moduleSpecifier);
149868
- if (ts.isRequireVariableDeclaration(i.parent)) {
150163
+ if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
149869
150164
  return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
149870
150165
  }
149871
150166
  if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) {
@@ -149948,26 +150243,34 @@ var ts;
149948
150243
  }
149949
150244
  function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
149950
150245
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
149951
- var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
149952
- ? getFixesInfoForUMDImport(context, symbolToken)
149953
- : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
149954
- return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, context.host, context.preferences) });
150246
+ if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
150247
+ return getFixesInfoForUMDImport(context, symbolToken);
150248
+ }
150249
+ if (!ts.isIdentifier(symbolToken)) {
150250
+ return undefined;
150251
+ }
150252
+ if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
150253
+ var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
150254
+ var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
150255
+ return fix && { fixes: [fix], symbolName: symbolName_1 };
150256
+ }
150257
+ var info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
150258
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150259
+ return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
149955
150260
  }
149956
- function sortFixes(fixes, sourceFile, program, host, preferences) {
149957
- var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
149958
- return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, allowsImportingSpecifier); });
150261
+ function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
150262
+ return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier); });
149959
150263
  }
149960
- function getBestFix(fixes, sourceFile, program, host, preferences) {
150264
+ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
149961
150265
  if (!ts.some(fixes))
149962
150266
  return;
149963
150267
  // These will always be placed first if available, and are better than other kinds
149964
150268
  if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) {
149965
150269
  return fixes[0];
149966
150270
  }
149967
- var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
149968
150271
  return fixes.reduce(function (best, fix) {
149969
150272
  // Takes true branch of conditional if `fix` is better than `best`
149970
- return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
150273
+ return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
149971
150274
  });
149972
150275
  }
149973
150276
  /** @returns `Comparison.LessThan` if `a` is better than `b`. */
@@ -149975,10 +150278,15 @@ var ts;
149975
150278
  if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
149976
150279
  return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
149977
150280
  || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
150281
+ || ts.compareBooleans(isOnlyDotsAndSlashes(a.moduleSpecifier), isOnlyDotsAndSlashes(b.moduleSpecifier))
149978
150282
  || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
149979
150283
  }
149980
150284
  return 0 /* EqualTo */;
149981
150285
  }
150286
+ var notDotOrSlashPattern = /[^.\/]/;
150287
+ function isOnlyDotsAndSlashes(path) {
150288
+ return !notDotOrSlashPattern.test(path);
150289
+ }
149982
150290
  function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
149983
150291
  if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
149984
150292
  return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */;
@@ -150070,6 +150378,16 @@ var ts;
150070
150378
  }));
150071
150379
  return { fixes: fixes, symbolName: symbolName };
150072
150380
  }
150381
+ function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
150382
+ var checker = program.getTypeChecker();
150383
+ var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
150384
+ if (!symbol)
150385
+ return undefined;
150386
+ var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
150387
+ if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
150388
+ return undefined;
150389
+ return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
150390
+ }
150073
150391
  function jsxModeNeedsExplicitImport(jsx) {
150074
150392
  return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
150075
150393
  }
@@ -150077,12 +150395,18 @@ var ts;
150077
150395
  var parent = symbolToken.parent;
150078
150396
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150079
150397
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
150080
- if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
150398
+ if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
150081
150399
  return jsxNamespace;
150082
150400
  }
150083
150401
  }
150084
150402
  return symbolToken.text;
150085
150403
  }
150404
+ function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
150405
+ if (ts.isIntrinsicJsxName(symbolToken.text))
150406
+ return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
150407
+ var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
150408
+ return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
150409
+ }
150086
150410
  // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
150087
150411
  function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
150088
150412
  var _a;
@@ -150181,10 +150505,80 @@ var ts;
150181
150505
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
150182
150506
  return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150183
150507
  }
150508
+ case 4 /* PromoteTypeOnly */: {
150509
+ var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
150510
+ var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
150511
+ return promotedDeclaration.kind === 269 /* ImportSpecifier */
150512
+ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
150513
+ : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
150514
+ }
150184
150515
  default:
150185
150516
  return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
150186
150517
  }
150187
150518
  }
150519
+ function getModuleSpecifierText(promotedDeclaration) {
150520
+ var _a, _b;
150521
+ return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
150522
+ ? ((_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()
150523
+ : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
150524
+ }
150525
+ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
150526
+ // See comment in `doAddExistingFix` on constant with the same name.
150527
+ var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
150528
+ switch (aliasDeclaration.kind) {
150529
+ case 269 /* ImportSpecifier */:
150530
+ if (aliasDeclaration.isTypeOnly) {
150531
+ if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
150532
+ changes.delete(sourceFile, aliasDeclaration);
150533
+ var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
150534
+ var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
150535
+ changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
150536
+ }
150537
+ else {
150538
+ changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
150539
+ }
150540
+ return aliasDeclaration;
150541
+ }
150542
+ else {
150543
+ ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
150544
+ promoteImportClause(aliasDeclaration.parent.parent);
150545
+ return aliasDeclaration.parent.parent;
150546
+ }
150547
+ case 266 /* ImportClause */:
150548
+ promoteImportClause(aliasDeclaration);
150549
+ return aliasDeclaration;
150550
+ case 267 /* NamespaceImport */:
150551
+ promoteImportClause(aliasDeclaration.parent);
150552
+ return aliasDeclaration.parent;
150553
+ case 264 /* ImportEqualsDeclaration */:
150554
+ changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
150555
+ return aliasDeclaration;
150556
+ default:
150557
+ ts.Debug.failBadSyntaxKind(aliasDeclaration);
150558
+ }
150559
+ function promoteImportClause(importClause) {
150560
+ changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
150561
+ if (convertExistingToTypeOnly) {
150562
+ var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
150563
+ if (namedImports && namedImports.elements.length > 1) {
150564
+ if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
150565
+ aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
150566
+ namedImports.elements.indexOf(aliasDeclaration) !== 0) {
150567
+ // The import specifier being promoted will be the only non-type-only,
150568
+ // import in the NamedImports, so it should be moved to the front.
150569
+ changes.delete(sourceFile, aliasDeclaration);
150570
+ changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
150571
+ }
150572
+ for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
150573
+ var element = _a[_i];
150574
+ if (element !== aliasDeclaration && !element.isTypeOnly) {
150575
+ changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
150576
+ }
150577
+ }
150578
+ }
150579
+ }
150580
+ }
150581
+ }
150188
150582
  function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
150189
150583
  var _a;
150190
150584
  if (clause.kind === 200 /* ObjectBindingPattern */) {
@@ -150222,13 +150616,7 @@ var ts;
150222
150616
  var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
150223
150617
  ? 0
150224
150618
  : ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
150225
- var prevSpecifier = clause.namedBindings.elements[insertionIndex - 1];
150226
- if (prevSpecifier) {
150227
- changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
150228
- }
150229
- else {
150230
- changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
150231
- }
150619
+ changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
150232
150620
  }
150233
150621
  }
150234
150622
  else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
@@ -150586,7 +150974,7 @@ var ts;
150586
150974
  var errorCodes = [ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
150587
150975
  codefix.registerCodeFix({
150588
150976
  errorCodes: errorCodes,
150589
- getCodeActions: function (context) {
150977
+ getCodeActions: function getCodeActionsToFixImplicitThis(context) {
150590
150978
  var sourceFile = context.sourceFile, program = context.program, span = context.span;
150591
150979
  var diagnostic;
150592
150980
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) {
@@ -150601,7 +150989,8 @@ var ts;
150601
150989
  });
150602
150990
  function doChange(changes, sourceFile, pos, checker) {
150603
150991
  var token = ts.getTokenAtPosition(sourceFile, pos);
150604
- ts.Debug.assert(token.kind === 108 /* ThisKeyword */);
150992
+ if (!ts.isThis(token))
150993
+ return undefined;
150605
150994
  var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false);
150606
150995
  if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
150607
150996
  return undefined;
@@ -152411,6 +152800,9 @@ var ts;
152411
152800
  codefix.registerCodeFix({
152412
152801
  errorCodes: errorCodes,
152413
152802
  getCodeActions: function (context) {
152803
+ var syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
152804
+ if (syntacticDiagnostics.length)
152805
+ return;
152414
152806
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, context.span.start, context.span.length, context.errorCode); });
152415
152807
  return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Remove_unreachable_code, fixId, ts.Diagnostics.Remove_all_unreachable_code)];
152416
152808
  },
@@ -152814,7 +153206,7 @@ var ts;
152814
153206
  });
152815
153207
  var name = declaration && ts.getNameOfDeclaration(declaration);
152816
153208
  return !name || changes.length === 0 ? undefined
152817
- : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
153209
+ : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getTextOfNode(name)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
152818
153210
  },
152819
153211
  fixIds: [fixId],
152820
153212
  getAllCodeActions: function (context) {
@@ -152892,7 +153284,7 @@ var ts;
152892
153284
  case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: {
152893
153285
  var symbol = program.getTypeChecker().getSymbolAtLocation(token);
152894
153286
  if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) {
152895
- annotateVariableDeclaration(changes, importAdder, sourceFile, symbol.valueDeclaration, program, host, cancellationToken);
153287
+ annotateVariableDeclaration(changes, importAdder, ts.getSourceFileOfNode(symbol.valueDeclaration), symbol.valueDeclaration, program, host, cancellationToken);
152896
153288
  importAdder.writeFixes(changes);
152897
153289
  return symbol.valueDeclaration;
152898
153290
  }
@@ -154591,35 +154983,34 @@ var ts;
154591
154983
  codefix.registerCodeFix({
154592
154984
  errorCodes: errorCodes,
154593
154985
  getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
154594
- var propertyDeclaration = getPropertyDeclaration(context.sourceFile, context.span.start);
154595
- if (!propertyDeclaration)
154986
+ var info = getInfo(context.sourceFile, context.span.start);
154987
+ if (!info)
154596
154988
  return;
154597
- var result = [
154598
- getActionForAddMissingUndefinedType(context, propertyDeclaration),
154599
- getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration)
154600
- ];
154601
- ts.append(result, getActionForAddMissingInitializer(context, propertyDeclaration));
154989
+ var result = [];
154990
+ ts.append(result, getActionForAddMissingUndefinedType(context, info));
154991
+ ts.append(result, getActionForAddMissingDefiniteAssignmentAssertion(context, info));
154992
+ ts.append(result, getActionForAddMissingInitializer(context, info));
154602
154993
  return result;
154603
154994
  },
154604
154995
  fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
154605
154996
  getAllCodeActions: function (context) {
154606
154997
  return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
154607
- var propertyDeclaration = getPropertyDeclaration(diag.file, diag.start);
154608
- if (!propertyDeclaration)
154998
+ var info = getInfo(diag.file, diag.start);
154999
+ if (!info)
154609
155000
  return;
154610
155001
  switch (context.fixId) {
154611
155002
  case fixIdAddDefiniteAssignmentAssertions:
154612
- addDefiniteAssignmentAssertion(changes, diag.file, propertyDeclaration);
155003
+ addDefiniteAssignmentAssertion(changes, diag.file, info.prop);
154613
155004
  break;
154614
155005
  case fixIdAddUndefinedType:
154615
- addUndefinedType(changes, diag.file, propertyDeclaration);
155006
+ addUndefinedType(changes, diag.file, info);
154616
155007
  break;
154617
155008
  case fixIdAddInitializer:
154618
155009
  var checker = context.program.getTypeChecker();
154619
- var initializer = getInitializer(checker, propertyDeclaration);
155010
+ var initializer = getInitializer(checker, info.prop);
154620
155011
  if (!initializer)
154621
155012
  return;
154622
- addInitializer(changes, diag.file, propertyDeclaration, initializer);
155013
+ addInitializer(changes, diag.file, info.prop, initializer);
154623
155014
  break;
154624
155015
  default:
154625
155016
  ts.Debug.fail(JSON.stringify(context.fixId));
@@ -154627,35 +155018,50 @@ var ts;
154627
155018
  });
154628
155019
  },
154629
155020
  });
154630
- function getPropertyDeclaration(sourceFile, pos) {
155021
+ function getInfo(sourceFile, pos) {
154631
155022
  var token = ts.getTokenAtPosition(sourceFile, pos);
154632
- return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined;
155023
+ if (ts.isIdentifier(token) && ts.isPropertyDeclaration(token.parent)) {
155024
+ var type = ts.getEffectiveTypeAnnotationNode(token.parent);
155025
+ if (type) {
155026
+ return { type: type, prop: token.parent, isJs: ts.isInJSFile(token.parent) };
155027
+ }
155028
+ }
155029
+ return undefined;
154633
155030
  }
154634
- function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) {
154635
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, propertyDeclaration); });
154636
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
155031
+ function getActionForAddMissingDefiniteAssignmentAssertion(context, info) {
155032
+ if (info.isJs)
155033
+ return undefined;
155034
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, info.prop); });
155035
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154637
155036
  }
154638
155037
  function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154639
155038
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
154640
155039
  changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
154641
155040
  }
154642
- function getActionForAddMissingUndefinedType(context, propertyDeclaration) {
154643
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, propertyDeclaration); });
154644
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
155041
+ function getActionForAddMissingUndefinedType(context, info) {
155042
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, info); });
155043
+ 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);
154645
155044
  }
154646
- function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
155045
+ function addUndefinedType(changeTracker, sourceFile, info) {
154647
155046
  var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
154648
- var type = propertyDeclaration.type; // TODO: GH#18217
154649
- var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode];
154650
- changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types));
155047
+ var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
155048
+ var unionTypeNode = ts.factory.createUnionTypeNode(types);
155049
+ if (info.isJs) {
155050
+ changeTracker.addJSDocTags(sourceFile, info.prop, [ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(unionTypeNode))]);
155051
+ }
155052
+ else {
155053
+ changeTracker.replaceNode(sourceFile, info.type, unionTypeNode);
155054
+ }
154651
155055
  }
154652
- function getActionForAddMissingInitializer(context, propertyDeclaration) {
155056
+ function getActionForAddMissingInitializer(context, info) {
155057
+ if (info.isJs)
155058
+ return undefined;
154653
155059
  var checker = context.program.getTypeChecker();
154654
- var initializer = getInitializer(checker, propertyDeclaration);
155060
+ var initializer = getInitializer(checker, info.prop);
154655
155061
  if (!initializer)
154656
155062
  return undefined;
154657
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, propertyDeclaration, initializer); });
154658
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, propertyDeclaration.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
155063
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, info.prop, initializer); });
155064
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154659
155065
  }
154660
155066
  function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
154661
155067
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
@@ -161032,6 +161438,7 @@ var ts;
161032
161438
  ], false);
161033
161439
  function createLanguageService(host, documentRegistry, syntaxOnlyOrLanguageServiceMode) {
161034
161440
  var _a;
161441
+ var _b;
161035
161442
  if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); }
161036
161443
  var languageServiceMode;
161037
161444
  if (syntaxOnlyOrLanguageServiceMode === undefined) {
@@ -161052,10 +161459,8 @@ var ts;
161052
161459
  ? new CancellationTokenObject(host.getCancellationToken())
161053
161460
  : NoopCancellationToken;
161054
161461
  var currentDirectory = host.getCurrentDirectory();
161055
- // Check if the localized messages json is set, otherwise query the host for it
161056
- if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
161057
- ts.setLocalizedDiagnosticMessages(host.getLocalizedDiagnosticMessages());
161058
- }
161462
+ // Checks if the localized messages json is set, and if not, query the host for it
161463
+ ts.maybeSetLocalizedDiagnosticMessages((_b = host.getLocalizedDiagnosticMessages) === null || _b === void 0 ? void 0 : _b.bind(host));
161059
161464
  function log(message) {
161060
161465
  if (host.log) {
161061
161466
  host.log(message);
@@ -161157,6 +161562,7 @@ var ts;
161157
161562
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
161158
161563
  trace: parseConfigHost.trace,
161159
161564
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
161565
+ getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
161160
161566
  resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
161161
161567
  useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
161162
161568
  getParsedCommandLine: getParsedCommandLine,
@@ -165370,6 +165776,9 @@ var ts;
165370
165776
  Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference, _options, containingSourceFile) {
165371
165777
  return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile);
165372
165778
  };
165779
+ Project.prototype.getModuleResolutionCache = function () {
165780
+ return this.resolutionCache.getModuleResolutionCache();
165781
+ };
165373
165782
  Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
165374
165783
  return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
165375
165784
  };
@@ -166632,6 +167041,7 @@ var ts;
166632
167041
  if (!program) {
166633
167042
  return ts.emptyArray;
166634
167043
  }
167044
+ var start = ts.timestamp();
166635
167045
  var dependencyNames;
166636
167046
  var rootNames;
166637
167047
  var rootFileName = ts.combinePaths(hostProject.currentDirectory, ts.inferredTypesContainingFile);
@@ -166641,14 +167051,14 @@ var ts;
166641
167051
  (_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a.forEach(function (_, dependenyName) { return addDependency(dependenyName); });
166642
167052
  (_b = packageJson.peerDependencies) === null || _b === void 0 ? void 0 : _b.forEach(function (_, dependencyName) { return addDependency(dependencyName); });
166643
167053
  }
167054
+ var dependenciesAdded = 0;
166644
167055
  if (dependencyNames) {
166645
- var dependenciesAdded = 0;
166646
167056
  var symlinkCache = hostProject.getSymlinkCache();
166647
167057
  for (var _c = 0, _d = ts.arrayFrom(dependencyNames.keys()); _c < _d.length; _c++) {
166648
167058
  var name = _d[_c];
166649
167059
  // Avoid creating a large project that would significantly slow down time to editor interactivity
166650
167060
  if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this.maxDependencies) {
166651
- hostProject.log("Auto-import provider attempted to add more than " + this.maxDependencies + " dependencies.");
167061
+ hostProject.log("AutoImportProviderProject: attempted to add more than " + this.maxDependencies + " dependencies. Aborting.");
166652
167062
  return ts.emptyArray;
166653
167063
  }
166654
167064
  // 1. Try to load from the implementation package. For many dependencies, the
@@ -166682,6 +167092,9 @@ var ts;
166682
167092
  }
166683
167093
  }
166684
167094
  }
167095
+ if (rootNames === null || rootNames === void 0 ? void 0 : rootNames.length) {
167096
+ hostProject.log("AutoImportProviderProject: found " + rootNames.length + " root files in " + dependenciesAdded + " dependencies in " + (ts.timestamp() - start) + " ms");
167097
+ }
166685
167098
  return rootNames || ts.emptyArray;
166686
167099
  function addDependency(dependency) {
166687
167100
  if (!ts.startsWith(dependency, "@types/")) {
@@ -166782,6 +167195,11 @@ var ts;
166782
167195
  return this.hostProject.getSymlinkCache();
166783
167196
  };
166784
167197
  /*@internal*/
167198
+ AutoImportProviderProject.prototype.getModuleResolutionCache = function () {
167199
+ var _a;
167200
+ return (_a = this.hostProject.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getModuleResolutionCache();
167201
+ };
167202
+ /*@internal*/
166785
167203
  AutoImportProviderProject.maxDependencies = 10;
166786
167204
  /*@internal*/
166787
167205
  AutoImportProviderProject.compilerOptionsOverrides = {