typescript 4.6.0-dev.20220110 → 4.6.0-dev.20220114

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-dev.20220110";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220114";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -8482,7 +8482,7 @@ var ts;
8482
8482
  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
8483
  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
8484
  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."),
8485
+ 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
8486
  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
8487
  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
8488
  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 +8505,7 @@ var ts;
8505
8505
  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
8506
  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
8507
  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."),
8508
+ 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
8509
  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
8510
  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
8511
  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."),
@@ -15665,6 +15666,34 @@ var ts;
15665
15666
  }
15666
15667
  }
15667
15668
  ts.getThisContainer = getThisContainer;
15669
+ /**
15670
+ * @returns Whether the node creates a new 'this' scope for its children.
15671
+ */
15672
+ function isThisContainerOrFunctionBlock(node) {
15673
+ switch (node.kind) {
15674
+ // Arrow functions use the same scope, but may do so in a "delayed" manner
15675
+ // For example, `const getThis = () => this` may be before a super() call in a derived constructor
15676
+ case 213 /* ArrowFunction */:
15677
+ case 255 /* FunctionDeclaration */:
15678
+ case 212 /* FunctionExpression */:
15679
+ case 166 /* PropertyDeclaration */:
15680
+ return true;
15681
+ case 234 /* Block */:
15682
+ switch (node.parent.kind) {
15683
+ case 170 /* Constructor */:
15684
+ case 168 /* MethodDeclaration */:
15685
+ case 171 /* GetAccessor */:
15686
+ case 172 /* SetAccessor */:
15687
+ // Object properties can have computed names; only method-like bodies start a new scope
15688
+ return true;
15689
+ default:
15690
+ return false;
15691
+ }
15692
+ default:
15693
+ return false;
15694
+ }
15695
+ }
15696
+ ts.isThisContainerOrFunctionBlock = isThisContainerOrFunctionBlock;
15668
15697
  function isInTopLevelContext(node) {
15669
15698
  // The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
15670
15699
  if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
@@ -19985,16 +20014,6 @@ var ts;
19985
20014
  (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real);
19986
20015
  }
19987
20016
  },
19988
- setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) {
19989
- this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real);
19990
- var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1];
19991
- if (commonResolved && commonOriginal) {
19992
- this.setSymlinkedDirectory(commonOriginal, {
19993
- real: commonResolved,
19994
- realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName),
19995
- });
19996
- }
19997
- },
19998
20017
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
19999
20018
  var _this = this;
20000
20019
  var _a;
@@ -26261,7 +26280,7 @@ var ts;
26261
26280
  * @param visitor Optional callback used to visit any custom prologue directives.
26262
26281
  */
26263
26282
  function copyPrologue(source, target, ensureUseStrict, visitor) {
26264
- var offset = copyStandardPrologue(source, target, ensureUseStrict);
26283
+ var offset = copyStandardPrologue(source, target, 0, ensureUseStrict);
26265
26284
  return copyCustomPrologue(source, target, offset, visitor);
26266
26285
  }
26267
26286
  function isUseStrictPrologue(node) {
@@ -26274,12 +26293,14 @@ var ts;
26274
26293
  * Copies only the standard (string-expression) prologue-directives into the target statement-array.
26275
26294
  * @param source origin statements array
26276
26295
  * @param target result statements array
26296
+ * @param statementOffset The offset at which to begin the copy.
26277
26297
  * @param ensureUseStrict boolean determining whether the function need to add prologue-directives
26298
+ * @returns Count of how many directive statements were copied.
26278
26299
  */
26279
- function copyStandardPrologue(source, target, ensureUseStrict) {
26300
+ function copyStandardPrologue(source, target, statementOffset, ensureUseStrict) {
26301
+ if (statementOffset === void 0) { statementOffset = 0; }
26280
26302
  ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
26281
26303
  var foundUseStrict = false;
26282
- var statementOffset = 0;
26283
26304
  var numStatements = source.length;
26284
26305
  while (statementOffset < numStatements) {
26285
26306
  var statement = source[statementOffset];
@@ -27702,7 +27723,7 @@ var ts;
27702
27723
  importName: "__createBinding",
27703
27724
  scoped: false,
27704
27725
  priority: 1,
27705
- 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 }));"
27726
+ 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 }));"
27706
27727
  };
27707
27728
  ts.setModuleDefaultHelper = {
27708
27729
  name: "typescript:commonjscreatevalue",
@@ -41337,7 +41358,7 @@ var ts;
41337
41358
  ? 1 /* Recursive */ : 0 /* None */
41338
41359
  };
41339
41360
  }
41340
- if (ts.isImplicitGlob(spec)) {
41361
+ if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
41341
41362
  return {
41342
41363
  key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
41343
41364
  flags: 1 /* Recursive */
@@ -41703,9 +41724,7 @@ var ts;
41703
41724
  }
41704
41725
  }
41705
41726
  var failedLookupLocations = [];
41706
- var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41707
- ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41708
- NodeResolutionFeatures.None;
41727
+ var features = getDefaultNodeResolutionFeatures(options);
41709
41728
  var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
41710
41729
  var resolved = primaryLookup();
41711
41730
  var primary = true;
@@ -41790,6 +41809,34 @@ var ts;
41790
41809
  }
41791
41810
  }
41792
41811
  ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
41812
+ function getDefaultNodeResolutionFeatures(options) {
41813
+ return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41814
+ ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41815
+ NodeResolutionFeatures.None;
41816
+ }
41817
+ /**
41818
+ * @internal
41819
+ * Does not try `@types/${packageName}` - use a second pass if needed.
41820
+ */
41821
+ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
41822
+ var moduleResolutionState = {
41823
+ compilerOptions: options,
41824
+ host: host,
41825
+ traceEnabled: isTraceEnabled(options, host),
41826
+ failedLookupLocations: [],
41827
+ packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
41828
+ conditions: ts.emptyArray,
41829
+ features: NodeResolutionFeatures.None,
41830
+ };
41831
+ return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
41832
+ if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
41833
+ var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
41834
+ var candidate = ts.combinePaths(nodeModulesFolder, packageName);
41835
+ return getPackageJsonInfo(candidate, /*onlyRecordFailures*/ false, moduleResolutionState);
41836
+ }
41837
+ });
41838
+ }
41839
+ ts.resolvePackageNameToPackageJson = resolvePackageNameToPackageJson;
41793
41840
  /**
41794
41841
  * Given a set of options, returns the set of type directive names
41795
41842
  * that should be included for this program automatically.
@@ -42363,11 +42410,6 @@ var ts;
42363
42410
  }
42364
42411
  ts.resolveJSModule = resolveJSModule;
42365
42412
  /* @internal */
42366
- function tryResolveJSModule(moduleName, initialDir, host) {
42367
- return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
42368
- }
42369
- ts.tryResolveJSModule = tryResolveJSModule;
42370
- /* @internal */
42371
42413
  var NodeResolutionFeatures;
42372
42414
  (function (NodeResolutionFeatures) {
42373
42415
  NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
@@ -42675,6 +42717,97 @@ var ts;
42675
42717
  var versionPaths = packageInfo && packageInfo.versionPaths;
42676
42718
  return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
42677
42719
  }
42720
+ /* @internal */
42721
+ function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache, resolveJs) {
42722
+ if (!resolveJs && packageJsonInfo.resolvedEntrypoints !== undefined) {
42723
+ // Cached value excludes resolutions to JS files - those could be
42724
+ // cached separately, but they're used rarely.
42725
+ return packageJsonInfo.resolvedEntrypoints;
42726
+ }
42727
+ var entrypoints;
42728
+ var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
42729
+ var features = getDefaultNodeResolutionFeatures(options);
42730
+ var requireState = {
42731
+ compilerOptions: options,
42732
+ host: host,
42733
+ traceEnabled: isTraceEnabled(options, host),
42734
+ failedLookupLocations: [],
42735
+ packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42736
+ conditions: ["node", "require", "types"],
42737
+ features: features,
42738
+ };
42739
+ var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
42740
+ /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
42741
+ entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
42742
+ if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) {
42743
+ for (var _i = 0, _a = [["node", "import", "types"], ["node", "require", "types"]]; _i < _a.length; _i++) {
42744
+ var conditions = _a[_i];
42745
+ var exportState = __assign(__assign({}, requireState), { failedLookupLocations: [], conditions: conditions });
42746
+ var exportResolutions = loadEntrypointsFromExportMap(packageJsonInfo, packageJsonInfo.packageJsonContent.exports, exportState, extensions);
42747
+ if (exportResolutions) {
42748
+ for (var _b = 0, exportResolutions_1 = exportResolutions; _b < exportResolutions_1.length; _b++) {
42749
+ var resolution = exportResolutions_1[_b];
42750
+ entrypoints = ts.appendIfUnique(entrypoints, resolution.path);
42751
+ }
42752
+ }
42753
+ }
42754
+ }
42755
+ return packageJsonInfo.resolvedEntrypoints = entrypoints || false;
42756
+ }
42757
+ ts.getEntrypointsFromPackageJsonInfo = getEntrypointsFromPackageJsonInfo;
42758
+ function loadEntrypointsFromExportMap(scope, exports, state, extensions) {
42759
+ var entrypoints;
42760
+ if (ts.isArray(exports)) {
42761
+ for (var _i = 0, exports_1 = exports; _i < exports_1.length; _i++) {
42762
+ var target = exports_1[_i];
42763
+ loadEntrypointsFromTargetExports(target);
42764
+ }
42765
+ }
42766
+ // eslint-disable-next-line no-null/no-null
42767
+ else if (typeof exports === "object" && exports !== null && allKeysStartWithDot(exports)) {
42768
+ for (var key in exports) {
42769
+ loadEntrypointsFromTargetExports(exports[key]);
42770
+ }
42771
+ }
42772
+ else {
42773
+ loadEntrypointsFromTargetExports(exports);
42774
+ }
42775
+ return entrypoints;
42776
+ function loadEntrypointsFromTargetExports(target) {
42777
+ var _a, _b;
42778
+ if (typeof target === "string" && ts.startsWith(target, "./") && target.indexOf("*") === -1) {
42779
+ var partsAfterFirst = ts.getPathComponents(target).slice(2);
42780
+ if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
42781
+ return false;
42782
+ }
42783
+ var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
42784
+ var finalPath = ts.getNormalizedAbsolutePath(resolvedTarget, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
42785
+ var result = loadJSOrExactTSFileName(extensions, finalPath, /*recordOnlyFailures*/ false, state);
42786
+ if (result) {
42787
+ entrypoints = ts.appendIfUnique(entrypoints, result, function (a, b) { return a.path === b.path; });
42788
+ return true;
42789
+ }
42790
+ }
42791
+ else if (Array.isArray(target)) {
42792
+ for (var _i = 0, target_1 = target; _i < target_1.length; _i++) {
42793
+ var t = target_1[_i];
42794
+ var success = loadEntrypointsFromTargetExports(t);
42795
+ if (success) {
42796
+ return true;
42797
+ }
42798
+ }
42799
+ }
42800
+ // eslint-disable-next-line no-null/no-null
42801
+ else if (typeof target === "object" && target !== null) {
42802
+ return ts.forEach(ts.getOwnKeys(target), function (key) {
42803
+ if (key === "default" || ts.contains(state.conditions, key) || isApplicableVersionedTypesKey(state.conditions, key)) {
42804
+ loadEntrypointsFromTargetExports(target[key]);
42805
+ return true;
42806
+ }
42807
+ });
42808
+ }
42809
+ }
42810
+ }
42678
42811
  /**
42679
42812
  * A function for locating the package.json scope for a given path
42680
42813
  */
@@ -42731,7 +42864,7 @@ var ts;
42731
42864
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
42732
42865
  }
42733
42866
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
42734
- var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
42867
+ var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
42735
42868
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
42736
42869
  return result;
42737
42870
  }
@@ -43028,8 +43161,8 @@ var ts;
43028
43161
  }
43029
43162
  return toSearchResult(/*value*/ undefined);
43030
43163
  }
43031
- for (var _d = 0, target_1 = target; _d < target_1.length; _d++) {
43032
- var elem = target_1[_d];
43164
+ for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
43165
+ var elem = target_2[_d];
43033
43166
  var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
43034
43167
  if (result) {
43035
43168
  return result;
@@ -50058,7 +50191,7 @@ var ts;
50058
50191
  if (!sigs || !sigs.length) {
50059
50192
  sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
50060
50193
  }
50061
- if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
50194
+ if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) {
50062
50195
  var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
50063
50196
  return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
50064
50197
  }
@@ -52262,8 +52395,8 @@ var ts;
52262
52395
  }
52263
52396
  else {
52264
52397
  if (parent && getExportsOfSymbol(parent)) {
52265
- var exports_1 = getExportsOfSymbol(parent);
52266
- ts.forEachEntry(exports_1, function (ex, name) {
52398
+ var exports_2 = getExportsOfSymbol(parent);
52399
+ ts.forEachEntry(exports_2, function (ex, name) {
52267
52400
  if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) {
52268
52401
  symbolName = ts.unescapeLeadingUnderscores(name);
52269
52402
  return true;
@@ -57374,6 +57507,11 @@ var ts;
57374
57507
  return simplified !== type ? simplified : getConstraintOfType(type);
57375
57508
  }
57376
57509
  function getConstraintFromIndexedAccess(type) {
57510
+ if (isMappedTypeGenericIndexedAccess(type)) {
57511
+ // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
57512
+ // we substitute an instantiation of E where P is replaced with X.
57513
+ return substituteIndexedMappedType(type.objectType, type.indexType);
57514
+ }
57377
57515
  var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
57378
57516
  if (indexConstraint && indexConstraint !== type.indexType) {
57379
57517
  var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags);
@@ -57578,6 +57716,11 @@ var ts;
57578
57716
  return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
57579
57717
  }
57580
57718
  if (t.flags & 8388608 /* IndexedAccess */) {
57719
+ if (isMappedTypeGenericIndexedAccess(t)) {
57720
+ // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
57721
+ // we substitute an instantiation of E where P is replaced with X.
57722
+ return getBaseConstraint(substituteIndexedMappedType(t.objectType, t.indexType));
57723
+ }
57581
57724
  var baseObjectType = getBaseConstraint(t.objectType);
57582
57725
  var baseIndexType = getBaseConstraint(t.indexType);
57583
57726
  var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags);
@@ -57662,13 +57805,7 @@ var ts;
57662
57805
  * type itself.
57663
57806
  */
57664
57807
  function getApparentType(type) {
57665
- // We obtain the base constraint for all instantiable types, except indexed access types of the form
57666
- // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57667
- // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57668
- // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57669
- var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57670
- isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57671
- getBaseConstraintOfType(type) || unknownType;
57808
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
57672
57809
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57673
57810
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57674
57811
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -64332,6 +64469,17 @@ var ts;
64332
64469
  resetErrorInfo(saveErrorInfo);
64333
64470
  return result;
64334
64471
  }
64472
+ if (isMappedTypeGenericIndexedAccess(source)) {
64473
+ // For an indexed access type { [P in K]: E}[X], above we have already explored an instantiation of E with X
64474
+ // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X.
64475
+ var indexConstraint = getConstraintOfType(source.indexType);
64476
+ if (indexConstraint) {
64477
+ if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
64478
+ resetErrorInfo(saveErrorInfo);
64479
+ return result;
64480
+ }
64481
+ }
64482
+ }
64335
64483
  }
64336
64484
  }
64337
64485
  else if (source.flags & 4194304 /* Index */) {
@@ -78595,32 +78743,38 @@ var ts;
78595
78743
  if (classExtendsNull) {
78596
78744
  error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
78597
78745
  }
78598
- // The first statement in the body of a constructor (excluding prologue directives) must be a super call
78599
- // if both of the following are true:
78746
+ // A super call must be root-level in a constructor if both of the following are true:
78600
78747
  // - The containing class is a derived class.
78601
78748
  // - The constructor declares parameter properties
78602
78749
  // or the containing class declares instance member variables with initializers.
78603
- var superCallShouldBeFirst = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
78750
+ var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
78604
78751
  (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
78605
78752
  ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
78606
- // Skip past any prologue directives to find the first statement
78607
- // to ensure that it was a super call.
78608
- if (superCallShouldBeFirst) {
78609
- var statements = node.body.statements;
78610
- var superCallStatement = void 0;
78611
- for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
78612
- var statement = statements_4[_i];
78613
- if (statement.kind === 237 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) {
78614
- superCallStatement = statement;
78615
- break;
78753
+ if (superCallShouldBeRootLevel) {
78754
+ // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
78755
+ // See GH #8277
78756
+ if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
78757
+ 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);
78758
+ }
78759
+ // Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
78760
+ else {
78761
+ var superCallStatement = void 0;
78762
+ for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
78763
+ var statement = _a[_i];
78764
+ if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
78765
+ superCallStatement = statement;
78766
+ break;
78767
+ }
78768
+ if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
78769
+ break;
78770
+ }
78616
78771
  }
78617
- if (!ts.isPrologueDirective(statement)) {
78618
- break;
78772
+ // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
78773
+ // See GH #8277
78774
+ if (superCallStatement === undefined) {
78775
+ 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);
78619
78776
  }
78620
78777
  }
78621
- if (!superCallStatement) {
78622
- 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);
78623
- }
78624
78778
  }
78625
78779
  }
78626
78780
  else if (!classExtendsNull) {
@@ -78628,6 +78782,19 @@ var ts;
78628
78782
  }
78629
78783
  }
78630
78784
  }
78785
+ function superCallIsRootLevelInConstructor(superCall, body) {
78786
+ var superCallParent = ts.walkUpParenthesizedExpressions(superCall.parent);
78787
+ return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body;
78788
+ }
78789
+ function nodeImmediatelyReferencesSuperOrThis(node) {
78790
+ if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) {
78791
+ return true;
78792
+ }
78793
+ if (ts.isThisContainerOrFunctionBlock(node)) {
78794
+ return false;
78795
+ }
78796
+ return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
78797
+ }
78631
78798
  function checkAccessorDeclaration(node) {
78632
78799
  if (produceDiagnostics) {
78633
78800
  // Grammar checking accessors
@@ -83450,9 +83617,9 @@ var ts;
83450
83617
  }
83451
83618
  }
83452
83619
  // Checks for export * conflicts
83453
- var exports_2 = getExportsOfModule(moduleSymbol);
83454
- if (exports_2) {
83455
- exports_2.forEach(function (_a, id) {
83620
+ var exports_3 = getExportsOfModule(moduleSymbol);
83621
+ if (exports_3) {
83622
+ exports_3.forEach(function (_a, id) {
83456
83623
  var declarations = _a.declarations, flags = _a.flags;
83457
83624
  if (id === "__export") {
83458
83625
  return;
@@ -88750,34 +88917,31 @@ var ts;
88750
88917
  }
88751
88918
  ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
88752
88919
  /**
88753
- * Adds super call and preceding prologue directives into the list of statements.
88754
- *
88755
- * @param ctor The constructor node.
88756
- * @param result The list of statements.
88757
- * @param visitor The visitor to apply to each node added to the result array.
88758
- * @returns index of the statement that follows super call
88920
+ * @returns Contained super() call from descending into the statement ignoring parentheses, if that call exists.
88921
+ */
88922
+ function getSuperCallFromStatement(statement) {
88923
+ if (!ts.isExpressionStatement(statement)) {
88924
+ return undefined;
88925
+ }
88926
+ var expression = ts.skipParentheses(statement.expression);
88927
+ return ts.isSuperCall(expression)
88928
+ ? expression
88929
+ : undefined;
88930
+ }
88931
+ ts.getSuperCallFromStatement = getSuperCallFromStatement;
88932
+ /**
88933
+ * @returns The index (after prologue statements) of a super call, or -1 if not found.
88759
88934
  */
88760
- function addPrologueDirectivesAndInitialSuperCall(factory, ctor, result, visitor) {
88761
- if (ctor.body) {
88762
- var statements = ctor.body.statements;
88763
- // add prologue directives to the list (if any)
88764
- var index = factory.copyPrologue(statements, result, /*ensureUseStrict*/ false, visitor);
88765
- if (index === statements.length) {
88766
- // list contains nothing but prologue directives (or empty) - exit
88767
- return index;
88768
- }
88769
- var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
88770
- if (superIndex > -1) {
88771
- for (var i = index; i <= superIndex; i++) {
88772
- result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
88773
- }
88774
- return superIndex + 1;
88935
+ function findSuperStatementIndex(statements, indexAfterLastPrologueStatement) {
88936
+ for (var i = indexAfterLastPrologueStatement; i < statements.length; i += 1) {
88937
+ var statement = statements[i];
88938
+ if (getSuperCallFromStatement(statement)) {
88939
+ return i;
88775
88940
  }
88776
- return index;
88777
88941
  }
88778
- return 0;
88942
+ return -1;
88779
88943
  }
88780
- ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
88944
+ ts.findSuperStatementIndex = findSuperStatementIndex;
88781
88945
  function getProperties(node, requireInitializer, isStatic) {
88782
88946
  return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
88783
88947
  }
@@ -90676,6 +90840,7 @@ var ts;
90676
90840
  case 176 /* TypePredicate */:
90677
90841
  case 133 /* BooleanKeyword */:
90678
90842
  return factory.createIdentifier("Boolean");
90843
+ case 197 /* TemplateLiteralType */:
90679
90844
  case 149 /* StringKeyword */:
90680
90845
  return factory.createIdentifier("String");
90681
90846
  case 147 /* ObjectKeyword */:
@@ -91014,10 +91179,14 @@ var ts;
91014
91179
  return ts.visitFunctionBody(body, visitor, context);
91015
91180
  }
91016
91181
  var statements = [];
91017
- var indexOfFirstStatement = 0;
91018
91182
  resumeLexicalEnvironment();
91019
- indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
91020
- // Add parameters with property assignments. Transforms this:
91183
+ var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
91184
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
91185
+ // If there was a super call, visit existing statements up to and including it
91186
+ if (superStatementIndex >= 0) {
91187
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
91188
+ }
91189
+ // Transform parameters into property assignments. Transforms this:
91021
91190
  //
91022
91191
  // constructor (public x, public y) {
91023
91192
  // }
@@ -91029,9 +91198,17 @@ var ts;
91029
91198
  // this.y = y;
91030
91199
  // }
91031
91200
  //
91032
- ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
91033
- // Add the existing statements, skipping the initial super call.
91034
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
91201
+ var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment);
91202
+ // If there is a super() call, the parameter properties go immediately after it
91203
+ if (superStatementIndex >= 0) {
91204
+ ts.addRange(statements, parameterPropertyAssignments);
91205
+ }
91206
+ // Since there was no super() call, parameter properties are the first statements in the constructor
91207
+ else {
91208
+ statements = ts.addRange(parameterPropertyAssignments, statements);
91209
+ }
91210
+ // Add remaining statements from the body, skipping the super() call if it was found
91211
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
91035
91212
  // End the lexical environment.
91036
91213
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
91037
91214
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -92929,6 +93106,7 @@ var ts;
92929
93106
  /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
92930
93107
  }
92931
93108
  function transformConstructorBody(node, constructor, isDerivedClass) {
93109
+ var _a;
92932
93110
  var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false);
92933
93111
  if (!useDefineForClassFields) {
92934
93112
  properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
@@ -92940,9 +93118,21 @@ var ts;
92940
93118
  return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
92941
93119
  }
92942
93120
  resumeLexicalEnvironment();
92943
- var indexOfFirstStatement = 0;
93121
+ var needsSyntheticConstructor = !constructor && isDerivedClass;
93122
+ var indexOfFirstStatementAfterSuper = 0;
93123
+ var prologueStatementCount = 0;
93124
+ var superStatementIndex = -1;
92944
93125
  var statements = [];
92945
- if (!constructor && isDerivedClass) {
93126
+ if ((_a = constructor === null || constructor === void 0 ? void 0 : constructor.body) === null || _a === void 0 ? void 0 : _a.statements) {
93127
+ prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, /*ensureUseStrict*/ false, visitor);
93128
+ superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
93129
+ // If there was a super call, visit existing statements up to and including it
93130
+ if (superStatementIndex >= 0) {
93131
+ indexOfFirstStatementAfterSuper = superStatementIndex + 1;
93132
+ 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);
93133
+ }
93134
+ }
93135
+ if (needsSyntheticConstructor) {
92946
93136
  // Add a synthetic `super` call:
92947
93137
  //
92948
93138
  // super(...arguments);
@@ -92950,9 +93140,6 @@ var ts;
92950
93140
  statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(),
92951
93141
  /*typeArguments*/ undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
92952
93142
  }
92953
- if (constructor) {
92954
- indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
92955
- }
92956
93143
  // Add the property initializers. Transforms this:
92957
93144
  //
92958
93145
  // public x = 1;
@@ -92963,31 +93150,59 @@ var ts;
92963
93150
  // this.x = 1;
92964
93151
  // }
92965
93152
  //
93153
+ // If we do useDefineForClassFields, they'll be converted elsewhere.
93154
+ // We instead *remove* them from the transformed output at this stage.
93155
+ var parameterPropertyDeclarationCount = 0;
92966
93156
  if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
92967
- var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
92968
- if (afterParameterProperties === -1) {
92969
- afterParameterProperties = constructor.body.statements.length;
93157
+ if (useDefineForClassFields) {
93158
+ statements = statements.filter(function (statement) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor); });
92970
93159
  }
92971
- if (afterParameterProperties > indexOfFirstStatement) {
92972
- if (!useDefineForClassFields) {
92973
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
93160
+ else {
93161
+ for (var _i = 0, _b = constructor.body.statements; _i < _b.length; _i++) {
93162
+ var statement = _b[_i];
93163
+ if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
93164
+ parameterPropertyDeclarationCount++;
93165
+ }
93166
+ }
93167
+ if (parameterPropertyDeclarationCount > 0) {
93168
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
93169
+ // If there was a super() call found, add parameter properties immediately after it
93170
+ if (superStatementIndex >= 0) {
93171
+ ts.addRange(statements, parameterProperties);
93172
+ }
93173
+ // If a synthetic super() call was added, add them just after it
93174
+ else if (needsSyntheticConstructor) {
93175
+ statements = __spreadArray(__spreadArray([
93176
+ statements[0]
93177
+ ], parameterProperties, true), statements.slice(1), true);
93178
+ }
93179
+ // Since there wasn't a super() call, add them to the top of the constructor
93180
+ else {
93181
+ statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
93182
+ }
93183
+ indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
92974
93184
  }
92975
- indexOfFirstStatement = afterParameterProperties;
92976
93185
  }
92977
93186
  }
92978
93187
  var receiver = factory.createThis();
92979
93188
  // private methods can be called in property initializers, they should execute first.
92980
93189
  addMethodStatements(statements, privateMethodsAndAccessors, receiver);
92981
93190
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
92982
- // Add existing statements, skipping the initial super call.
93191
+ // Add existing statements after the initial prologues and super call
92983
93192
  if (constructor) {
92984
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
93193
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
92985
93194
  }
92986
93195
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
92987
93196
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
92988
93197
  /*location*/ constructor ? constructor.body.statements : node.members),
92989
93198
  /*multiLine*/ true),
92990
93199
  /*location*/ constructor ? constructor.body : undefined);
93200
+ function visitBodyStatement(statement) {
93201
+ if (useDefineForClassFields && ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
93202
+ return undefined;
93203
+ }
93204
+ return visitor(statement);
93205
+ }
92991
93206
  }
92992
93207
  /**
92993
93208
  * Generates assignment statements for property initializers.
@@ -93008,6 +93223,11 @@ var ts;
93008
93223
  ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93009
93224
  ts.setCommentRange(statement, property);
93010
93225
  ts.setOriginalNode(statement, property);
93226
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93227
+ // `statement` and `expression` have a copy of the synthesized comments.
93228
+ // Drop the comments from expression to avoid printing them twice.
93229
+ ts.setSyntheticLeadingComments(expression, undefined);
93230
+ ts.setSyntheticTrailingComments(expression, undefined);
93011
93231
  statements.push(statement);
93012
93232
  }
93013
93233
  }
@@ -96774,37 +96994,39 @@ var ts;
96774
96994
  var prologue = [];
96775
96995
  var statements = [];
96776
96996
  resumeLexicalEnvironment();
96997
+ // In derived classes, there may be code before the necessary super() call
96998
+ // We'll remove pre-super statements to be tacked on after the rest of the body
96999
+ var existingPrologue = ts.takeWhile(constructor.body.statements, ts.isPrologueDirective);
97000
+ var _a = findSuperCallAndStatementIndex(constructor.body.statements, existingPrologue), superCall = _a.superCall, superStatementIndex = _a.superStatementIndex;
97001
+ var postSuperStatementsStart = superStatementIndex === -1 ? existingPrologue.length : superStatementIndex + 1;
96777
97002
  // If a super call has already been synthesized,
96778
97003
  // we're going to assume that we should just transform everything after that.
96779
97004
  // The assumption is that no prior step in the pipeline has added any prologue directives.
96780
- var statementOffset = 0;
97005
+ var statementOffset = postSuperStatementsStart;
96781
97006
  if (!hasSynthesizedSuper)
96782
- statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, /*ensureUseStrict*/ false);
96783
- addDefaultValueAssignmentsIfNeeded(statements, constructor);
96784
- addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
97007
+ statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, statementOffset, /*ensureUseStrict*/ false);
96785
97008
  if (!hasSynthesizedSuper)
96786
- statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
96787
- // If the first statement is a call to `super()`, visit the statement directly
97009
+ statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor, /*filter*/ undefined);
97010
+ // If there already exists a call to `super()`, visit the statement directly
96788
97011
  var superCallExpression;
96789
97012
  if (hasSynthesizedSuper) {
96790
97013
  superCallExpression = createDefaultSuperCallOrThis();
96791
97014
  }
96792
- else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
96793
- var firstStatement = constructor.body.statements[statementOffset];
96794
- if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
96795
- superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
96796
- }
97015
+ else if (superCall) {
97016
+ superCallExpression = visitSuperCallInBody(superCall);
96797
97017
  }
96798
97018
  if (superCallExpression) {
96799
97019
  hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
96800
- statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
96801
97020
  }
97021
+ // Add parameter defaults at the beginning of the output, with prologue statements
97022
+ addDefaultValueAssignmentsIfNeeded(prologue, constructor);
97023
+ addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
96802
97024
  // visit the remaining statements
96803
97025
  ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset));
96804
97026
  factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
96805
97027
  insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
96806
- if (isDerivedClass) {
96807
- if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
97028
+ if (isDerivedClass || superCallExpression) {
97029
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
96808
97030
  // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
96809
97031
  // following representation:
96810
97032
  //
@@ -96824,10 +97046,10 @@ var ts;
96824
97046
  // return C;
96825
97047
  // })(Base);
96826
97048
  // ```
96827
- var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
97049
+ var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
96828
97050
  var returnStatement = factory.createReturnStatement(superCallExpression);
96829
- ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
96830
- ts.setEmitFlags(superCall, 1536 /* NoComments */);
97051
+ ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1));
97052
+ ts.setEmitFlags(superCall_1, 1536 /* NoComments */);
96831
97053
  statements.push(returnStatement);
96832
97054
  }
96833
97055
  else {
@@ -96852,9 +97074,19 @@ var ts;
96852
97074
  // return C;
96853
97075
  // })(Base);
96854
97076
  // ```
96855
- // Since the `super()` call was the first statement, we insert the `this` capturing call to
96856
- // `super()` at the top of the list of `statements` (after any pre-existing custom prologues).
96857
- insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
97077
+ // If the super() call is the first statement, we can directly create and assign its result to `_this`
97078
+ if (superStatementIndex <= existingPrologue.length) {
97079
+ insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
97080
+ }
97081
+ // Since the `super()` call isn't the first statement, it's split across 1-2 statements:
97082
+ // * A prologue `var _this = this;`, in case the constructor accesses this before super()
97083
+ // * If it exists, a reassignment to that `_this` of the super() call
97084
+ else {
97085
+ insertCaptureThisForNode(prologue, constructor, createActualThis());
97086
+ if (superCallExpression) {
97087
+ insertSuperThisCaptureThisForNode(statements, superCallExpression);
97088
+ }
97089
+ }
96858
97090
  if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
96859
97091
  statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
96860
97092
  }
@@ -96877,11 +97109,27 @@ var ts;
96877
97109
  // ```
96878
97110
  insertCaptureThisForNodeIfNeeded(prologue, constructor);
96879
97111
  }
96880
- var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)),
97112
+ 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)),
96881
97113
  /*location*/ constructor.body.statements),
96882
97114
  /*multiLine*/ true);
96883
- ts.setTextRange(block, constructor.body);
96884
- return block;
97115
+ ts.setTextRange(body, constructor.body);
97116
+ return body;
97117
+ }
97118
+ function findSuperCallAndStatementIndex(originalBodyStatements, existingPrologue) {
97119
+ for (var i = existingPrologue.length; i < originalBodyStatements.length; i += 1) {
97120
+ var superCall = ts.getSuperCallFromStatement(originalBodyStatements[i]);
97121
+ if (superCall) {
97122
+ // With a super() call, split the statements into pre-super() and 'body' (post-super())
97123
+ return {
97124
+ superCall: superCall,
97125
+ superStatementIndex: i,
97126
+ };
97127
+ }
97128
+ }
97129
+ // Since there was no super() call found, consider all statements to be in the main 'body' (post-super())
97130
+ return {
97131
+ superStatementIndex: -1,
97132
+ };
96885
97133
  }
96886
97134
  /**
96887
97135
  * We want to try to avoid emitting a return statement in certain cases if a user already returned something.
@@ -97110,6 +97358,18 @@ var ts;
97110
97358
  }
97111
97359
  return false;
97112
97360
  }
97361
+ /**
97362
+ * Assigns the `this` in a constructor to the result of its `super()` call.
97363
+ *
97364
+ * @param statements Statements in the constructor body.
97365
+ * @param superExpression Existing `super()` call for the constructor.
97366
+ */
97367
+ function insertSuperThisCaptureThisForNode(statements, superExpression) {
97368
+ enableSubstitutionsForCapturedThis();
97369
+ var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression));
97370
+ ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression);
97371
+ ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent);
97372
+ }
97113
97373
  function insertCaptureThisForNode(statements, node, initializer) {
97114
97374
  enableSubstitutionsForCapturedThis();
97115
97375
  var captureThisStatement = factory.createVariableStatement(
@@ -97419,7 +97679,7 @@ var ts;
97419
97679
  if (ts.isBlock(body)) {
97420
97680
  // ensureUseStrict is false because no new prologue-directive should be added.
97421
97681
  // addStandardPrologue will put already-existing directives at the beginning of the target statement-array
97422
- statementOffset = factory.copyStandardPrologue(body.statements, prologue, /*ensureUseStrict*/ false);
97682
+ statementOffset = factory.copyStandardPrologue(body.statements, prologue, 0, /*ensureUseStrict*/ false);
97423
97683
  statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
97424
97684
  statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
97425
97685
  }
@@ -98790,7 +99050,7 @@ var ts;
98790
99050
  /*type*/ undefined, factory.updateBlock(func.body, statements))),
98791
99051
  /*typeArguments*/ undefined, call.arguments))));
98792
99052
  }
98793
- function visitImmediateSuperCallInBody(node) {
99053
+ function visitSuperCallInBody(node) {
98794
99054
  return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false);
98795
99055
  }
98796
99056
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
@@ -119348,28 +119608,37 @@ var ts;
119348
119608
  useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
119349
119609
  };
119350
119610
  }
119351
- function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
119352
- var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
119611
+ // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
119612
+ // Because when this is called by the file renamer, `importingSourceFile` is the file being renamed,
119613
+ // while `importingSourceFileName` its *new* name. We need a source file just to get its
119614
+ // `impliedNodeFormat` and to detect certain preferences from existing import module specifiers.
119615
+ function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, oldImportSpecifier) {
119616
+ var res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
119353
119617
  if (res === oldImportSpecifier)
119354
119618
  return undefined;
119355
119619
  return res;
119356
119620
  }
119357
119621
  moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
119358
- // Note: importingSourceFile is just for usesJsExtensionOnImports
119622
+ // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
119623
+ // Because when this is called by the declaration emitter, `importingSourceFile` is the implementation
119624
+ // file, but `importingSourceFileName` and `toFileName` refer to declaration files (the former to the
119625
+ // one currently being produced; the latter to the one being imported). We need an implementation file
119626
+ // just to get its `impliedNodeFormat` and to detect certain preferences from existing import module
119627
+ // specifiers.
119359
119628
  function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
119360
- return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
119629
+ return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
119361
119630
  }
119362
119631
  moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
119363
- function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) {
119364
- var info = getInfo(importingSourceFileName, host);
119365
- var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host, preferences);
119366
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, /*packageNameOnly*/ true); });
119632
+ function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences) {
119633
+ var info = getInfo(importingSourceFile.path, host);
119634
+ var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences);
119635
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true); });
119367
119636
  }
119368
119637
  moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
119369
- function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences, userPreferences) {
119638
+ function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences) {
119370
119639
  var info = getInfo(importingSourceFileName, host);
119371
119640
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences);
119372
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
119641
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions); }) ||
119373
119642
  getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
119374
119643
  }
119375
119644
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences) {
@@ -119436,7 +119705,7 @@ var ts;
119436
119705
  var relativeSpecifiers;
119437
119706
  for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
119438
119707
  var modulePath = modulePaths_1[_i];
119439
- var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
119708
+ var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions);
119440
119709
  nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
119441
119710
  if (specifier && modulePath.isRedirect) {
119442
119711
  // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
@@ -119828,7 +120097,7 @@ var ts;
119828
120097
  ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
119829
120098
  : ts.removeFileExtension(relativePath);
119830
120099
  }
119831
- function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
120100
+ function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly) {
119832
120101
  var path = _a.path, isRedirect = _a.isRedirect;
119833
120102
  var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
119834
120103
  if (!host.fileExists || !host.readFile) {
@@ -119891,11 +120160,19 @@ var ts;
119891
120160
  var moduleFileToTry = path;
119892
120161
  if (host.fileExists(packageJsonPath)) {
119893
120162
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119894
- // TODO: Inject `require` or `import` condition based on the intended import mode
119895
120163
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119896
- var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
120164
+ // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
120165
+ // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
120166
+ // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
120167
+ // with, so for now we just stick with the mode of the file.
120168
+ var conditions = ["node", importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
120169
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
120170
+ ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
120171
+ : undefined;
119897
120172
  if (fromExports) {
119898
- var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
120173
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry)
120174
+ ? fromExports
120175
+ : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119899
120176
  return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119900
120177
  }
119901
120178
  if (packageJsonContent.exports) {
@@ -120001,8 +120278,8 @@ var ts;
120001
120278
  }
120002
120279
  function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
120003
120280
  return ts.firstDefined(rootDirs, function (rootDir) {
120004
- var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); // TODO: GH#18217
120005
- return isPathRelativeToParent(relativePath) ? undefined : relativePath;
120281
+ var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
120282
+ return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
120006
120283
  });
120007
120284
  }
120008
120285
  function removeExtensionAndIndexPostFix(fileName, ending, options) {
@@ -126631,7 +126908,7 @@ var ts;
126631
126908
  if (!ts.stringContains(importedFileName, "node_modules")) {
126632
126909
  return undefined;
126633
126910
  }
126634
- var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, preferences);
126911
+ var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile, importedFileName, moduleSpecifierResolutionHost, preferences);
126635
126912
  if (!specifier) {
126636
126913
  return undefined;
126637
126914
  }
@@ -136277,7 +136554,7 @@ var ts;
136277
136554
  : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
136278
136555
  // Need an update if the imported file moved, or the importing file moved and was using a relative path.
136279
136556
  return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text)))
136280
- ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
136557
+ ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
136281
136558
  : undefined;
136282
136559
  });
136283
136560
  };
@@ -137922,6 +138199,9 @@ var ts;
137922
138199
  // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
137923
138200
  // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
137924
138201
  function areSameModule(a, b) {
138202
+ if (!a.body || !b.body) {
138203
+ return a.body === b.body;
138204
+ }
137925
138205
  return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body));
137926
138206
  }
137927
138207
  /** Merge source into target. Source should be thrown away after this is called. */
@@ -146699,20 +146979,31 @@ var ts;
146699
146979
  codefix.registerCodeFix({
146700
146980
  errorCodes: errorCodes,
146701
146981
  getCodeActions: function getCodeActionsToAddConvertToUnknownForNonOverlappingTypes(context) {
146702
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); });
146982
+ var assertion = getAssertion(context.sourceFile, context.span.start);
146983
+ if (assertion === undefined)
146984
+ return undefined;
146985
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, assertion); });
146703
146986
  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)];
146704
146987
  },
146705
146988
  fixIds: [fixId],
146706
- getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); },
146989
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
146990
+ var assertion = getAssertion(diag.file, diag.start);
146991
+ if (assertion) {
146992
+ makeChange(changes, diag.file, assertion);
146993
+ }
146994
+ }); },
146707
146995
  });
146708
- function makeChange(changeTracker, sourceFile, pos) {
146709
- var token = ts.getTokenAtPosition(sourceFile, pos);
146710
- var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression");
146996
+ function makeChange(changeTracker, sourceFile, assertion) {
146711
146997
  var replacement = ts.isAsExpression(assertion)
146712
146998
  ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */))
146713
146999
  : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */), assertion.expression);
146714
147000
  changeTracker.replaceNode(sourceFile, assertion.expression, replacement);
146715
147001
  }
147002
+ function getAssertion(sourceFile, pos) {
147003
+ if (ts.isInJSFile(sourceFile))
147004
+ return undefined;
147005
+ return ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); });
147006
+ }
146716
147007
  })(codefix = ts.codefix || (ts.codefix = {}));
146717
147008
  })(ts || (ts = {}));
146718
147009
  /* @internal */
@@ -155136,7 +155427,7 @@ var ts;
155136
155427
  defaultToNamedAction.kind,
155137
155428
  namedToDefaultAction.kind
155138
155429
  ],
155139
- getAvailableActions: function (context) {
155430
+ getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndDefaultExports(context) {
155140
155431
  var info = getInfo(context, context.triggerReason === "invoked");
155141
155432
  if (!info)
155142
155433
  return ts.emptyArray;
@@ -155154,7 +155445,7 @@ var ts;
155154
155445
  }
155155
155446
  return ts.emptyArray;
155156
155447
  },
155157
- getEditsForAction: function (context, actionName) {
155448
+ getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndDefaultExports(context, actionName) {
155158
155449
  ts.Debug.assert(actionName === defaultToNamedAction.name || actionName === namedToDefaultAction.name, "Unexpected action name");
155159
155450
  var info = getInfo(context);
155160
155451
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -155382,7 +155673,7 @@ var ts;
155382
155673
  namespaceToNamedAction.kind,
155383
155674
  namedToNamespaceAction.kind
155384
155675
  ],
155385
- getAvailableActions: function (context) {
155676
+ getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
155386
155677
  var info = getImportToConvert(context, context.triggerReason === "invoked");
155387
155678
  if (!info)
155388
155679
  return ts.emptyArray;
@@ -155401,7 +155692,7 @@ var ts;
155401
155692
  }
155402
155693
  return ts.emptyArray;
155403
155694
  },
155404
- getEditsForAction: function (context, actionName) {
155695
+ getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
155405
155696
  ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
155406
155697
  var info = getImportToConvert(context);
155407
155698
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -155567,10 +155858,10 @@ var ts;
155567
155858
  };
155568
155859
  refactor.registerRefactor(refactorName, {
155569
155860
  kinds: [toOptionalChainAction.kind],
155570
- getAvailableActions: getAvailableActions,
155571
- getEditsForAction: getEditsForAction
155861
+ getEditsForAction: getRefactorEditsToConvertToOptionalChain,
155862
+ getAvailableActions: getRefactorActionsToConvertToOptionalChain,
155572
155863
  });
155573
- function getAvailableActions(context) {
155864
+ function getRefactorActionsToConvertToOptionalChain(context) {
155574
155865
  var info = getInfo(context, context.triggerReason === "invoked");
155575
155866
  if (!info)
155576
155867
  return ts.emptyArray;
@@ -155590,7 +155881,7 @@ var ts;
155590
155881
  }
155591
155882
  return ts.emptyArray;
155592
155883
  }
155593
- function getEditsForAction(context, actionName) {
155884
+ function getRefactorEditsToConvertToOptionalChain(context, actionName) {
155594
155885
  var info = getInfo(context);
155595
155886
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
155596
155887
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) {
@@ -155833,10 +156124,10 @@ var ts;
155833
156124
  };
155834
156125
  refactor.registerRefactor(refactorName, {
155835
156126
  kinds: [functionOverloadAction.kind],
155836
- getEditsForAction: getEditsForAction,
155837
- getAvailableActions: getAvailableActions
156127
+ getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
156128
+ getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
155838
156129
  });
155839
- function getAvailableActions(context) {
156130
+ function getRefactorActionsToConvertOverloadsToOneSignature(context) {
155840
156131
  var file = context.file, startPosition = context.startPosition, program = context.program;
155841
156132
  var info = getConvertableOverloadListAtPosition(file, startPosition, program);
155842
156133
  if (!info)
@@ -155847,7 +156138,7 @@ var ts;
155847
156138
  actions: [functionOverloadAction]
155848
156139
  }];
155849
156140
  }
155850
- function getEditsForAction(context) {
156141
+ function getRefactorEditsToConvertOverloadsToOneSignature(context) {
155851
156142
  var file = context.file, startPosition = context.startPosition, program = context.program;
155852
156143
  var signatureDecls = getConvertableOverloadListAtPosition(file, startPosition, program);
155853
156144
  if (!signatureDecls)
@@ -156003,14 +156294,14 @@ var ts;
156003
156294
  extractConstantAction.kind,
156004
156295
  extractFunctionAction.kind
156005
156296
  ],
156006
- getAvailableActions: getAvailableActions,
156007
- getEditsForAction: getEditsForAction
156297
+ getEditsForAction: getRefactorEditsToExtractSymbol,
156298
+ getAvailableActions: getRefactorActionsToExtractSymbol,
156008
156299
  });
156009
156300
  /**
156010
156301
  * Compute the associated code actions
156011
156302
  * Exported for tests.
156012
156303
  */
156013
- function getAvailableActions(context) {
156304
+ function getRefactorActionsToExtractSymbol(context) {
156014
156305
  var requestedRefactor = context.kind;
156015
156306
  var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context), context.triggerReason === "invoked");
156016
156307
  var targetRange = rangeToExtract.targetRange;
@@ -156139,9 +156430,9 @@ var ts;
156139
156430
  return error;
156140
156431
  }
156141
156432
  }
156142
- extractSymbol.getAvailableActions = getAvailableActions;
156433
+ extractSymbol.getRefactorActionsToExtractSymbol = getRefactorActionsToExtractSymbol;
156143
156434
  /* Exported for tests */
156144
- function getEditsForAction(context, actionName) {
156435
+ function getRefactorEditsToExtractSymbol(context, actionName) {
156145
156436
  var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context));
156146
156437
  var targetRange = rangeToExtract.targetRange; // TODO:GH#18217
156147
156438
  var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName);
@@ -156158,7 +156449,7 @@ var ts;
156158
156449
  }
156159
156450
  ts.Debug.fail("Unrecognized action name");
156160
156451
  }
156161
- extractSymbol.getEditsForAction = getEditsForAction;
156452
+ extractSymbol.getRefactorEditsToExtractSymbol = getRefactorEditsToExtractSymbol;
156162
156453
  // Move these into diagnostic messages if they become user-facing
156163
156454
  var Messages;
156164
156455
  (function (Messages) {
@@ -157709,7 +158000,7 @@ var ts;
157709
158000
  extractToInterfaceAction.kind,
157710
158001
  extractToTypeDefAction.kind
157711
158002
  ],
157712
- getAvailableActions: function (context) {
158003
+ getAvailableActions: function getRefactorActionsToExtractType(context) {
157713
158004
  var info = getRangeToExtract(context, context.triggerReason === "invoked");
157714
158005
  if (!info)
157715
158006
  return ts.emptyArray;
@@ -157734,7 +158025,7 @@ var ts;
157734
158025
  }
157735
158026
  return ts.emptyArray;
157736
158027
  },
157737
- getEditsForAction: function (context, actionName) {
158028
+ getEditsForAction: function getRefactorEditsToExtractType(context, actionName) {
157738
158029
  var file = context.file;
157739
158030
  var info = getRangeToExtract(context);
157740
158031
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected to find a range to extract");
@@ -157902,7 +158193,7 @@ var ts;
157902
158193
  };
157903
158194
  refactor.registerRefactor(actionName, {
157904
158195
  kinds: [generateGetSetAction.kind],
157905
- getEditsForAction: function (context, actionName) {
158196
+ getEditsForAction: function getRefactorActionsToGenerateGetAndSetAccessors(context, actionName) {
157906
158197
  if (!context.endPosition)
157907
158198
  return undefined;
157908
158199
  var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.program, context.startPosition, context.endPosition);
@@ -157981,7 +158272,7 @@ var ts;
157981
158272
  };
157982
158273
  refactor.registerRefactor(refactorName, {
157983
158274
  kinds: [moveToNewFileAction.kind],
157984
- getAvailableActions: function (context) {
158275
+ getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
157985
158276
  var statements = getStatementsToMove(context);
157986
158277
  if (context.preferences.allowTextChangesInNewFiles && statements) {
157987
158278
  return [{ name: refactorName, description: description, actions: [moveToNewFileAction] }];
@@ -157992,7 +158283,7 @@ var ts;
157992
158283
  }
157993
158284
  return ts.emptyArray;
157994
158285
  },
157995
- getEditsForAction: function (context, actionName) {
158286
+ getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName) {
157996
158287
  ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked");
157997
158288
  var statements = ts.Debug.checkDefined(getStatementsToMove(context));
157998
158289
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); });
@@ -158723,10 +159014,10 @@ var ts;
158723
159014
  };
158724
159015
  refactor.registerRefactor(refactorName, {
158725
159016
  kinds: [removeBracesAction.kind],
158726
- getEditsForAction: getEditsForAction,
158727
- getAvailableActions: getAvailableActions
159017
+ getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
159018
+ getAvailableActions: getRefactorActionsToRemoveFunctionBraces
158728
159019
  });
158729
- function getAvailableActions(context) {
159020
+ function getRefactorActionsToRemoveFunctionBraces(context) {
158730
159021
  var file = context.file, startPosition = context.startPosition, triggerReason = context.triggerReason;
158731
159022
  var info = getConvertibleArrowFunctionAtPosition(file, startPosition, triggerReason === "invoked");
158732
159023
  if (!info)
@@ -158752,7 +159043,7 @@ var ts;
158752
159043
  }
158753
159044
  return ts.emptyArray;
158754
159045
  }
158755
- function getEditsForAction(context, actionName) {
159046
+ function getRefactorEditsToRemoveFunctionBraces(context, actionName) {
158756
159047
  var file = context.file, startPosition = context.startPosition;
158757
159048
  var info = getConvertibleArrowFunctionAtPosition(file, startPosition);
158758
159049
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -158826,10 +159117,10 @@ var ts;
158826
159117
  };
158827
159118
  refactor.registerRefactor(refactorName, {
158828
159119
  kinds: [toDestructuredAction.kind],
158829
- getEditsForAction: getEditsForAction,
158830
- getAvailableActions: getAvailableActions
159120
+ getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
159121
+ getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
158831
159122
  });
158832
- function getAvailableActions(context) {
159123
+ function getRefactorActionsToConvertParametersToDestructuredObject(context) {
158833
159124
  var file = context.file, startPosition = context.startPosition;
158834
159125
  var isJSFile = ts.isSourceFileJS(file);
158835
159126
  if (isJSFile)
@@ -158843,7 +159134,7 @@ var ts;
158843
159134
  actions: [toDestructuredAction]
158844
159135
  }];
158845
159136
  }
158846
- function getEditsForAction(context, actionName) {
159137
+ function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName) {
158847
159138
  ts.Debug.assert(actionName === refactorName, "Unexpected action name");
158848
159139
  var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host;
158849
159140
  var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
@@ -159353,10 +159644,10 @@ var ts;
159353
159644
  };
159354
159645
  refactor.registerRefactor(refactorName, {
159355
159646
  kinds: [convertStringAction.kind],
159356
- getEditsForAction: getEditsForAction,
159357
- getAvailableActions: getAvailableActions
159647
+ getEditsForAction: getRefactorEditsToConvertToTemplateString,
159648
+ getAvailableActions: getRefactorActionsToConvertToTemplateString
159358
159649
  });
159359
- function getAvailableActions(context) {
159650
+ function getRefactorActionsToConvertToTemplateString(context) {
159360
159651
  var file = context.file, startPosition = context.startPosition;
159361
159652
  var node = getNodeOrParentOfParentheses(file, startPosition);
159362
159653
  var maybeBinary = getParentBinaryExpression(node);
@@ -159382,7 +159673,7 @@ var ts;
159382
159673
  }
159383
159674
  return node;
159384
159675
  }
159385
- function getEditsForAction(context, actionName) {
159676
+ function getRefactorEditsToConvertToTemplateString(context, actionName) {
159386
159677
  var file = context.file, startPosition = context.startPosition;
159387
159678
  var node = getNodeOrParentOfParentheses(file, startPosition);
159388
159679
  switch (actionName) {
@@ -159596,10 +159887,10 @@ var ts;
159596
159887
  toNamedFunctionAction.kind,
159597
159888
  toArrowFunctionAction.kind
159598
159889
  ],
159599
- getEditsForAction: getEditsForAction,
159600
- getAvailableActions: getAvailableActions
159890
+ getEditsForAction: getRefactorEditsToConvertFunctionExpressions,
159891
+ getAvailableActions: getRefactorActionsToConvertFunctionExpressions
159601
159892
  });
159602
- function getAvailableActions(context) {
159893
+ function getRefactorActionsToConvertFunctionExpressions(context) {
159603
159894
  var file = context.file, startPosition = context.startPosition, program = context.program, kind = context.kind;
159604
159895
  var info = getFunctionInfo(file, startPosition, program);
159605
159896
  if (!info)
@@ -159643,7 +159934,7 @@ var ts;
159643
159934
  errors : possibleActions
159644
159935
  }];
159645
159936
  }
159646
- function getEditsForAction(context, actionName) {
159937
+ function getRefactorEditsToConvertFunctionExpressions(context, actionName) {
159647
159938
  var file = context.file, startPosition = context.startPosition, program = context.program;
159648
159939
  var info = getFunctionInfo(file, startPosition, program);
159649
159940
  if (!info)
@@ -159803,10 +160094,10 @@ var ts;
159803
160094
  };
159804
160095
  refactor.registerRefactor(refactorName, {
159805
160096
  kinds: [inferReturnTypeAction.kind],
159806
- getEditsForAction: getEditsForAction,
159807
- getAvailableActions: getAvailableActions
160097
+ getEditsForAction: getRefactorEditsToInferReturnType,
160098
+ getAvailableActions: getRefactorActionsToInferReturnType
159808
160099
  });
159809
- function getEditsForAction(context) {
160100
+ function getRefactorEditsToInferReturnType(context) {
159810
160101
  var info = getInfo(context);
159811
160102
  if (info && !refactor.isRefactorErrorInfo(info)) {
159812
160103
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); });
@@ -159814,7 +160105,7 @@ var ts;
159814
160105
  }
159815
160106
  return undefined;
159816
160107
  }
159817
- function getAvailableActions(context) {
160108
+ function getRefactorActionsToInferReturnType(context) {
159818
160109
  var info = getInfo(context);
159819
160110
  if (!info)
159820
160111
  return ts.emptyArray;