typescript 4.9.1-beta → 5.0.0-dev.20221101

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.
@@ -104,11 +104,11 @@ var ts;
104
104
  (function (ts) {
105
105
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
106
106
  // If changing the text in this section, be sure to test `configurePrerelease` too.
107
- ts.versionMajorMinor = "4.9";
107
+ ts.versionMajorMinor = "5.0";
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = "".concat(ts.versionMajorMinor, ".1-beta");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221101");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -1900,8 +1900,8 @@ var ts;
1900
1900
  return compareValues(a === null || a === void 0 ? void 0 : a.start, b === null || b === void 0 ? void 0 : b.start) || compareValues(a === null || a === void 0 ? void 0 : a.length, b === null || b === void 0 ? void 0 : b.length);
1901
1901
  }
1902
1902
  ts.compareTextSpans = compareTextSpans;
1903
- function min(a, b, compare) {
1904
- return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b;
1903
+ function min(items, compare) {
1904
+ return reduceLeft(items, function (x, y) { return compare(x, y) === -1 /* Comparison.LessThan */ ? x : y; });
1905
1905
  }
1906
1906
  ts.min = min;
1907
1907
  /**
@@ -3214,11 +3214,13 @@ var ts;
3214
3214
  // > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
3215
3215
  // > MUST NOT include leading zeroes.
3216
3216
  var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
3217
+ var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
3217
3218
  // https://semver.org/#spec-item-10
3218
3219
  // > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
3219
3220
  // > identifiers immediately following the patch or pre-release version. Identifiers MUST
3220
3221
  // > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
3221
3222
  var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
3223
+ var buildPartRegExp = /^[a-z0-9-]+$/i;
3222
3224
  // https://semver.org/#spec-item-9
3223
3225
  // > Numeric identifiers MUST NOT include leading zeroes.
3224
3226
  var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
@@ -3238,13 +3240,15 @@ var ts;
3238
3240
  ts.Debug.assert(major >= 0, "Invalid argument: major");
3239
3241
  ts.Debug.assert(minor >= 0, "Invalid argument: minor");
3240
3242
  ts.Debug.assert(patch >= 0, "Invalid argument: patch");
3241
- ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
3242
- ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
3243
+ var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
3244
+ var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
3245
+ ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
3246
+ ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
3243
3247
  this.major = major;
3244
3248
  this.minor = minor;
3245
3249
  this.patch = patch;
3246
- this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
3247
- this.build = build ? build.split(".") : ts.emptyArray;
3250
+ this.prerelease = prereleaseArray;
3251
+ this.build = buildArray;
3248
3252
  }
3249
3253
  Version.tryParse = function (text) {
3250
3254
  var result = tryParseComponents(text);
@@ -3283,6 +3287,10 @@ var ts;
3283
3287
  default: return ts.Debug.assertNever(field);
3284
3288
  }
3285
3289
  };
3290
+ Version.prototype.with = function (fields) {
3291
+ var _a = fields.major, major = _a === void 0 ? this.major : _a, _b = fields.minor, minor = _b === void 0 ? this.minor : _b, _c = fields.patch, patch = _c === void 0 ? this.patch : _c, _d = fields.prerelease, prerelease = _d === void 0 ? this.prerelease : _d, _e = fields.build, build = _e === void 0 ? this.build : _e;
3292
+ return new Version(major, minor, patch, prerelease, build);
3293
+ };
3286
3294
  Version.prototype.toString = function () {
3287
3295
  var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
3288
3296
  if (ts.some(this.prerelease))
@@ -3291,7 +3299,7 @@ var ts;
3291
3299
  result += "+".concat(this.build.join("."));
3292
3300
  return result;
3293
3301
  };
3294
- Version.zero = new Version(0, 0, 0);
3302
+ Version.zero = new Version(0, 0, 0, ["0"]);
3295
3303
  return Version;
3296
3304
  }());
3297
3305
  ts.Version = Version;
@@ -3374,6 +3382,10 @@ var ts;
3374
3382
  }
3375
3383
  return undefined;
3376
3384
  };
3385
+ /**
3386
+ * Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
3387
+ * in `node-semver`.
3388
+ */
3377
3389
  VersionRange.prototype.test = function (version) {
3378
3390
  if (typeof version === "string")
3379
3391
  version = new Version(version);
@@ -3484,19 +3496,20 @@ var ts;
3484
3496
  break;
3485
3497
  case "<":
3486
3498
  case ">=":
3487
- comparators.push(createComparator(operator, version));
3499
+ comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
3500
+ createComparator(operator, version));
3488
3501
  break;
3489
3502
  case "<=":
3490
3503
  case ">":
3491
- comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
3492
- isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
3504
+ comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
3505
+ isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
3493
3506
  createComparator(operator, version));
3494
3507
  break;
3495
3508
  case "=":
3496
3509
  case undefined:
3497
3510
  if (isWildcard(minor) || isWildcard(patch)) {
3498
- comparators.push(createComparator(">=", version));
3499
- comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
3511
+ comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
3512
+ comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
3500
3513
  }
3501
3514
  else {
3502
3515
  comparators.push(createComparator("=", version));
@@ -5105,8 +5118,8 @@ var ts;
5105
5118
  NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
5106
5119
  NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
5107
5120
  NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
5108
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper";
5109
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding";
5121
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAccessInAsync"] = 2048] = "MethodWithSuperPropertyAccessInAsync";
5122
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAssignmentInAsync"] = 4096] = "MethodWithSuperPropertyAssignmentInAsync";
5110
5123
  NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
5111
5124
  NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
5112
5125
  NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
@@ -6741,7 +6754,7 @@ var ts;
6741
6754
  }
6742
6755
  /*@internal*/
6743
6756
  function createSystemWatchFunctions(_a) {
6744
- var pollingWatchFileWorker = _a.pollingWatchFileWorker, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
6757
+ var pollingWatchFileWorker = _a.pollingWatchFileWorker, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
6745
6758
  var pollingWatches = new ts.Map();
6746
6759
  var fsWatches = new ts.Map();
6747
6760
  var fsWatchesRecursive = new ts.Map();
@@ -6807,8 +6820,8 @@ var ts;
6807
6820
  return useNonPollingWatchers ?
6808
6821
  // Use notifications from FS to watch with falling back to fs.watchFile
6809
6822
  generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
6810
- // Default to do not use fixed polling interval
6811
- { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.UseFsEvents };
6823
+ // Default to using fs events
6824
+ { watchFile: ts.WatchFileKind.UseFsEvents };
6812
6825
  }
6813
6826
  }
6814
6827
  function generateWatchFileOptions(watchFile, fallbackPolling, options) {
@@ -7080,7 +7093,6 @@ var ts;
7080
7093
  tscWatchFile: process.env.TSC_WATCHFILE,
7081
7094
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
7082
7095
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
7083
- defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7084
7096
  inodeWatching: isLinuxOrMacOs,
7085
7097
  sysLog: sysLog,
7086
7098
  }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
@@ -9591,6 +9603,10 @@ var ts;
9591
9603
  Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"),
9592
9604
  Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"),
9593
9605
  Project_0_is_out_of_date_because_there_was_error_reading_file_1: diag(6401, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_there_was_error_reading_file_1_6401", "Project '{0}' is out of date because there was error reading file '{1}'"),
9606
+ Resolving_in_0_mode_with_conditions_1: diag(6402, ts.DiagnosticCategory.Message, "Resolving_in_0_mode_with_conditions_1_6402", "Resolving in {0} mode with conditions {1}."),
9607
+ Matched_0_condition_1: diag(6403, ts.DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."),
9608
+ Using_0_subpath_1_with_target_2: diag(6404, ts.DiagnosticCategory.Message, "Using_0_subpath_1_with_target_2_6404", "Using '{0}' subpath '{1}' with target '{2}'."),
9609
+ Saw_non_matching_condition_0: diag(6405, ts.DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
9594
9610
  The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
9595
9611
  The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
9596
9612
  The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
@@ -9907,6 +9923,8 @@ var ts;
9907
9923
  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}\""),
9908
9924
  Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
9909
9925
  Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
9926
+ Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
9927
+ Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
9910
9928
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9911
9929
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9912
9930
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -11364,7 +11382,7 @@ var ts;
11364
11382
  return -1;
11365
11383
  }
11366
11384
  function peekExtendedUnicodeEscape() {
11367
- if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11385
+ if (codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11368
11386
  var start_2 = pos;
11369
11387
  pos += 3;
11370
11388
  var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
@@ -21667,6 +21685,32 @@ var ts;
21667
21685
  return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21668
21686
  }
21669
21687
  ts.getParameterTypeNode = getParameterTypeNode;
21688
+ function isTypeDeclaration(node) {
21689
+ switch (node.kind) {
21690
+ case 165 /* SyntaxKind.TypeParameter */:
21691
+ case 260 /* SyntaxKind.ClassDeclaration */:
21692
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
21693
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
21694
+ case 263 /* SyntaxKind.EnumDeclaration */:
21695
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
21696
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
21697
+ case 342 /* SyntaxKind.JSDocEnumTag */:
21698
+ return true;
21699
+ case 270 /* SyntaxKind.ImportClause */:
21700
+ return node.isTypeOnly;
21701
+ case 273 /* SyntaxKind.ImportSpecifier */:
21702
+ case 278 /* SyntaxKind.ExportSpecifier */:
21703
+ return node.parent.parent.isTypeOnly;
21704
+ default:
21705
+ return false;
21706
+ }
21707
+ }
21708
+ ts.isTypeDeclaration = isTypeDeclaration;
21709
+ function canHaveExportModifier(node) {
21710
+ return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
21711
+ || ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
21712
+ }
21713
+ ts.canHaveExportModifier = canHaveExportModifier;
21670
21714
  })(ts || (ts = {}));
21671
21715
  /* @internal */
21672
21716
  var ts;
@@ -21675,13 +21719,11 @@ var ts;
21675
21719
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21676
21720
  */
21677
21721
  function createBaseNodeFactory() {
21678
- // tslint:disable variable-name
21679
21722
  var NodeConstructor;
21680
21723
  var TokenConstructor;
21681
21724
  var IdentifierConstructor;
21682
21725
  var PrivateIdentifierConstructor;
21683
21726
  var SourceFileConstructor;
21684
- // tslint:enable variable-name
21685
21727
  return {
21686
21728
  createBaseSourceFileNode: createBaseSourceFileNode,
21687
21729
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -23145,7 +23187,7 @@ var ts;
23145
23187
  return node;
23146
23188
  }
23147
23189
  // @api
23148
- function createIdentifier(text, typeArguments, originalKeywordKind) {
23190
+ function createIdentifier(text, typeArguments, originalKeywordKind, hasExtendedUnicodeEscape) {
23149
23191
  var node = createBaseIdentifier(text, originalKeywordKind);
23150
23192
  if (typeArguments) {
23151
23193
  // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
@@ -23154,6 +23196,10 @@ var ts;
23154
23196
  if (node.originalKeywordKind === 133 /* SyntaxKind.AwaitKeyword */) {
23155
23197
  node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */;
23156
23198
  }
23199
+ if (hasExtendedUnicodeEscape) {
23200
+ node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
23201
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
23202
+ }
23157
23203
  return node;
23158
23204
  }
23159
23205
  // @api
@@ -27609,11 +27655,9 @@ var ts;
27609
27655
  rawTextScanner.setText("`" + rawText + "`");
27610
27656
  break;
27611
27657
  case 15 /* SyntaxKind.TemplateHead */:
27612
- // tslint:disable-next-line no-invalid-template-strings
27613
27658
  rawTextScanner.setText("`" + rawText + "${");
27614
27659
  break;
27615
27660
  case 16 /* SyntaxKind.TemplateMiddle */:
27616
- // tslint:disable-next-line no-invalid-template-strings
27617
27661
  rawTextScanner.setText("}" + rawText + "${");
27618
27662
  break;
27619
27663
  case 17 /* SyntaxKind.TemplateTail */:
@@ -27972,7 +28016,6 @@ var ts;
27972
28016
  return node;
27973
28017
  }
27974
28018
  ts.createInputFiles = createInputFiles;
27975
- // tslint:disable-next-line variable-name
27976
28019
  var SourceMapSource;
27977
28020
  /**
27978
28021
  * Create an external source map source file reference
@@ -28764,6 +28807,8 @@ var ts;
28764
28807
  // - The verb (`next`, `throw`, or `return` method) to delegate to the expression
28765
28808
  // of a `yield*`.
28766
28809
  // - The result of evaluating the verb delegated to the expression of a `yield*`.
28810
+ // g A temporary variable that holds onto the generator object until the generator
28811
+ // is started, allowing it to also act as the `suspendedStart` state.
28767
28812
  //
28768
28813
  // functions:
28769
28814
  // verb(n) Creates a bound callback to the `step` function for opcode `n`.
@@ -28802,7 +28847,7 @@ var ts;
28802
28847
  importName: "__generator",
28803
28848
  scoped: false,
28804
28849
  priority: 6,
28805
- text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };"
28850
+ text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };"
28806
28851
  };
28807
28852
  // ES Module Helpers
28808
28853
  ts.createBindingHelper = {
@@ -32106,13 +32151,11 @@ var ts;
32106
32151
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32107
32152
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32108
32153
  // capture constructors in 'initializeState' to avoid null checks
32109
- // tslint:disable variable-name
32110
32154
  var NodeConstructor;
32111
32155
  var TokenConstructor;
32112
32156
  var IdentifierConstructor;
32113
32157
  var PrivateIdentifierConstructor;
32114
32158
  var SourceFileConstructor;
32115
- // tslint:enable variable-name
32116
32159
  function countNode(node) {
32117
32160
  nodeCount++;
32118
32161
  return node;
@@ -33088,8 +33131,9 @@ var ts;
33088
33131
  // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
33089
33132
  var originalKeywordKind = token();
33090
33133
  var text = internIdentifier(scanner.getTokenValue());
33134
+ var hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
33091
33135
  nextTokenWithoutCheck();
33092
- return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
33136
+ return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind, hasExtendedUnicodeEscape), pos);
33093
33137
  }
33094
33138
  if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
33095
33139
  parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
@@ -40338,9 +40382,6 @@ var ts;
40338
40382
  name: "listFilesOnly",
40339
40383
  type: "boolean",
40340
40384
  category: ts.Diagnostics.Command_line_Options,
40341
- affectsSemanticDiagnostics: true,
40342
- affectsEmit: true,
40343
- affectsMultiFileEmitBuildInfo: true,
40344
40385
  isCommandLineOnly: true,
40345
40386
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
40346
40387
  defaultValueDescription: false,
@@ -42068,12 +42109,14 @@ var ts;
42068
42109
  return config;
42069
42110
  }
42070
42111
  ts.convertToTSConfig = convertToTSConfig;
42112
+ /*@internal*/
42071
42113
  function optionMapToObject(optionMap) {
42072
42114
  return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
42073
42115
  var _a;
42074
42116
  return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
42075
42117
  }, {}));
42076
42118
  }
42119
+ ts.optionMapToObject = optionMapToObject;
42077
42120
  function filterSameAsDefaultInclude(specs) {
42078
42121
  if (!ts.length(specs))
42079
42122
  return undefined;
@@ -42122,9 +42165,11 @@ var ts;
42122
42165
  });
42123
42166
  }
42124
42167
  ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
42168
+ /* @internal */
42125
42169
  function serializeCompilerOptions(options, pathOptions) {
42126
42170
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
42127
42171
  }
42172
+ ts.serializeCompilerOptions = serializeCompilerOptions;
42128
42173
  function serializeWatchOptions(options) {
42129
42174
  return serializeOptionBaseObject(options, getWatchOptionsNameMap());
42130
42175
  }
@@ -42228,12 +42273,23 @@ var ts;
42228
42273
  }
42229
42274
  function writeConfigurations() {
42230
42275
  // Filter applicable options to place in the file
42231
- var categorizedOptions = ts.createMultiMap();
42276
+ var categorizedOptions = new ts.Map();
42277
+ // Set allowed categories in order
42278
+ categorizedOptions.set(ts.Diagnostics.Projects, []);
42279
+ categorizedOptions.set(ts.Diagnostics.Language_and_Environment, []);
42280
+ categorizedOptions.set(ts.Diagnostics.Modules, []);
42281
+ categorizedOptions.set(ts.Diagnostics.JavaScript_Support, []);
42282
+ categorizedOptions.set(ts.Diagnostics.Emit, []);
42283
+ categorizedOptions.set(ts.Diagnostics.Interop_Constraints, []);
42284
+ categorizedOptions.set(ts.Diagnostics.Type_Checking, []);
42285
+ categorizedOptions.set(ts.Diagnostics.Completeness, []);
42232
42286
  for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
42233
42287
  var option = optionDeclarations_1[_i];
42234
- var category = option.category;
42235
42288
  if (isAllowedOptionForOutput(option)) {
42236
- categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
42289
+ var listForCategory = categorizedOptions.get(option.category);
42290
+ if (!listForCategory)
42291
+ categorizedOptions.set(option.category, listForCategory = []);
42292
+ listForCategory.push(option);
42237
42293
  }
42238
42294
  }
42239
42295
  // Serialize all options and their descriptions
@@ -42244,7 +42300,7 @@ var ts;
42244
42300
  if (entries.length !== 0) {
42245
42301
  entries.push({ value: "" });
42246
42302
  }
42247
- entries.push({ value: "/* ".concat(category, " */") });
42303
+ entries.push({ value: "/* ".concat(ts.getLocaleSpecificMessage(category), " */") });
42248
42304
  for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
42249
42305
  var option = options_1[_i];
42250
42306
  var optionName = void 0;
@@ -44286,6 +44342,9 @@ var ts;
44286
44342
  requestContainingDirectory: containingDirectory,
44287
44343
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44288
44344
  };
44345
+ if (traceEnabled && ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) <= ts.ModuleResolutionKind.NodeNext) {
44346
+ trace(host, ts.Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(function (c) { return "'".concat(c, "'"); }).join(", "));
44347
+ }
44289
44348
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
44290
44349
  return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44291
44350
  function tryResolve(extensions) {
@@ -44875,7 +44934,7 @@ var ts;
44875
44934
  }
44876
44935
  if (mainExport) {
44877
44936
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
44878
- return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
44937
+ return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false, ".");
44879
44938
  }
44880
44939
  }
44881
44940
  else if (allKeysStartWithDot(scope.contents.packageJsonContent.exports)) {
@@ -44955,7 +45014,7 @@ var ts;
44955
45014
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44956
45015
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
44957
45016
  var target = lookupTable[moduleName];
44958
- return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
45017
+ return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
44959
45018
  }
44960
45019
  var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
44961
45020
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
@@ -44964,17 +45023,17 @@ var ts;
44964
45023
  var target = lookupTable[potentialTarget];
44965
45024
  var starPos = potentialTarget.indexOf("*");
44966
45025
  var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
44967
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
45026
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
44968
45027
  }
44969
45028
  else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
44970
45029
  var target = lookupTable[potentialTarget];
44971
45030
  var subpath = moduleName.substring(potentialTarget.length - 1);
44972
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
45031
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
44973
45032
  }
44974
45033
  else if (ts.startsWith(moduleName, potentialTarget)) {
44975
45034
  var target = lookupTable[potentialTarget];
44976
45035
  var subpath = moduleName.substring(potentialTarget.length);
44977
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
45036
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false, potentialTarget);
44978
45037
  }
44979
45038
  }
44980
45039
  function matchesPatternWithTrailer(target, name) {
@@ -44991,7 +45050,7 @@ var ts;
44991
45050
  */
44992
45051
  function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
44993
45052
  return loadModuleFromTargetImportOrExport;
44994
- function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
45053
+ function loadModuleFromTargetImportOrExport(target, subpath, pattern, key) {
44995
45054
  if (typeof target === "string") {
44996
45055
  if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
44997
45056
  if (state.traceEnabled) {
@@ -45002,6 +45061,8 @@ var ts;
45002
45061
  if (!ts.startsWith(target, "./")) {
45003
45062
  if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
45004
45063
  var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
45064
+ traceIfEnabled(state, ts.Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
45065
+ traceIfEnabled(state, ts.Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
45005
45066
  var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
45006
45067
  return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
45007
45068
  }
@@ -45028,6 +45089,9 @@ var ts;
45028
45089
  }
45029
45090
  return toSearchResult(/*value*/ undefined);
45030
45091
  }
45092
+ if (state.traceEnabled) {
45093
+ trace(state.host, ts.Diagnostics.Using_0_subpath_1_with_target_2, isImports ? "imports" : "exports", key, pattern ? target.replace(/\*/g, subpath) : target + subpath);
45094
+ }
45031
45095
  var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
45032
45096
  var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
45033
45097
  if (inputLink)
@@ -45037,14 +45101,18 @@ var ts;
45037
45101
  else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
45038
45102
  if (!Array.isArray(target)) {
45039
45103
  for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
45040
- var key = _a[_i];
45041
- if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
45042
- var subTarget = target[key];
45043
- var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
45104
+ var condition = _a[_i];
45105
+ if (condition === "default" || state.conditions.indexOf(condition) >= 0 || isApplicableVersionedTypesKey(state.conditions, condition)) {
45106
+ traceIfEnabled(state, ts.Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
45107
+ var subTarget = target[condition];
45108
+ var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern, key);
45044
45109
  if (result) {
45045
45110
  return result;
45046
45111
  }
45047
45112
  }
45113
+ else {
45114
+ traceIfEnabled(state, ts.Diagnostics.Saw_non_matching_condition_0, condition);
45115
+ }
45048
45116
  }
45049
45117
  return undefined;
45050
45118
  }
@@ -45057,7 +45125,7 @@ var ts;
45057
45125
  }
45058
45126
  for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
45059
45127
  var elem = target_2[_b];
45060
- var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
45128
+ var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern, key);
45061
45129
  if (result) {
45062
45130
  return result;
45063
45131
  }
@@ -45473,6 +45541,15 @@ var ts;
45473
45541
  function toSearchResult(value) {
45474
45542
  return value !== undefined ? { value: value } : undefined;
45475
45543
  }
45544
+ function traceIfEnabled(state, diagnostic) {
45545
+ var args = [];
45546
+ for (var _i = 2; _i < arguments.length; _i++) {
45547
+ args[_i - 2] = arguments[_i];
45548
+ }
45549
+ if (state.traceEnabled) {
45550
+ trace.apply(void 0, __spreadArray([state.host, diagnostic], args, false));
45551
+ }
45552
+ }
45476
45553
  })(ts || (ts = {}));
45477
45554
  /* @internal */
45478
45555
  var ts;
@@ -49064,8 +49141,6 @@ var ts;
49064
49141
  IntersectionState[IntersectionState["None"] = 0] = "None";
49065
49142
  IntersectionState[IntersectionState["Source"] = 1] = "Source";
49066
49143
  IntersectionState[IntersectionState["Target"] = 2] = "Target";
49067
- IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
49068
- IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
49069
49144
  })(IntersectionState || (IntersectionState = {}));
49070
49145
  var RecursionFlags;
49071
49146
  (function (RecursionFlags) {
@@ -49484,6 +49559,12 @@ var ts;
49484
49559
  getOptionalType: function () { return optionalType; },
49485
49560
  getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
49486
49561
  getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
49562
+ getAsyncIterableType: function () {
49563
+ var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
49564
+ if (type === emptyGenericType)
49565
+ return undefined;
49566
+ return type;
49567
+ },
49487
49568
  isSymbolAccessible: isSymbolAccessible,
49488
49569
  isArrayType: isArrayType,
49489
49570
  isTupleType: isTupleType,
@@ -50321,9 +50402,9 @@ var ts;
50321
50402
  return symbol;
50322
50403
  }
50323
50404
  if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
50324
- var target = resolveAlias(symbol);
50325
- // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors
50326
- if (target === unknownSymbol || target.flags & meaning) {
50405
+ var targetFlags = getAllSymbolFlags(symbol);
50406
+ // `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
50407
+ if (targetFlags & meaning) {
50327
50408
  return symbol;
50328
50409
  }
50329
50410
  }
@@ -50956,8 +51037,8 @@ var ts;
50956
51037
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50957
51038
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50958
51039
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
51040
+ !checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
50959
51041
  !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
50960
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50961
51042
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50962
51043
  var suggestion = void 0;
50963
51044
  var suggestedLib = void 0;
@@ -51044,7 +51125,7 @@ var ts;
51044
51125
  }
51045
51126
  }
51046
51127
  if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
51047
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
51128
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
51048
51129
  if (typeOnlyDeclaration) {
51049
51130
  var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
51050
51131
  ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
@@ -51207,7 +51288,7 @@ var ts;
51207
51288
  return false;
51208
51289
  }
51209
51290
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
51210
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) {
51291
+ if (meaning & 111551 /* SymbolFlags.Value */) {
51211
51292
  if (isPrimitiveTypeName(name)) {
51212
51293
  if (isExtendedByInterface(errorLocation)) {
51213
51294
  error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name));
@@ -51218,7 +51299,8 @@ var ts;
51218
51299
  return true;
51219
51300
  }
51220
51301
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51221
- if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) {
51302
+ var allFlags = symbol && getAllSymbolFlags(symbol);
51303
+ if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
51222
51304
  var rawName = ts.unescapeLeadingUnderscores(name);
51223
51305
  if (isES2015OrLaterConstructorName(name)) {
51224
51306
  error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName);
@@ -51266,16 +51348,16 @@ var ts;
51266
51348
  }
51267
51349
  return false;
51268
51350
  }
51269
- function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
51270
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) {
51271
- var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51351
+ function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
51352
+ if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
51353
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51272
51354
  if (symbol) {
51273
51355
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
51274
51356
  return true;
51275
51357
  }
51276
51358
  }
51277
- else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) {
51278
- var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51359
+ else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
51360
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51279
51361
  if (symbol) {
51280
51362
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
51281
51363
  return true;
@@ -51865,6 +51947,52 @@ var ts;
51865
51947
  }
51866
51948
  return undefined;
51867
51949
  }
51950
+ /**
51951
+ * Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
51952
+ * is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
51953
+ * with another exported symbol, e.g.
51954
+ * ```ts
51955
+ * // a.ts
51956
+ * export const a = 0;
51957
+ * // b.ts
51958
+ * export { a } from "./a";
51959
+ * export type a = number;
51960
+ * // c.ts
51961
+ * import { a } from "./b";
51962
+ * ```
51963
+ * Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
51964
+ * from b.ts, even though there is still more alias to resolve. Consequently, if we were
51965
+ * trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
51966
+ * the local symbol and on the symbol returned by `resolveAlias` is not enough.
51967
+ * @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
51968
+ * combined flags of all alias targets otherwise.
51969
+ */
51970
+ function getAllSymbolFlags(symbol) {
51971
+ var flags = symbol.flags;
51972
+ var seenSymbols;
51973
+ while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
51974
+ var target = resolveAlias(symbol);
51975
+ if (target === unknownSymbol) {
51976
+ return 67108863 /* SymbolFlags.All */;
51977
+ }
51978
+ // Optimizations - try to avoid creating or adding to
51979
+ // `seenSymbols` if possible
51980
+ if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
51981
+ break;
51982
+ }
51983
+ if (target.flags & 2097152 /* SymbolFlags.Alias */) {
51984
+ if (seenSymbols) {
51985
+ seenSymbols.add(target);
51986
+ }
51987
+ else {
51988
+ seenSymbols = new ts.Set([symbol, target]);
51989
+ }
51990
+ }
51991
+ flags |= target.flags;
51992
+ symbol = target;
51993
+ }
51994
+ return flags;
51995
+ }
51868
51996
  /**
51869
51997
  * Marks a symbol as type-only if its declaration is syntactically type-only.
51870
51998
  * If it is not itself marked type-only, but resolves to a type-only alias
@@ -51910,19 +52038,25 @@ var ts;
51910
52038
  return !!aliasDeclarationLinks.typeOnlyDeclaration;
51911
52039
  }
51912
52040
  /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
51913
- function getTypeOnlyAliasDeclaration(symbol) {
52041
+ function getTypeOnlyAliasDeclaration(symbol, include) {
51914
52042
  if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
51915
52043
  return undefined;
51916
52044
  }
51917
52045
  var links = getSymbolLinks(symbol);
51918
- return links.typeOnlyDeclaration || undefined;
52046
+ if (include === undefined) {
52047
+ return links.typeOnlyDeclaration || undefined;
52048
+ }
52049
+ if (links.typeOnlyDeclaration) {
52050
+ return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
52051
+ }
52052
+ return undefined;
51919
52053
  }
51920
52054
  function markExportAsReferenced(node) {
51921
52055
  var symbol = getSymbolOfNode(node);
51922
52056
  var target = resolveAlias(symbol);
51923
52057
  if (target) {
51924
52058
  var markAlias = target === unknownSymbol ||
51925
- ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
52059
+ ((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
51926
52060
  if (markAlias) {
51927
52061
  markAliasSymbolAsReferenced(symbol);
51928
52062
  }
@@ -51942,8 +52076,7 @@ var ts;
51942
52076
  // This way a chain of imports can be elided if ultimately the final input is only used in a type
51943
52077
  // position.
51944
52078
  if (ts.isInternalModuleImportEqualsDeclaration(node)) {
51945
- var target = resolveSymbol(symbol);
51946
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
52079
+ if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
51947
52080
  // import foo = <symbol>
51948
52081
  checkExpressionCached(node.moduleReference);
51949
52082
  }
@@ -52765,7 +52898,7 @@ var ts;
52765
52898
  }
52766
52899
  function symbolIsValue(symbol, includeTypeOnlyMembers) {
52767
52900
  return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
52768
- symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52901
+ symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52769
52902
  }
52770
52903
  function findConstructorDeclaration(node) {
52771
52904
  var members = node.members;
@@ -53034,8 +53167,10 @@ var ts;
53034
53167
  return true;
53035
53168
  }
53036
53169
  // Qualify if the symbol from symbol table has same meaning as expected
53037
- symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53038
- if (symbolFromSymbolTable.flags & meaning) {
53170
+ var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
53171
+ symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53172
+ var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
53173
+ if (flags & meaning) {
53039
53174
  qualify = true;
53040
53175
  return true;
53041
53176
  }
@@ -55347,7 +55482,7 @@ var ts;
55347
55482
  // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
55348
55483
  var indices = ts.indicesOf(statements);
55349
55484
  var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
55350
- if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
55485
+ if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
55351
55486
  for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
55352
55487
  var index_1 = associatedIndices_1[_i];
55353
55488
  statements[index_1] = addExportModifier(statements[index_1]);
@@ -55381,15 +55516,6 @@ var ts;
55381
55516
  }
55382
55517
  return statements;
55383
55518
  }
55384
- function canHaveExportModifier(node) {
55385
- return ts.isEnumDeclaration(node) ||
55386
- ts.isVariableStatement(node) ||
55387
- ts.isFunctionDeclaration(node) ||
55388
- ts.isClassDeclaration(node) ||
55389
- (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
55390
- ts.isInterfaceDeclaration(node) ||
55391
- isTypeDeclaration(node);
55392
- }
55393
55519
  function addExportModifier(node) {
55394
55520
  var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
55395
55521
  return ts.factory.updateModifiers(node, flags);
@@ -55636,7 +55762,7 @@ var ts;
55636
55762
  (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
55637
55763
  if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
55638
55764
  enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
55639
- canHaveExportModifier(node)) {
55765
+ ts.canHaveExportModifier(node)) {
55640
55766
  // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
55641
55767
  newModifierFlags |= 1 /* ModifierFlags.Export */;
55642
55768
  }
@@ -55692,7 +55818,7 @@ var ts;
55692
55818
  return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
55693
55819
  }
55694
55820
  function isTypeOnlyNamespace(symbol) {
55695
- return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); });
55821
+ return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
55696
55822
  }
55697
55823
  function serializeModule(symbol, symbolName, modifierFlags) {
55698
55824
  var members = getNamespaceMembersForSerialization(symbol);
@@ -57606,16 +57732,32 @@ var ts;
57606
57732
  return getTypeFromTypeNode(typeNode);
57607
57733
  }
57608
57734
  }
57735
+ function isParameterOfContextSensitiveSignature(symbol) {
57736
+ var decl = symbol.valueDeclaration;
57737
+ if (!decl) {
57738
+ return false;
57739
+ }
57740
+ if (ts.isBindingElement(decl)) {
57741
+ decl = ts.walkUpBindingElementsAndPatterns(decl);
57742
+ }
57743
+ if (ts.isParameter(decl)) {
57744
+ return isContextSensitiveFunctionOrObjectLiteralMethod(decl.parent);
57745
+ }
57746
+ return false;
57747
+ }
57609
57748
  function getTypeOfVariableOrParameterOrProperty(symbol) {
57610
57749
  var links = getSymbolLinks(symbol);
57611
57750
  if (!links.type) {
57612
57751
  var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
57613
57752
  // For a contextually typed parameter it is possible that a type has already
57614
57753
  // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
57615
- // to preserve this type.
57616
- if (!links.type) {
57754
+ // to preserve this type. In fact, we need to _prefer_ that type, but it won't
57755
+ // be assigned until contextual typing is complete, so we need to defer in
57756
+ // cases where contextual typing may take place.
57757
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
57617
57758
  links.type = type;
57618
57759
  }
57760
+ return type;
57619
57761
  }
57620
57762
  return links.type;
57621
57763
  }
@@ -57912,7 +58054,7 @@ var ts;
57912
58054
  links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
57913
58055
  : isDuplicatedCommonJSExport(symbol.declarations) ? autoType
57914
58056
  : declaredType ? declaredType
57915
- : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
58057
+ : getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
57916
58058
  : errorType;
57917
58059
  }
57918
58060
  return links.type;
@@ -59795,7 +59937,20 @@ var ts;
59795
59937
  return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
59796
59938
  }
59797
59939
  function isGenericMappedType(type) {
59798
- return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type));
59940
+ if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
59941
+ var constraint = getConstraintTypeFromMappedType(type);
59942
+ if (isGenericIndexType(constraint)) {
59943
+ return true;
59944
+ }
59945
+ // A mapped type is generic if the 'as' clause references generic types other than the iteration type.
59946
+ // To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
59947
+ // type and check whether the resulting type is generic.
59948
+ var nameType = getNameTypeFromMappedType(type);
59949
+ if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
59950
+ return true;
59951
+ }
59952
+ }
59953
+ return false;
59799
59954
  }
59800
59955
  function resolveStructuredTypeMembers(type) {
59801
59956
  if (!type.members) {
@@ -60265,7 +60420,7 @@ var ts;
60265
60420
  var indexTypes;
60266
60421
  var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
60267
60422
  // Flags we want to propagate to the result if they exist in all source symbols
60268
- var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */;
60423
+ var optionalFlag;
60269
60424
  var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
60270
60425
  var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
60271
60426
  var mergedInstantiations = false;
@@ -60276,11 +60431,14 @@ var ts;
60276
60431
  var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
60277
60432
  var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
60278
60433
  if (prop) {
60279
- if (isUnion) {
60280
- optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60281
- }
60282
- else {
60283
- optionalFlag &= prop.flags;
60434
+ if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
60435
+ optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
60436
+ if (isUnion) {
60437
+ optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60438
+ }
60439
+ else {
60440
+ optionalFlag &= prop.flags;
60441
+ }
60284
60442
  }
60285
60443
  if (!singleProp) {
60286
60444
  singleProp = prop;
@@ -60399,7 +60557,7 @@ var ts;
60399
60557
  propTypes.push(type);
60400
60558
  }
60401
60559
  ts.addRange(propTypes, indexTypes);
60402
- var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
60560
+ var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
60403
60561
  result.containingType = containingType;
60404
60562
  if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
60405
60563
  result.valueDeclaration = firstValueDeclaration;
@@ -63112,8 +63270,14 @@ var ts;
63112
63270
  return getStringLiteralType(text);
63113
63271
  }
63114
63272
  newTexts.push(text);
63115
- if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63116
- return stringType;
63273
+ if (ts.every(newTexts, function (t) { return t === ""; })) {
63274
+ if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63275
+ return stringType;
63276
+ }
63277
+ // Normalize `${Mapping<xxx>}` into Mapping<xxx>
63278
+ if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
63279
+ return newTypes[0];
63280
+ }
63117
63281
  }
63118
63282
  var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
63119
63283
  var type = templateLiteralTypes.get(id);
@@ -63172,12 +63336,14 @@ var ts;
63172
63336
  }
63173
63337
  function getStringMappingType(symbol, type) {
63174
63338
  return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
63175
- // Mapping<Mapping<T>> === Mapping<T>
63176
- type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63177
- isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
63178
- type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63179
- type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63180
- type;
63339
+ type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63340
+ type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63341
+ // Mapping<Mapping<T>> === Mapping<T>
63342
+ type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63343
+ type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
63344
+ // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
63345
+ isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
63346
+ type;
63181
63347
  }
63182
63348
  function applyStringMapping(symbol, str) {
63183
63349
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -63342,7 +63508,18 @@ var ts;
63342
63508
  return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63343
63509
  }
63344
63510
  errorIfWritingToReadonlyIndex(indexInfo);
63345
- return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63511
+ // When accessing an enum object with its own type,
63512
+ // e.g. E[E.A] for enum E { A }, undefined shouldn't
63513
+ // be included in the result type
63514
+ if ((accessFlags & 1 /* AccessFlags.IncludeUndefined */) &&
63515
+ !(objectType.symbol &&
63516
+ objectType.symbol.flags & (256 /* SymbolFlags.RegularEnum */ | 128 /* SymbolFlags.ConstEnum */) &&
63517
+ (indexType.symbol &&
63518
+ indexType.flags & 1024 /* TypeFlags.EnumLiteral */ &&
63519
+ getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
63520
+ return getUnionType([indexInfo.type, undefinedType]);
63521
+ }
63522
+ return indexInfo.type;
63346
63523
  }
63347
63524
  if (indexType.flags & 131072 /* TypeFlags.Never */) {
63348
63525
  return neverType;
@@ -63445,10 +63622,11 @@ var ts;
63445
63622
  accessNode;
63446
63623
  }
63447
63624
  function isPatternLiteralPlaceholderType(type) {
63448
- return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type));
63625
+ return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
63449
63626
  }
63450
63627
  function isPatternLiteralType(type) {
63451
- return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
63628
+ return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
63629
+ !!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
63452
63630
  }
63453
63631
  function isGenericType(type) {
63454
63632
  return !!getGenericObjectFlags(type);
@@ -63727,18 +63905,23 @@ var ts;
63727
63905
  var result;
63728
63906
  var extraTypes;
63729
63907
  var tailCount = 0;
63730
- var _loop_20 = function () {
63908
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
63909
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
63910
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
63911
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63912
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
63913
+ while (true) {
63731
63914
  if (tailCount === 1000) {
63732
63915
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
63733
63916
  result = errorType;
63734
- return "break";
63917
+ break;
63735
63918
  }
63736
63919
  var isUnwrapped = isTypicalNondistributiveConditional(root);
63737
63920
  var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
63738
63921
  var checkTypeInstantiable = isGenericType(checkType);
63739
63922
  var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
63740
63923
  if (checkType === wildcardType || extendsType === wildcardType) {
63741
- return { value: wildcardType };
63924
+ return wildcardType;
63742
63925
  }
63743
63926
  var combinedMapper = void 0;
63744
63927
  if (root.inferTypeParameters) {
@@ -63771,11 +63954,7 @@ var ts;
63771
63954
  }
63772
63955
  }
63773
63956
  }
63774
- // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
63775
- // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
63776
- // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
63777
- // so in those cases we refain from performing inference and retain the uninfered type parameter
63778
- if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
63957
+ if (!checkTypeInstantiable) {
63779
63958
  // We don't want inferences from constraints as they may cause us to eagerly resolve the
63780
63959
  // conditional type instead of deferring resolution. Also, we always want strict function
63781
63960
  // types rules (i.e. proper contravariance) for inferences.
@@ -63807,14 +63986,14 @@ var ts;
63807
63986
  var newRoot = falseType_1.root;
63808
63987
  if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
63809
63988
  root = newRoot;
63810
- return "continue";
63989
+ continue;
63811
63990
  }
63812
63991
  if (canTailRecurse(falseType_1, mapper)) {
63813
- return "continue";
63992
+ continue;
63814
63993
  }
63815
63994
  }
63816
63995
  result = instantiateType(falseType_1, mapper);
63817
- return "break";
63996
+ break;
63818
63997
  }
63819
63998
  // Return trueType for a definitely true extends check. We check instantiations of the two
63820
63999
  // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
@@ -63825,10 +64004,10 @@ var ts;
63825
64004
  var trueType_1 = getTypeFromTypeNode(root.node.trueType);
63826
64005
  var trueMapper = combinedMapper || mapper;
63827
64006
  if (canTailRecurse(trueType_1, trueMapper)) {
63828
- return "continue";
64007
+ continue;
63829
64008
  }
63830
64009
  result = instantiateType(trueType_1, trueMapper);
63831
- return "break";
64010
+ break;
63832
64011
  }
63833
64012
  }
63834
64013
  // Return a deferred type for a check that is neither definitely true nor definitely false
@@ -63840,19 +64019,7 @@ var ts;
63840
64019
  result.combinedMapper = combinedMapper;
63841
64020
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
63842
64021
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
63843
- return "break";
63844
- };
63845
- // We loop here for an immediately nested conditional type in the false position, effectively treating
63846
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
63847
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
63848
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63849
- // cases we increment the tail recursion counter and stop after 1000 iterations.
63850
- while (true) {
63851
- var state_6 = _loop_20();
63852
- if (typeof state_6 === "object")
63853
- return state_6.value;
63854
- if (state_6 === "break")
63855
- break;
64022
+ break;
63856
64023
  }
63857
64024
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
63858
64025
  // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -66306,7 +66473,7 @@ var ts;
66306
66473
  return 0 /* Ternary.False */;
66307
66474
  }
66308
66475
  }
66309
- var isPerformingCommonPropertyChecks = (relation !== comparableRelation || !(source.flags & 1048576 /* TypeFlags.Union */) && isLiteralType(source)) &&
66476
+ var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
66310
66477
  !(intersectionState & 2 /* IntersectionState.Target */) &&
66311
66478
  source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
66312
66479
  target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
@@ -66334,27 +66501,6 @@ var ts;
66334
66501
  var result_7 = skipCaching ?
66335
66502
  unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
66336
66503
  recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
66337
- // For certain combinations involving intersections and optional, excess, or mismatched properties we need
66338
- // an extra property check where the intersection is viewed as a single object. The following are motivating
66339
- // examples that all should be errors, but aren't without this extra property check:
66340
- //
66341
- // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
66342
- //
66343
- // declare let wrong: { a: { y: string } };
66344
- // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
66345
- //
66346
- // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
66347
- // x = y; // Mismatched property in source intersection
66348
- // }
66349
- //
66350
- // We suppress recursive intersection property checks because they can generate lots of work when relating
66351
- // recursive intersections that are structurally similar but not exactly identical. See #37854.
66352
- if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
66353
- isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
66354
- inPropertyCheck = true;
66355
- result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
66356
- inPropertyCheck = false;
66357
- }
66358
66504
  if (result_7) {
66359
66505
  return result_7;
66360
66506
  }
@@ -66466,7 +66612,7 @@ var ts;
66466
66612
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
66467
66613
  checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
66468
66614
  }
66469
- var _loop_21 = function (prop) {
66615
+ var _loop_20 = function (prop) {
66470
66616
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
66471
66617
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
66472
66618
  if (reportErrors) {
@@ -66529,9 +66675,9 @@ var ts;
66529
66675
  };
66530
66676
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
66531
66677
  var prop = _b[_i];
66532
- var state_7 = _loop_21(prop);
66533
- if (typeof state_7 === "object")
66534
- return state_7.value;
66678
+ var state_6 = _loop_20(prop);
66679
+ if (typeof state_6 === "object")
66680
+ return state_6.value;
66535
66681
  }
66536
66682
  return false;
66537
66683
  }
@@ -66752,8 +66898,7 @@ var ts;
66752
66898
  if (overflow) {
66753
66899
  return 0 /* Ternary.False */;
66754
66900
  }
66755
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0);
66756
- var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
66901
+ var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
66757
66902
  var entry = relation.get(id);
66758
66903
  if (entry !== undefined) {
66759
66904
  if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
@@ -66783,7 +66928,7 @@ var ts;
66783
66928
  // A key that starts with "*" is an indication that we have type references that reference constrained
66784
66929
  // type parameters. For such keys we also check against the key we would have gotten if all type parameters
66785
66930
  // were unconstrained.
66786
- var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
66931
+ var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
66787
66932
  for (var i = 0; i < maybeCount; i++) {
66788
66933
  // If source and target are already being compared, consider them related with assumptions
66789
66934
  if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
@@ -66870,7 +67015,7 @@ var ts;
66870
67015
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
66871
67016
  var saveErrorInfo = captureErrorCalculationState();
66872
67017
  var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
66873
- if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
67018
+ if (relation !== identityRelation) {
66874
67019
  // The combined constraint of an intersection type is the intersection of the constraints of
66875
67020
  // the constituents. When an intersection type contains instantiable types with union type
66876
67021
  // constraints, there are situations where we need to examine the combined constraint. One is
@@ -66884,10 +67029,33 @@ var ts;
66884
67029
  // needs to have its constraint hoisted into an intersection with said type parameter, this way
66885
67030
  // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
66886
67031
  // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
66887
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
66888
- if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66889
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66890
- result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
67032
+ if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
67033
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
67034
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
67035
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
67036
+ result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
67037
+ }
67038
+ }
67039
+ // For certain combinations involving intersections and optional, excess, or mismatched properties we need
67040
+ // an extra property check where the intersection is viewed as a single object. The following are motivating
67041
+ // examples that all should be errors, but aren't without this extra property check:
67042
+ //
67043
+ // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
67044
+ //
67045
+ // declare let wrong: { a: { y: string } };
67046
+ // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
67047
+ //
67048
+ // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
67049
+ // x = y; // Mismatched property in source intersection
67050
+ // }
67051
+ //
67052
+ // We suppress recursive intersection property checks because they can generate lots of work when relating
67053
+ // recursive intersections that are structurally similar but not exactly identical. See #37854.
67054
+ if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
67055
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
67056
+ inPropertyCheck = true;
67057
+ result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
67058
+ inPropertyCheck = false;
66891
67059
  }
66892
67060
  }
66893
67061
  if (result) {
@@ -66896,9 +67064,6 @@ var ts;
66896
67064
  return result;
66897
67065
  }
66898
67066
  function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
66899
- if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
66900
- return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
66901
- }
66902
67067
  var result;
66903
67068
  var originalErrorInfo;
66904
67069
  var varianceCheckFailed = false;
@@ -66999,7 +67164,7 @@ var ts;
66999
67164
  // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
67000
67165
  var constraint = getConstraintOfTypeParameter(source);
67001
67166
  if (constraint && hasNonCircularBaseConstraint(source)) {
67002
- while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
67167
+ while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
67003
67168
  if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
67004
67169
  return result;
67005
67170
  }
@@ -67522,11 +67687,11 @@ var ts;
67522
67687
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
67523
67688
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
67524
67689
  var matchingTypes = [];
67525
- var _loop_22 = function (combination) {
67690
+ var _loop_21 = function (combination) {
67526
67691
  var hasMatch = false;
67527
67692
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
67528
67693
  var type = _d[_c];
67529
- var _loop_23 = function (i) {
67694
+ var _loop_22 = function (i) {
67530
67695
  var sourceProperty = sourcePropertiesFiltered[i];
67531
67696
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
67532
67697
  if (!targetProperty)
@@ -67542,8 +67707,8 @@ var ts;
67542
67707
  }
67543
67708
  };
67544
67709
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
67545
- var state_9 = _loop_23(i);
67546
- switch (state_9) {
67710
+ var state_8 = _loop_22(i);
67711
+ switch (state_8) {
67547
67712
  case "continue-outer": continue outer;
67548
67713
  }
67549
67714
  }
@@ -67556,9 +67721,9 @@ var ts;
67556
67721
  };
67557
67722
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
67558
67723
  var combination = discriminantCombinations_1[_a];
67559
- var state_8 = _loop_22(combination);
67560
- if (typeof state_8 === "object")
67561
- return state_8.value;
67724
+ var state_7 = _loop_21(combination);
67725
+ if (typeof state_7 === "object")
67726
+ return state_7.value;
67562
67727
  }
67563
67728
  // Compare the remaining non-discriminant properties of each match.
67564
67729
  var result = -1 /* Ternary.True */;
@@ -67655,7 +67820,7 @@ var ts;
67655
67820
  return 0 /* Ternary.False */;
67656
67821
  }
67657
67822
  // When checking for comparability, be more lenient with optional properties.
67658
- if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67823
+ if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67659
67824
  // TypeScript 1.0 spec (April 2014): 3.8.3
67660
67825
  // S is a subtype of a type T, and T is a supertype of S if ...
67661
67826
  // S' and T are object types and, for each member M in T..
@@ -68263,7 +68428,7 @@ var ts;
68263
68428
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
68264
68429
  links.variances = ts.emptyArray;
68265
68430
  var variances = [];
68266
- var _loop_24 = function (tp) {
68431
+ var _loop_23 = function (tp) {
68267
68432
  var modifiers = getVarianceModifiers(tp);
68268
68433
  var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
68269
68434
  modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
@@ -68301,7 +68466,7 @@ var ts;
68301
68466
  };
68302
68467
  for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
68303
68468
  var tp = typeParameters_2[_i];
68304
- _loop_24(tp);
68469
+ _loop_23(tp);
68305
68470
  }
68306
68471
  links.variances = variances;
68307
68472
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
@@ -68755,8 +68920,7 @@ var ts;
68755
68920
  return !!(type.flags & 109440 /* TypeFlags.Unit */);
68756
68921
  }
68757
68922
  function isUnitLikeType(type) {
68758
- return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) :
68759
- !!(type.flags & 109440 /* TypeFlags.Unit */);
68923
+ return isUnitType(getBaseConstraintOrType(type));
68760
68924
  }
68761
68925
  function extractUnitType(type) {
68762
68926
  return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type;
@@ -69635,7 +69799,7 @@ var ts;
69635
69799
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
69636
69800
  }
69637
69801
  function isMemberOfStringMapping(source, target) {
69638
- if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) {
69802
+ if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
69639
69803
  return true;
69640
69804
  }
69641
69805
  if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
@@ -70259,7 +70423,7 @@ var ts;
70259
70423
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
70260
70424
  // succeed. That would be a pointless and confusing outcome.
70261
70425
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
70262
- var _loop_25 = function (i) {
70426
+ var _loop_24 = function (i) {
70263
70427
  var source_1 = matches ? matches[i] : neverType;
70264
70428
  var target_3 = types[i];
70265
70429
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -70309,7 +70473,7 @@ var ts;
70309
70473
  inferFromTypes(source_1, target_3);
70310
70474
  };
70311
70475
  for (var i = 0; i < types.length; i++) {
70312
- _loop_25(i);
70476
+ _loop_24(i);
70313
70477
  }
70314
70478
  }
70315
70479
  }
@@ -70761,7 +70925,7 @@ var ts;
70761
70925
  }
70762
70926
  if (ts.isEntityNameExpression(node.argumentExpression)) {
70763
70927
  var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
70764
- if (!symbol || !isConstVariable(symbol))
70928
+ if (!symbol || !(isConstVariable(symbol) || (symbol.flags & 8 /* SymbolFlags.EnumMember */)))
70765
70929
  return undefined;
70766
70930
  var declaration = symbol.valueDeclaration;
70767
70931
  if (declaration === undefined)
@@ -70775,7 +70939,12 @@ var ts;
70775
70939
  }
70776
70940
  if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70777
70941
  var initializer = ts.getEffectiveInitializer(declaration);
70778
- return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70942
+ if (initializer) {
70943
+ return tryGetNameFromType(getTypeOfExpression(initializer));
70944
+ }
70945
+ if (ts.isEnumMember(declaration)) {
70946
+ return ts.getTextOfPropertyName(declaration.name);
70947
+ }
70779
70948
  }
70780
70949
  }
70781
70950
  return undefined;
@@ -70833,7 +71002,7 @@ var ts;
70833
71002
  function mapTypesByKeyProperty(types, name) {
70834
71003
  var map = new ts.Map();
70835
71004
  var count = 0;
70836
- var _loop_26 = function (type) {
71005
+ var _loop_25 = function (type) {
70837
71006
  if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
70838
71007
  var discriminant = getTypeOfPropertyOfType(type, name);
70839
71008
  if (discriminant) {
@@ -70859,9 +71028,9 @@ var ts;
70859
71028
  };
70860
71029
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70861
71030
  var type = types_15[_i];
70862
- var state_10 = _loop_26(type);
70863
- if (typeof state_10 === "object")
70864
- return state_10.value;
71031
+ var state_9 = _loop_25(type);
71032
+ if (typeof state_9 === "object")
71033
+ return state_9.value;
70865
71034
  }
70866
71035
  return count >= 10 && count * 2 >= types.length ? map : undefined;
70867
71036
  }
@@ -71458,6 +71627,7 @@ var ts;
71458
71627
  ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
71459
71628
  }
71460
71629
  function getExplicitTypeOfSymbol(symbol, diagnostic) {
71630
+ symbol = resolveSymbol(symbol);
71461
71631
  if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) {
71462
71632
  return getTypeOfSymbol(symbol);
71463
71633
  }
@@ -71496,7 +71666,7 @@ var ts;
71496
71666
  switch (node.kind) {
71497
71667
  case 79 /* SyntaxKind.Identifier */:
71498
71668
  var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
71499
- return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic);
71669
+ return getExplicitTypeOfSymbol(symbol, diagnostic);
71500
71670
  case 108 /* SyntaxKind.ThisKeyword */:
71501
71671
  return getExplicitThisType(node);
71502
71672
  case 106 /* SyntaxKind.SuperKeyword */:
@@ -71983,7 +72153,7 @@ var ts;
71983
72153
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71984
72154
  }
71985
72155
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
71986
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72156
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71987
72157
  }
71988
72158
  else {
71989
72159
  if (strictNullChecks) {
@@ -72264,7 +72434,7 @@ var ts;
72264
72434
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72265
72435
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72266
72436
  }
72267
- function narrowByInKeyword(type, nameType, assumeTrue) {
72437
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72268
72438
  var name = getPropertyNameFromType(nameType);
72269
72439
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72270
72440
  if (isKnownProperty) {
@@ -72345,7 +72515,7 @@ var ts;
72345
72515
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72346
72516
  }
72347
72517
  if (isMatchingReference(reference, target)) {
72348
- return narrowByInKeyword(type, leftType, assumeTrue);
72518
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72349
72519
  }
72350
72520
  }
72351
72521
  break;
@@ -72534,7 +72704,7 @@ var ts;
72534
72704
  neverType;
72535
72705
  });
72536
72706
  }
72537
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72707
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72538
72708
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72539
72709
  if (!witnesses) {
72540
72710
  return type;
@@ -72922,15 +73092,15 @@ var ts;
72922
73092
  });
72923
73093
  }
72924
73094
  function markAliasReferenced(symbol, location) {
72925
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
73095
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
72926
73096
  var target = resolveAlias(symbol);
72927
- if (target.flags & 111551 /* SymbolFlags.Value */) {
73097
+ if (getAllSymbolFlags(target) & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */)) {
72928
73098
  // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
72929
73099
  // (because the const enum value will not be inlined), or if (2) the alias is an export
72930
73100
  // of a const enum declaration that will be preserved.
72931
73101
  if (compilerOptions.isolatedModules ||
72932
73102
  ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) ||
72933
- !isConstEnumOrConstEnumOnlyModule(target)) {
73103
+ !isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
72934
73104
  markAliasSymbolAsReferenced(symbol);
72935
73105
  }
72936
73106
  else {
@@ -73158,7 +73328,7 @@ var ts;
73158
73328
  // We only look for uninitialized variables in strict null checking mode, and only when we can analyze
73159
73329
  // the entire control flow graph from the variable's declaration (i.e. when the flow container and
73160
73330
  // declaration container are the same).
73161
- var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
73331
+ var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
73162
73332
  type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 ||
73163
73333
  isInTypeQuery(node) || node.parent.kind === 278 /* SyntaxKind.ExportSpecifier */) ||
73164
73334
  node.parent.kind === 232 /* SyntaxKind.NonNullExpression */ ||
@@ -73187,6 +73357,12 @@ var ts;
73187
73357
  }
73188
73358
  return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
73189
73359
  }
73360
+ function isSameScopedBindingElement(node, declaration) {
73361
+ if (ts.isBindingElement(declaration)) {
73362
+ var bindingElement = ts.findAncestor(node, ts.isBindingElement);
73363
+ return bindingElement && ts.getRootDeclaration(bindingElement) === ts.getRootDeclaration(declaration);
73364
+ }
73365
+ }
73190
73366
  function shouldMarkIdentifierAliasReferenced(node) {
73191
73367
  var _a;
73192
73368
  var parent = node.parent;
@@ -73528,12 +73704,17 @@ var ts;
73528
73704
  var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
73529
73705
  var container = immediateContainer;
73530
73706
  var needToCaptureLexicalThis = false;
73707
+ var inAsyncFunction = false;
73531
73708
  // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
73532
73709
  if (!isCallExpression) {
73533
73710
  while (container && container.kind === 216 /* SyntaxKind.ArrowFunction */) {
73711
+ if (ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73712
+ inAsyncFunction = true;
73534
73713
  container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
73535
73714
  needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
73536
73715
  }
73716
+ if (container && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73717
+ inAsyncFunction = true;
73537
73718
  }
73538
73719
  var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
73539
73720
  var nodeCheckFlag = 0;
@@ -73639,12 +73820,12 @@ var ts;
73639
73820
  // as a call expression cannot be used as the target of a destructuring assignment while a property access can.
73640
73821
  //
73641
73822
  // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
73642
- if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */)) {
73823
+ if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && inAsyncFunction) {
73643
73824
  if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
73644
- getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */;
73825
+ getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */;
73645
73826
  }
73646
73827
  else {
73647
- getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */;
73828
+ getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */;
73648
73829
  }
73649
73830
  }
73650
73831
  if (needToCaptureLexicalThis) {
@@ -74340,9 +74521,10 @@ var ts;
74340
74521
  function instantiateContextualType(contextualType, node, contextFlags) {
74341
74522
  if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
74342
74523
  var inferenceContext = getInferenceContext(node);
74343
- // If no inferences have been made, nothing is gained from instantiating as type parameters
74344
- // would just be replaced with their defaults similar to the apparent type.
74345
- if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
74524
+ // If no inferences have been made, and none of the type parameters for which we are inferring
74525
+ // specify default types, nothing is gained from instantiating as type parameters would just be
74526
+ // replaced with their constraints similar to the apparent type.
74527
+ if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
74346
74528
  // For contextual signatures we incorporate all inferences made so far, e.g. from return
74347
74529
  // types as well as arguments to the left in a function call.
74348
74530
  return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
@@ -77316,7 +77498,7 @@ var ts;
77316
77498
  if (spreadIndex >= 0) {
77317
77499
  // Create synthetic arguments from spreads of tuple types.
77318
77500
  var effectiveArgs_1 = args.slice(0, spreadIndex);
77319
- var _loop_27 = function (i) {
77501
+ var _loop_26 = function (i) {
77320
77502
  var arg = args[i];
77321
77503
  // We can call checkExpressionCached because spread expressions never have a contextual type.
77322
77504
  var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -77333,7 +77515,7 @@ var ts;
77333
77515
  }
77334
77516
  };
77335
77517
  for (var i = spreadIndex; i < args.length; i++) {
77336
- _loop_27(i);
77518
+ _loop_26(i);
77337
77519
  }
77338
77520
  return effectiveArgs_1;
77339
77521
  }
@@ -77662,7 +77844,7 @@ var ts;
77662
77844
  var min_3 = Number.MAX_VALUE;
77663
77845
  var minIndex = 0;
77664
77846
  var i_1 = 0;
77665
- var _loop_28 = function (c) {
77847
+ var _loop_27 = function (c) {
77666
77848
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
77667
77849
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
77668
77850
  if (diags_2) {
@@ -77680,7 +77862,7 @@ var ts;
77680
77862
  };
77681
77863
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
77682
77864
  var c = candidatesForArgumentError_1[_a];
77683
- _loop_28(c);
77865
+ _loop_27(c);
77684
77866
  }
77685
77867
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
77686
77868
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -77838,7 +78020,7 @@ var ts;
77838
78020
  }
77839
78021
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
77840
78022
  var parameters = [];
77841
- var _loop_29 = function (i) {
78023
+ var _loop_28 = function (i) {
77842
78024
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
77843
78025
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
77844
78026
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -77846,7 +78028,7 @@ var ts;
77846
78028
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
77847
78029
  };
77848
78030
  for (var i = 0; i < maxNonRestParam; i++) {
77849
- _loop_29(i);
78031
+ _loop_28(i);
77850
78032
  }
77851
78033
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
77852
78034
  var flags = 0 /* SignatureFlags.None */;
@@ -78816,7 +78998,7 @@ var ts;
78816
78998
  if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
78817
78999
  symbol = resolveAlias(symbol);
78818
79000
  }
78819
- return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
79001
+ return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78820
79002
  }
78821
79003
  return false;
78822
79004
  }
@@ -79478,7 +79660,17 @@ var ts;
79478
79660
  }
79479
79661
  function isExhaustiveSwitchStatement(node) {
79480
79662
  var links = getNodeLinks(node);
79481
- return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
79663
+ if (links.isExhaustive === undefined) {
79664
+ links.isExhaustive = 0; // Indicate resolution is in process
79665
+ var exhaustive = computeExhaustiveSwitchStatement(node);
79666
+ if (links.isExhaustive === 0) {
79667
+ links.isExhaustive = exhaustive;
79668
+ }
79669
+ }
79670
+ else if (links.isExhaustive === 0) {
79671
+ links.isExhaustive = false; // Resolve circularity to false
79672
+ }
79673
+ return links.isExhaustive;
79482
79674
  }
79483
79675
  function computeExhaustiveSwitchStatement(node) {
79484
79676
  if (node.expression.kind === 218 /* SyntaxKind.TypeOfExpression */) {
@@ -79486,7 +79678,7 @@ var ts;
79486
79678
  if (!witnesses) {
79487
79679
  return false;
79488
79680
  }
79489
- var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression));
79681
+ var operandConstraint = getBaseConstraintOrType(checkExpressionCached(node.expression.expression));
79490
79682
  // Get the not-equal flags for all handled cases.
79491
79683
  var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
79492
79684
  if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) {
@@ -79496,7 +79688,7 @@ var ts;
79496
79688
  // A missing not-equal flag indicates that the type wasn't handled by some case.
79497
79689
  return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
79498
79690
  }
79499
- var type = getTypeOfExpression(node.expression);
79691
+ var type = checkExpressionCached(node.expression);
79500
79692
  if (!isLiteralType(type)) {
79501
79693
  return false;
79502
79694
  }
@@ -81190,6 +81382,9 @@ var ts;
81190
81382
  function hasInferenceCandidates(info) {
81191
81383
  return !!(info.candidates || info.contraCandidates);
81192
81384
  }
81385
+ function hasInferenceCandidatesOrDefault(info) {
81386
+ return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
81387
+ }
81193
81388
  function hasOverlappingInferences(a, b) {
81194
81389
  for (var i = 0; i < a.length; i++) {
81195
81390
  if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
@@ -81891,7 +82086,7 @@ var ts;
81891
82086
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
81892
82087
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
81893
82088
  var indexSignatureMap_1 = new ts.Map();
81894
- var _loop_30 = function (declaration) {
82089
+ var _loop_29 = function (declaration) {
81895
82090
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
81896
82091
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
81897
82092
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -81906,7 +82101,7 @@ var ts;
81906
82101
  };
81907
82102
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
81908
82103
  var declaration = _a[_i];
81909
- _loop_30(declaration);
82104
+ _loop_29(declaration);
81910
82105
  }
81911
82106
  indexSignatureMap_1.forEach(function (entry) {
81912
82107
  if (entry.declarations.length > 1) {
@@ -82183,7 +82378,7 @@ var ts;
82183
82378
  }
82184
82379
  var symbol = getNodeLinks(node).resolvedSymbol;
82185
82380
  if (symbol) {
82186
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
82381
+ if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
82187
82382
  addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
82188
82383
  }
82189
82384
  if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
@@ -82786,7 +82981,7 @@ var ts;
82786
82981
  return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
82787
82982
  }
82788
82983
  // primitives with a `{ then() }` won't be unwrapped/adopted.
82789
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82984
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82790
82985
  return undefined;
82791
82986
  }
82792
82987
  var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
@@ -82853,7 +83048,7 @@ var ts;
82853
83048
  * Determines whether a type is an object with a callable `then` member.
82854
83049
  */
82855
83050
  function isThenableType(type) {
82856
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
83051
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82857
83052
  // primitive types cannot be considered "thenable" since they are not objects.
82858
83053
  return false;
82859
83054
  }
@@ -82887,7 +83082,7 @@ var ts;
82887
83082
  // We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82888
83083
  // or is promise-like.
82889
83084
  if (baseConstraint ?
82890
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83085
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
82891
83086
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
82892
83087
  return true;
82893
83088
  }
@@ -83561,7 +83756,7 @@ var ts;
83561
83756
  }
83562
83757
  function errorUnusedLocal(declaration, name, addDiagnostic) {
83563
83758
  var node = ts.getNameOfDeclaration(declaration) || declaration;
83564
- var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
83759
+ var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
83565
83760
  addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
83566
83761
  }
83567
83762
  function isIdentifierThatStartsWithUnderscore(node) {
@@ -84991,7 +85186,16 @@ var ts;
84991
85186
  var message = allowAsyncIterables
84992
85187
  ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
84993
85188
  : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
84994
- return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
85189
+ var suggestAwait =
85190
+ // for (const x of Promise<...>) or [...Promise<...>]
85191
+ !!getAwaitedTypeOfPromise(type)
85192
+ // for (const x of AsyncIterable<...>)
85193
+ || (!allowAsyncIterables &&
85194
+ ts.isForOfStatement(errorNode.parent) &&
85195
+ errorNode.parent.expression === errorNode &&
85196
+ getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
85197
+ isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
85198
+ return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
84995
85199
  }
84996
85200
  /**
84997
85201
  * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
@@ -85506,7 +85710,7 @@ var ts;
85506
85710
  var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
85507
85711
  name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
85508
85712
  var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
85509
- var _loop_31 = function (info) {
85713
+ var _loop_30 = function (info) {
85510
85714
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
85511
85715
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
85512
85716
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -85523,7 +85727,7 @@ var ts;
85523
85727
  };
85524
85728
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
85525
85729
  var info = indexInfos_9[_i];
85526
- _loop_31(info);
85730
+ _loop_30(info);
85527
85731
  }
85528
85732
  }
85529
85733
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -85531,7 +85735,7 @@ var ts;
85531
85735
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
85532
85736
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
85533
85737
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
85534
- var _loop_32 = function (info) {
85738
+ var _loop_31 = function (info) {
85535
85739
  if (info === checkInfo)
85536
85740
  return "continue";
85537
85741
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -85546,7 +85750,7 @@ var ts;
85546
85750
  };
85547
85751
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
85548
85752
  var info = indexInfos_10[_i];
85549
- _loop_32(info);
85753
+ _loop_31(info);
85550
85754
  }
85551
85755
  }
85552
85756
  function checkTypeNameIsReserved(name, message) {
@@ -85601,7 +85805,7 @@ var ts;
85601
85805
  }
85602
85806
  else {
85603
85807
  ts.forEach(jsdocParameters, function (_a, index) {
85604
- var name = _a.name;
85808
+ var name = _a.name, isNameFirst = _a.isNameFirst;
85605
85809
  if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
85606
85810
  return;
85607
85811
  }
@@ -85611,7 +85815,9 @@ var ts;
85611
85815
  }
85612
85816
  }
85613
85817
  else {
85614
- errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
85818
+ if (!isNameFirst) {
85819
+ errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
85820
+ }
85615
85821
  }
85616
85822
  });
85617
85823
  }
@@ -85866,7 +86072,7 @@ var ts;
85866
86072
  var baseTypes = baseTypeNode && getBaseTypes(type);
85867
86073
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
85868
86074
  var baseStaticType = getBaseConstructorTypeOfClass(type);
85869
- var _loop_33 = function (member) {
86075
+ var _loop_32 = function (member) {
85870
86076
  if (ts.hasAmbientModifier(member)) {
85871
86077
  return "continue";
85872
86078
  }
@@ -85883,7 +86089,7 @@ var ts;
85883
86089
  };
85884
86090
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85885
86091
  var member = _a[_i];
85886
- _loop_33(member);
86092
+ _loop_32(member);
85887
86093
  }
85888
86094
  }
85889
86095
  /**
@@ -85971,7 +86177,7 @@ var ts;
85971
86177
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
85972
86178
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
85973
86179
  var issuedMemberError = false;
85974
- var _loop_34 = function (member) {
86180
+ var _loop_33 = function (member) {
85975
86181
  if (ts.isStatic(member)) {
85976
86182
  return "continue";
85977
86183
  }
@@ -85990,7 +86196,7 @@ var ts;
85990
86196
  };
85991
86197
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85992
86198
  var member = _a[_i];
85993
- _loop_34(member);
86199
+ _loop_33(member);
85994
86200
  }
85995
86201
  if (!issuedMemberError) {
85996
86202
  // check again with diagnostics to generate a less-specific error
@@ -86061,7 +86267,7 @@ var ts;
86061
86267
  var _a, _b, _c, _d;
86062
86268
  // NOTE: assignability is checked in checkClassDeclaration
86063
86269
  var baseProperties = getPropertiesOfType(baseType);
86064
- var _loop_35 = function (baseProperty) {
86270
+ var _loop_34 = function (baseProperty) {
86065
86271
  var base = getTargetSymbol(baseProperty);
86066
86272
  if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
86067
86273
  return "continue";
@@ -86171,8 +86377,8 @@ var ts;
86171
86377
  };
86172
86378
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
86173
86379
  var baseProperty = baseProperties_1[_i];
86174
- var state_11 = _loop_35(baseProperty);
86175
- switch (state_11) {
86380
+ var state_10 = _loop_34(baseProperty);
86381
+ switch (state_10) {
86176
86382
  case "continue-basePropertyCheck": continue basePropertyCheck;
86177
86383
  }
86178
86384
  }
@@ -86691,12 +86897,11 @@ var ts;
86691
86897
  }
86692
86898
  }
86693
86899
  function checkModuleAugmentationElement(node, isGlobalAugmentation) {
86694
- var _a;
86695
86900
  switch (node.kind) {
86696
86901
  case 240 /* SyntaxKind.VariableStatement */:
86697
86902
  // error each individual name in variable statement instead of marking the entire variable statement
86698
- for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) {
86699
- var decl = _b[_i];
86903
+ for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
86904
+ var decl = _a[_i];
86700
86905
  checkModuleAugmentationElement(decl, isGlobalAugmentation);
86701
86906
  }
86702
86907
  break;
@@ -86712,8 +86917,8 @@ var ts;
86712
86917
  case 257 /* SyntaxKind.VariableDeclaration */:
86713
86918
  var name = node.name;
86714
86919
  if (ts.isBindingPattern(name)) {
86715
- for (var _c = 0, _d = name.elements; _c < _d.length; _c++) {
86716
- var el = _d[_c];
86920
+ for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
86921
+ var el = _c[_b];
86717
86922
  // mark individual names in binding pattern
86718
86923
  checkModuleAugmentationElement(el, isGlobalAugmentation);
86719
86924
  }
@@ -86729,18 +86934,6 @@ var ts;
86729
86934
  if (isGlobalAugmentation) {
86730
86935
  return;
86731
86936
  }
86732
- var symbol = getSymbolOfNode(node);
86733
- if (symbol) {
86734
- // module augmentations cannot introduce new names on the top level scope of the module
86735
- // this is done it two steps
86736
- // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error
86737
- // 2. main check - report error if value declaration of the parent symbol is module augmentation)
86738
- var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */);
86739
- if (!reportError) {
86740
- // symbol should not originate in augmentation
86741
- reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
86742
- }
86743
- }
86744
86937
  break;
86745
86938
  }
86746
86939
  }
@@ -86842,10 +87035,11 @@ var ts;
86842
87035
  }
86843
87036
  return;
86844
87037
  }
87038
+ var targetFlags = getAllSymbolFlags(target);
86845
87039
  var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
86846
87040
  (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
86847
87041
  (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
86848
- if (target.flags & excludedMeanings) {
87042
+ if (targetFlags & excludedMeanings) {
86849
87043
  var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
86850
87044
  ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
86851
87045
  ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
@@ -86855,7 +87049,7 @@ var ts;
86855
87049
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
86856
87050
  && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
86857
87051
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
86858
- var isType = !(target.flags & 111551 /* SymbolFlags.Value */);
87052
+ var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
86859
87053
  if (isType || typeOnlyAlias) {
86860
87054
  switch (node.kind) {
86861
87055
  case 270 /* SyntaxKind.ImportClause */:
@@ -87015,14 +87209,15 @@ var ts;
87015
87209
  if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
87016
87210
  var target = resolveAlias(getSymbolOfNode(node));
87017
87211
  if (target !== unknownSymbol) {
87018
- if (target.flags & 111551 /* SymbolFlags.Value */) {
87212
+ var targetFlags = getAllSymbolFlags(target);
87213
+ if (targetFlags & 111551 /* SymbolFlags.Value */) {
87019
87214
  // Target is a value symbol, check that it is not hidden by a local declaration with the same name
87020
87215
  var moduleName = ts.getFirstIdentifier(node.moduleReference);
87021
87216
  if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
87022
87217
  error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
87023
87218
  }
87024
87219
  }
87025
- if (target.flags & 788968 /* SymbolFlags.Type */) {
87220
+ if (targetFlags & 788968 /* SymbolFlags.Type */) {
87026
87221
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
87027
87222
  }
87028
87223
  }
@@ -87161,7 +87356,7 @@ var ts;
87161
87356
  markExportAsReferenced(node);
87162
87357
  }
87163
87358
  var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
87164
- if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87359
+ if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87165
87360
  checkExpressionCached(node.propertyName || node.name);
87166
87361
  }
87167
87362
  }
@@ -87208,7 +87403,7 @@ var ts;
87208
87403
  markAliasReferenced(sym, id);
87209
87404
  // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
87210
87405
  var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
87211
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87406
+ if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87212
87407
  // However if it is a value, we need to check it's being used correctly
87213
87408
  checkExpressionCached(node.expression);
87214
87409
  }
@@ -87880,29 +88075,9 @@ var ts;
87880
88075
  }
87881
88076
  function isTypeDeclarationName(name) {
87882
88077
  return name.kind === 79 /* SyntaxKind.Identifier */ &&
87883
- isTypeDeclaration(name.parent) &&
88078
+ ts.isTypeDeclaration(name.parent) &&
87884
88079
  ts.getNameOfDeclaration(name.parent) === name;
87885
88080
  }
87886
- function isTypeDeclaration(node) {
87887
- switch (node.kind) {
87888
- case 165 /* SyntaxKind.TypeParameter */:
87889
- case 260 /* SyntaxKind.ClassDeclaration */:
87890
- case 261 /* SyntaxKind.InterfaceDeclaration */:
87891
- case 262 /* SyntaxKind.TypeAliasDeclaration */:
87892
- case 263 /* SyntaxKind.EnumDeclaration */:
87893
- case 348 /* SyntaxKind.JSDocTypedefTag */:
87894
- case 341 /* SyntaxKind.JSDocCallbackTag */:
87895
- case 342 /* SyntaxKind.JSDocEnumTag */:
87896
- return true;
87897
- case 270 /* SyntaxKind.ImportClause */:
87898
- return node.isTypeOnly;
87899
- case 273 /* SyntaxKind.ImportSpecifier */:
87900
- case 278 /* SyntaxKind.ExportSpecifier */:
87901
- return node.parent.parent.isTypeOnly;
87902
- default:
87903
- return false;
87904
- }
87905
- }
87906
88081
  // True if the given identifier is part of a type reference
87907
88082
  function isTypeReferenceIdentifier(node) {
87908
88083
  while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
@@ -88335,7 +88510,7 @@ var ts;
88335
88510
  var baseType = ts.firstOrUndefined(getBaseTypes(classType));
88336
88511
  return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
88337
88512
  }
88338
- if (isTypeDeclaration(node)) {
88513
+ if (ts.isTypeDeclaration(node)) {
88339
88514
  // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
88340
88515
  var symbol = getSymbolOfNode(node);
88341
88516
  return getDeclaredTypeOfSymbol(symbol);
@@ -88530,7 +88705,7 @@ var ts;
88530
88705
  return symbolLinks.exportsSomeValue;
88531
88706
  function isValue(s) {
88532
88707
  s = resolveSymbol(s);
88533
- return s && !!(s.flags & 111551 /* SymbolFlags.Value */);
88708
+ return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
88534
88709
  }
88535
88710
  }
88536
88711
  function isNameOfModuleOrEnumDeclaration(node) {
@@ -88583,7 +88758,7 @@ var ts;
88583
88758
  var symbol = getReferencedValueOrAliasSymbol(node);
88584
88759
  // We should only get the declaration of an alias if there isn't a local value
88585
88760
  // declaration for the symbol
88586
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
88761
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
88587
88762
  return getDeclarationOfAliasSymbol(symbol);
88588
88763
  }
88589
88764
  }
@@ -88671,7 +88846,7 @@ var ts;
88671
88846
  case 273 /* SyntaxKind.ImportSpecifier */:
88672
88847
  case 278 /* SyntaxKind.ExportSpecifier */:
88673
88848
  var symbol = getSymbolOfNode(node);
88674
- return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
88849
+ return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
88675
88850
  case 275 /* SyntaxKind.ExportDeclaration */:
88676
88851
  var exportClause = node.exportClause;
88677
88852
  return !!exportClause && (ts.isNamespaceExport(exportClause) ||
@@ -88693,6 +88868,7 @@ var ts;
88693
88868
  return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
88694
88869
  }
88695
88870
  function isAliasResolvedToValue(symbol) {
88871
+ var _a;
88696
88872
  if (!symbol) {
88697
88873
  return false;
88698
88874
  }
@@ -88702,7 +88878,7 @@ var ts;
88702
88878
  }
88703
88879
  // const enums and modules that contain only const enums are not considered values from the emit perspective
88704
88880
  // unless 'preserveConstEnums' option is set to true
88705
- return !!(target.flags & 111551 /* SymbolFlags.Value */) &&
88881
+ return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
88706
88882
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
88707
88883
  }
88708
88884
  function isConstEnumOrConstEnumOnlyModule(s) {
@@ -88717,7 +88893,7 @@ var ts;
88717
88893
  }
88718
88894
  var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
88719
88895
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
88720
- target.flags & 111551 /* SymbolFlags.Value */ &&
88896
+ getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
88721
88897
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
88722
88898
  // An `export import ... =` of a value symbol is always considered referenced
88723
88899
  return true;
@@ -98371,8 +98547,11 @@ var ts;
98371
98547
  }
98372
98548
  return ts.visitEachChild(node, visitor, context);
98373
98549
  case 174 /* SyntaxKind.GetAccessor */:
98550
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitGetAccessorDeclaration, node);
98374
98551
  case 175 /* SyntaxKind.SetAccessor */:
98552
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitSetAccessorDeclaration, node);
98375
98553
  case 173 /* SyntaxKind.Constructor */:
98554
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitConstructorDeclaration, node);
98376
98555
  case 260 /* SyntaxKind.ClassDeclaration */:
98377
98556
  case 228 /* SyntaxKind.ClassExpression */:
98378
98557
  return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
@@ -98473,6 +98652,9 @@ var ts;
98473
98652
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
98474
98653
  /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
98475
98654
  }
98655
+ function visitConstructorDeclaration(node) {
98656
+ return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98657
+ }
98476
98658
  /**
98477
98659
  * Visits a MethodDeclaration node.
98478
98660
  *
@@ -98487,7 +98669,14 @@ var ts;
98487
98669
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
98488
98670
  /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
98489
98671
  ? transformAsyncFunctionBody(node)
98490
- : ts.visitFunctionBody(node.body, visitor, context));
98672
+ : transformMethodBody(node));
98673
+ }
98674
+ function visitGetAccessorDeclaration(node) {
98675
+ return factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context),
98676
+ /*type*/ undefined, transformMethodBody(node));
98677
+ }
98678
+ function visitSetAccessorDeclaration(node) {
98679
+ return factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98491
98680
  }
98492
98681
  /**
98493
98682
  * Visits a FunctionDeclaration node.
@@ -98601,6 +98790,42 @@ var ts;
98601
98790
  }
98602
98791
  return false;
98603
98792
  }
98793
+ function transformMethodBody(node) {
98794
+ ts.Debug.assertIsDefined(node.body);
98795
+ var savedCapturedSuperProperties = capturedSuperProperties;
98796
+ var savedHasSuperElementAccess = hasSuperElementAccess;
98797
+ capturedSuperProperties = new ts.Set();
98798
+ hasSuperElementAccess = false;
98799
+ var updated = ts.visitFunctionBody(node.body, visitor, context);
98800
+ // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98801
+ // This step isn't needed if we eventually transform this to ES5.
98802
+ var originalMethod = ts.getOriginalNode(node, ts.isFunctionLikeDeclaration);
98803
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ &&
98804
+ resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) &&
98805
+ (ts.getFunctionFlags(originalMethod) & 3 /* FunctionFlags.AsyncGenerator */) !== 3 /* FunctionFlags.AsyncGenerator */;
98806
+ if (emitSuperHelpers) {
98807
+ enableSubstitutionForAsyncMethodsWithSuper();
98808
+ if (capturedSuperProperties.size) {
98809
+ var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
98810
+ substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
98811
+ var statements = updated.statements.slice();
98812
+ ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
98813
+ updated = factory.updateBlock(updated, statements);
98814
+ }
98815
+ if (hasSuperElementAccess) {
98816
+ // Emit helpers for super element access expressions (`super[x]`).
98817
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98818
+ ts.addEmitHelper(updated, ts.advancedAsyncSuperHelper);
98819
+ }
98820
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98821
+ ts.addEmitHelper(updated, ts.asyncSuperHelper);
98822
+ }
98823
+ }
98824
+ }
98825
+ capturedSuperProperties = savedCapturedSuperProperties;
98826
+ hasSuperElementAccess = savedHasSuperElementAccess;
98827
+ return updated;
98828
+ }
98604
98829
  function transformAsyncFunctionBody(node) {
98605
98830
  resumeLexicalEnvironment();
98606
98831
  var original = ts.getOriginalNode(node, ts.isFunctionLike);
@@ -98633,7 +98858,7 @@ var ts;
98633
98858
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
98634
98859
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98635
98860
  // This step isn't needed if we eventually transform this to ES5.
98636
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
98861
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
98637
98862
  if (emitSuperHelpers) {
98638
98863
  enableSubstitutionForAsyncMethodsWithSuper();
98639
98864
  if (capturedSuperProperties.size) {
@@ -98646,10 +98871,10 @@ var ts;
98646
98871
  ts.setTextRange(block, node.body);
98647
98872
  if (emitSuperHelpers && hasSuperElementAccess) {
98648
98873
  // Emit helpers for super element access expressions (`super[x]`).
98649
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
98874
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98650
98875
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
98651
98876
  }
98652
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
98877
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98653
98878
  ts.addEmitHelper(block, ts.asyncSuperHelper);
98654
98879
  }
98655
98880
  }
@@ -98721,7 +98946,7 @@ var ts;
98721
98946
  // If we need to support substitutions for `super` in an async method,
98722
98947
  // we should track it here.
98723
98948
  if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
98724
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
98949
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
98725
98950
  if (superContainerFlags !== enclosingSuperContainerFlags) {
98726
98951
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
98727
98952
  enclosingSuperContainerFlags = superContainerFlags;
@@ -98798,7 +99023,7 @@ var ts;
98798
99023
  || kind === 175 /* SyntaxKind.SetAccessor */;
98799
99024
  }
98800
99025
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
98801
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99026
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98802
99027
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
98803
99028
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
98804
99029
  }
@@ -98813,7 +99038,7 @@ var ts;
98813
99038
  function createSuperAccessVariableStatement(factory, resolver, node, names) {
98814
99039
  // Create a variable declaration with a getter/setter (if binding) definition for each name:
98815
99040
  // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
98816
- var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0;
99041
+ var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) !== 0;
98817
99042
  var accessors = [];
98818
99043
  names.forEach(function (_, key) {
98819
99044
  var name = ts.unescapeLeadingUnderscores(key);
@@ -99306,11 +99531,22 @@ var ts;
99306
99531
  }
99307
99532
  return node;
99308
99533
  }
99309
- function convertForOfStatementHead(node, boundValue) {
99310
- var binding = ts.createForOfBindingStatement(factory, node.initializer, boundValue);
99534
+ function convertForOfStatementHead(node, boundValue, nonUserCode) {
99535
+ var value = factory.createTempVariable(hoistVariableDeclaration);
99536
+ var iteratorValueExpression = factory.createAssignment(value, boundValue);
99537
+ var iteratorValueStatement = factory.createExpressionStatement(iteratorValueExpression);
99538
+ ts.setSourceMapRange(iteratorValueStatement, node.expression);
99539
+ var exitNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createFalse());
99540
+ var exitNonUserCodeStatement = factory.createExpressionStatement(exitNonUserCodeExpression);
99541
+ ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
99542
+ var enterNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createTrue());
99543
+ var enterNonUserCodeStatement = factory.createExpressionStatement(enterNonUserCodeExpression);
99544
+ ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
99545
+ var statements = [];
99546
+ var binding = ts.createForOfBindingStatement(factory, node.initializer, value);
99547
+ statements.push(ts.visitNode(binding, visitor, ts.isStatement));
99311
99548
  var bodyLocation;
99312
99549
  var statementsLocation;
99313
- var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
99314
99550
  var statement = ts.visitIterationBody(node.statement, visitor, context);
99315
99551
  if (ts.isBlock(statement)) {
99316
99552
  ts.addRange(statements, statement.statements);
@@ -99320,8 +99556,16 @@ var ts;
99320
99556
  else {
99321
99557
  statements.push(statement);
99322
99558
  }
99323
- return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
99559
+ var body = ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
99324
99560
  /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */);
99561
+ return factory.createBlock([
99562
+ iteratorValueStatement,
99563
+ exitNonUserCodeStatement,
99564
+ factory.createTryStatement(body,
99565
+ /*catchClause*/ undefined, factory.createBlock([
99566
+ enterNonUserCodeStatement
99567
+ ]))
99568
+ ]);
99325
99569
  }
99326
99570
  function createDownlevelAwait(expression) {
99327
99571
  return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
@@ -99332,6 +99576,8 @@ var ts;
99332
99576
  var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
99333
99577
  var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined);
99334
99578
  var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(/*recordTempVariable*/ undefined);
99579
+ var nonUserCode = factory.createTempVariable(/*recordTempVariable*/ undefined);
99580
+ var done = factory.createTempVariable(hoistVariableDeclaration);
99335
99581
  var errorRecord = factory.createUniqueName("e");
99336
99582
  var catchVariable = factory.getGeneratedNameForNode(errorRecord);
99337
99583
  var returnMethod = factory.createTempVariable(/*recordTempVariable*/ undefined);
@@ -99348,12 +99594,17 @@ var ts;
99348
99594
  callValues;
99349
99595
  var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(
99350
99596
  /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
99597
+ factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
99351
99598
  ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
99352
99599
  factory.createVariableDeclaration(result)
99353
99600
  ]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
99354
- /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)),
99601
+ /*condition*/ factory.inlineExpressions([
99602
+ factory.createAssignment(result, createDownlevelAwait(callNext)),
99603
+ factory.createAssignment(done, getDone),
99604
+ factory.createLogicalNot(done)
99605
+ ]),
99355
99606
  /*incrementor*/ undefined,
99356
- /*statement*/ convertForOfStatementHead(node, getValue)),
99607
+ /*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)),
99357
99608
  /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
99358
99609
  ts.setOriginalNode(forStatement, node);
99359
99610
  return factory.createTryStatement(factory.createBlock([
@@ -99365,7 +99616,7 @@ var ts;
99365
99616
  ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([
99366
99617
  factory.createTryStatement(
99367
99618
  /*tryBlock*/ factory.createBlock([
99368
- ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */)
99619
+ ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(factory.createLogicalNot(nonUserCode), factory.createLogicalNot(done)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */)
99369
99620
  ]),
99370
99621
  /*catchClause*/ undefined,
99371
99622
  /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([
@@ -99521,7 +99772,7 @@ var ts;
99521
99772
  /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
99522
99773
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
99523
99774
  // This step isn't needed if we eventually transform this to ES5.
99524
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
99775
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
99525
99776
  if (emitSuperHelpers) {
99526
99777
  enableSubstitutionForAsyncMethodsWithSuper();
99527
99778
  var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
@@ -99532,10 +99783,10 @@ var ts;
99532
99783
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
99533
99784
  var block = factory.updateBlock(node.body, statements);
99534
99785
  if (emitSuperHelpers && hasSuperElementAccess) {
99535
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99786
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99536
99787
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
99537
99788
  }
99538
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
99789
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
99539
99790
  ts.addEmitHelper(block, ts.asyncSuperHelper);
99540
99791
  }
99541
99792
  }
@@ -99664,7 +99915,7 @@ var ts;
99664
99915
  // If we need to support substitutions for `super` in an async method,
99665
99916
  // we should track it here.
99666
99917
  if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
99667
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
99918
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
99668
99919
  if (superContainerFlags !== enclosingSuperContainerFlags) {
99669
99920
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
99670
99921
  enclosingSuperContainerFlags = superContainerFlags;
@@ -99741,7 +99992,7 @@ var ts;
99741
99992
  || kind === 175 /* SyntaxKind.SetAccessor */;
99742
99993
  }
99743
99994
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
99744
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99995
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99745
99996
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
99746
99997
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
99747
99998
  }
@@ -101210,11 +101461,13 @@ var ts;
101210
101461
  return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
101211
101462
  }
101212
101463
  function visitIdentifier(node) {
101213
- if (!convertedLoopState) {
101214
- return node;
101464
+ if (convertedLoopState) {
101465
+ if (resolver.isArgumentsLocalBinding(node)) {
101466
+ return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101467
+ }
101215
101468
  }
101216
- if (resolver.isArgumentsLocalBinding(node)) {
101217
- return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101469
+ if (node.hasExtendedUnicodeEscape) {
101470
+ return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
101218
101471
  }
101219
101472
  return node;
101220
101473
  }
@@ -105361,7 +105614,6 @@ var ts;
105361
105614
  return node;
105362
105615
  }
105363
105616
  function transformAndEmitForInStatement(node) {
105364
- // TODO(rbuckton): Source map locations
105365
105617
  if (containsYield(node)) {
105366
105618
  // [source]
105367
105619
  // for (var p in o) {
@@ -105369,34 +105621,41 @@ var ts;
105369
105621
  // }
105370
105622
  //
105371
105623
  // [intermediate]
105372
- // .local _a, _b, _i
105373
- // _a = [];
105374
- // for (_b in o) _a.push(_b);
105624
+ // .local _b, _a, _c, _i
105625
+ // _b = [];
105626
+ // _a = o;
105627
+ // for (_c in _a) _b.push(_c);
105375
105628
  // _i = 0;
105376
105629
  // .loop incrementLabel, endLoopLabel
105377
105630
  // .mark conditionLabel
105378
- // .brfalse endLoopLabel, (_i < _a.length)
105379
- // p = _a[_i];
105631
+ // .brfalse endLoopLabel, (_i < _b.length)
105632
+ // _c = _b[_i];
105633
+ // .brfalse incrementLabel, (_c in _a)
105634
+ // p = _c;
105380
105635
  // /*body*/
105381
105636
  // .mark incrementLabel
105382
- // _b++;
105637
+ // _c++;
105383
105638
  // .br conditionLabel
105384
105639
  // .endloop
105385
105640
  // .mark endLoopLabel
105386
- var keysArray = declareLocal(); // _a
105387
- var key = declareLocal(); // _b
105641
+ var obj = declareLocal(); // _a
105642
+ var keysArray = declareLocal(); // _b
105643
+ var key = declareLocal(); // _c
105388
105644
  var keysIndex = factory.createLoopVariable(); // _i
105389
105645
  var initializer = node.initializer;
105390
105646
  hoistVariableDeclaration(keysIndex);
105647
+ emitAssignment(obj, ts.visitNode(node.expression, visitor, ts.isExpression));
105391
105648
  emitAssignment(keysArray, factory.createArrayLiteralExpression());
105392
- emitStatement(factory.createForInStatement(key, ts.visitNode(node.expression, visitor, ts.isExpression), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
105649
+ emitStatement(factory.createForInStatement(key, obj, factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
105393
105650
  /*typeArguments*/ undefined, [key]))));
105394
105651
  emitAssignment(keysIndex, factory.createNumericLiteral(0));
105395
105652
  var conditionLabel = defineLabel();
105396
105653
  var incrementLabel = defineLabel();
105397
- var endLabel = beginLoopBlock(incrementLabel);
105654
+ var endLoopLabel = beginLoopBlock(incrementLabel);
105398
105655
  markLabel(conditionLabel);
105399
- emitBreakWhenFalse(endLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
105656
+ emitBreakWhenFalse(endLoopLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
105657
+ emitAssignment(key, factory.createElementAccessExpression(keysArray, keysIndex));
105658
+ emitBreakWhenFalse(incrementLabel, factory.createBinaryExpression(key, 101 /* SyntaxKind.InKeyword */, obj));
105400
105659
  var variable = void 0;
105401
105660
  if (ts.isVariableDeclarationList(initializer)) {
105402
105661
  for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
@@ -105409,7 +105668,7 @@ var ts;
105409
105668
  variable = ts.visitNode(initializer, visitor, ts.isExpression);
105410
105669
  ts.Debug.assert(ts.isLeftHandSideExpression(variable));
105411
105670
  }
105412
- emitAssignment(variable, factory.createElementAccessExpression(keysArray, keysIndex));
105671
+ emitAssignment(variable, key);
105413
105672
  transformAndEmitEmbeddedStatement(node.statement);
105414
105673
  markLabel(incrementLabel);
105415
105674
  emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
@@ -107250,7 +107509,7 @@ var ts;
107250
107509
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107251
107510
  case ts.ModuleKind.CommonJS:
107252
107511
  default:
107253
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107512
+ return createImportCallExpressionCommonJS(argument);
107254
107513
  }
107255
107514
  }
107256
107515
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107273,7 +107532,7 @@ var ts;
107273
107532
  return factory.createConditionalExpression(
107274
107533
  /*condition*/ factory.createIdentifier("__syncRequire"),
107275
107534
  /*questionToken*/ undefined,
107276
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107535
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107277
107536
  /*colonToken*/ undefined,
107278
107537
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107279
107538
  }
@@ -107282,7 +107541,7 @@ var ts;
107282
107541
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107283
107542
  /*condition*/ factory.createIdentifier("__syncRequire"),
107284
107543
  /*questionToken*/ undefined,
107285
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107544
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107286
107545
  /*colonToken*/ undefined,
107287
107546
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107288
107547
  }
@@ -107332,14 +107591,20 @@ var ts;
107332
107591
  }
107333
107592
  return promise;
107334
107593
  }
107335
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107336
- // import("./blah")
107594
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107595
+ // import(x)
107337
107596
  // emit as
107338
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107597
+ // var _a;
107598
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107339
107599
  // We have to wrap require in then callback so that require is done in asynchronously
107340
107600
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107341
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107342
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107601
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107602
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107603
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107604
+ /*typeArguments*/ undefined,
107605
+ /*argumentsArray*/ []);
107606
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107607
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107343
107608
  if (ts.getESModuleInterop(compilerOptions)) {
107344
107609
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107345
107610
  }
@@ -107360,14 +107625,9 @@ var ts;
107360
107625
  /*typeParameters*/ undefined,
107361
107626
  /*parameters*/ [],
107362
107627
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107363
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107364
- // that this new function expression indicates it captures 'this' so that the
107365
- // es2015 transformer will properly substitute 'this' with '_this'.
107366
- if (containsLexicalThis) {
107367
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107368
- }
107369
107628
  }
107370
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107629
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107630
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107371
107631
  }
107372
107632
  function getHelperExpressionForExport(node, innerExpr) {
107373
107633
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
@@ -118360,14 +118620,16 @@ var ts;
118360
118620
  }
118361
118621
  return setReadFileCache(key, fileName);
118362
118622
  };
118363
- var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
118623
+ var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
118364
118624
  var key = toPath(fileName);
118365
- var value = sourceFileCache.get(key);
118625
+ var impliedNodeFormat = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.impliedNodeFormat : undefined;
118626
+ var forImpliedNodeFormat = sourceFileCache.get(impliedNodeFormat);
118627
+ var value = forImpliedNodeFormat === null || forImpliedNodeFormat === void 0 ? void 0 : forImpliedNodeFormat.get(key);
118366
118628
  if (value)
118367
118629
  return value;
118368
- var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
118630
+ var sourceFile = getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
118369
118631
  if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) {
118370
- sourceFileCache.set(key, sourceFile);
118632
+ sourceFileCache.set(impliedNodeFormat, (forImpliedNodeFormat || new ts.Map()).set(key, sourceFile));
118371
118633
  }
118372
118634
  return sourceFile;
118373
118635
  } : undefined;
@@ -118392,13 +118654,15 @@ var ts;
118392
118654
  var value = readFileCache.get(key);
118393
118655
  if (value !== undefined && value !== data) {
118394
118656
  readFileCache.delete(key);
118395
- sourceFileCache.delete(key);
118657
+ sourceFileCache.forEach(function (map) { return map.delete(key); });
118396
118658
  }
118397
118659
  else if (getSourceFileWithCache) {
118398
- var sourceFile = sourceFileCache.get(key);
118399
- if (sourceFile && sourceFile.text !== data) {
118400
- sourceFileCache.delete(key);
118401
- }
118660
+ sourceFileCache.forEach(function (map) {
118661
+ var sourceFile = map.get(key);
118662
+ if (sourceFile && sourceFile.text !== data) {
118663
+ map.delete(key);
118664
+ }
118665
+ });
118402
118666
  }
118403
118667
  originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
118404
118668
  };
@@ -122540,10 +122804,16 @@ var ts;
122540
122804
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
122541
122805
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
122542
122806
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122807
+ // We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged,
122808
+ // which will eg be depedent on change in options like declarationDir and outDir options are unchanged.
122809
+ // We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because
122810
+ // oldCompilerOptions can be undefined if there was change in say module from None to some other option
122811
+ // which would make useOldState as false since we can now use reference maps that are needed to track what to emit, what to check etc
122812
+ // but that option change does not affect d.ts file name so emitSignatures should still be reused.
122543
122813
  var canCopyEmitSignatures = compilerOptions.composite &&
122544
122814
  (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
122545
122815
  !outFilePath &&
122546
- !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
122816
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122547
122817
  if (useOldState) {
122548
122818
  // Copy old state's changed files set
122549
122819
  (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
@@ -123089,7 +123359,8 @@ var ts;
123089
123359
  for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
123090
123360
  var path = _c[_b];
123091
123361
  if (ts.tryAddToSet(seenFiles, path)) {
123092
- (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]);
123362
+ var fileId = toFileId(path), emitKind = state.affectedFilesPendingEmitKind.get(path);
123363
+ (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push(emitKind === 1 /* BuilderFileEmit.Full */ ? fileId : [fileId]);
123093
123364
  }
123094
123365
  }
123095
123366
  }
@@ -123568,6 +123839,10 @@ var ts;
123568
123839
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
123569
123840
  }
123570
123841
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
123842
+ function toBuilderFileEmit(value) {
123843
+ return ts.isNumber(value) ? 1 /* BuilderFileEmit.Full */ : 0 /* BuilderFileEmit.DtsOnly */;
123844
+ }
123845
+ ts.toBuilderFileEmit = toBuilderFileEmit;
123571
123846
  function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
123572
123847
  var _a, _b, _c, _d;
123573
123848
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
@@ -123609,8 +123884,8 @@ var ts;
123609
123884
  exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
123610
123885
  semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }),
123611
123886
  hasReusableDiagnostic: true,
123612
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
123613
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
123887
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }),
123888
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, toBuilderFileEmit),
123614
123889
  affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
123615
123890
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
123616
123891
  latestChangedDtsFile: latestChangedDtsFile,
@@ -123758,7 +124033,7 @@ var ts;
123758
124033
  var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
123759
124034
  if (isNonDirectorySeparatorRoot &&
123760
124035
  dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
123761
- pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart
124036
+ pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) { // Dos style nextPart
123762
124037
  nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
123763
124038
  if (nextDirectorySeparator === -1) {
123764
124039
  // ignore "//vda1cs4850/c$/folderAtRoot"
@@ -125012,7 +125287,7 @@ var ts;
125012
125287
  });
125013
125288
  // Sort by paths closest to importing file Name directory
125014
125289
  var sortedPaths = [];
125015
- var _loop_36 = function (directory) {
125290
+ var _loop_35 = function (directory) {
125016
125291
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
125017
125292
  var pathsInDirectory;
125018
125293
  allFileNames.forEach(function (_a, fileName) {
@@ -125036,9 +125311,9 @@ var ts;
125036
125311
  };
125037
125312
  var out_directory_1;
125038
125313
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
125039
- var state_12 = _loop_36(directory);
125314
+ var state_11 = _loop_35(directory);
125040
125315
  directory = out_directory_1;
125041
- if (state_12 === "break")
125316
+ if (state_11 === "break")
125042
125317
  break;
125043
125318
  }
125044
125319
  if (allFileNames.size) {
@@ -125107,7 +125382,7 @@ var ts;
125107
125382
  }
125108
125383
  function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
125109
125384
  for (var key in paths) {
125110
- var _loop_37 = function (patternText_1) {
125385
+ var _loop_36 = function (patternText_1) {
125111
125386
  var pattern = ts.normalizePath(patternText_1);
125112
125387
  var indexOfStar = pattern.indexOf("*");
125113
125388
  // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
@@ -125174,9 +125449,9 @@ var ts;
125174
125449
  };
125175
125450
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
125176
125451
  var patternText_1 = _a[_i];
125177
- var state_13 = _loop_37(patternText_1);
125178
- if (typeof state_13 === "object")
125179
- return state_13.value;
125452
+ var state_12 = _loop_36(patternText_1);
125453
+ if (typeof state_12 === "object")
125454
+ return state_12.value;
125180
125455
  }
125181
125456
  }
125182
125457
  function validateEnding(_a) {
@@ -125264,15 +125539,21 @@ var ts;
125264
125539
  return undefined;
125265
125540
  }
125266
125541
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
125267
- var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125268
- if (normalizedTargetPath === undefined) {
125542
+ var normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125543
+ if (normalizedTargetPaths === undefined) {
125544
+ return undefined;
125545
+ }
125546
+ var normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125547
+ var relativePaths = ts.flatMap(normalizedSourcePaths, function (sourcePath) {
125548
+ return ts.map(normalizedTargetPaths, function (targetPath) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName)); });
125549
+ });
125550
+ var shortest = ts.min(relativePaths, ts.compareNumberOfDirectorySeparators);
125551
+ if (!shortest) {
125269
125552
  return undefined;
125270
125553
  }
125271
- var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125272
- var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
125273
125554
  return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
125274
- ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
125275
- : ts.removeFileExtension(relativePath);
125555
+ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions)
125556
+ : ts.removeFileExtension(shortest);
125276
125557
  }
125277
125558
  function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
125278
125559
  var path = _a.path, isRedirect = _a.isRedirect;
@@ -125409,8 +125690,8 @@ var ts;
125409
125690
  }
125410
125691
  }
125411
125692
  }
125412
- function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125413
- return ts.firstDefined(rootDirs, function (rootDir) {
125693
+ function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125694
+ return ts.mapDefined(rootDirs, function (rootDir) {
125414
125695
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
125415
125696
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
125416
125697
  });
@@ -127978,8 +128259,15 @@ var ts;
127978
128259
  }
127979
128260
  if (buildInfo.program) {
127980
128261
  // If there are pending changes that are not emitted, project is out of date
128262
+ // When there are syntax errors, changeFileSet will have list of files changed (irrespective of noEmit)
128263
+ // But in case of semantic error we need special treatment.
128264
+ // Checking presence of affectedFilesPendingEmit list is fast and good way to tell if there were semantic errors and file emit was blocked
128265
+ // But if noEmit is true, affectedFilesPendingEmit will have file list even if there are no semantic errors to preserve list of files to be emitted when running with noEmit false
128266
+ // So with noEmit set to true, check on semantic diagnostics needs to be explicit as oppose to when it is false when only files pending emit is sufficient
127981
128267
  if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
127982
- (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
128268
+ (!project.options.noEmit ?
128269
+ (_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length :
128270
+ ts.some(buildInfo.program.semanticDiagnosticsPerFile, ts.isArray))) {
127983
128271
  return {
127984
128272
  type: ts.UpToDateStatusType.OutOfDateBuildInfo,
127985
128273
  buildInfoFile: buildInfoPath
@@ -129160,6 +129448,12 @@ var ts;
129160
129448
  SemanticClassificationFormat["Original"] = "original";
129161
129449
  SemanticClassificationFormat["TwentyTwenty"] = "2020";
129162
129450
  })(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
129451
+ var OrganizeImportsMode;
129452
+ (function (OrganizeImportsMode) {
129453
+ OrganizeImportsMode["All"] = "All";
129454
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
129455
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
129456
+ })(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
129163
129457
  var CompletionTriggerKind;
129164
129458
  (function (CompletionTriggerKind) {
129165
129459
  /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
@@ -130205,6 +130499,8 @@ var ts;
130205
130499
  return lastTypeNode;
130206
130500
  }
130207
130501
  function getContextualTypeFromParentOrAncestorTypeNode(node, checker) {
130502
+ if (node.flags & (8388608 /* NodeFlags.JSDoc */ & ~262144 /* NodeFlags.JavaScriptFile */))
130503
+ return undefined;
130208
130504
  var contextualType = getContextualTypeFromParent(node, checker);
130209
130505
  if (contextualType)
130210
130506
  return contextualType;
@@ -132691,6 +132987,10 @@ var ts;
132691
132987
  return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
132692
132988
  }
132693
132989
  ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
132990
+ function isSourceFileFromLibrary(program, node) {
132991
+ return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
132992
+ }
132993
+ ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
132694
132994
  // #endregion
132695
132995
  })(ts || (ts = {}));
132696
132996
  /*@internal*/
@@ -135717,7 +136017,7 @@ var ts;
135717
136017
  if (preferences.includeCompletionsWithClassMemberSnippets &&
135718
136018
  preferences.includeCompletionsWithInsertText &&
135719
136019
  completionKind === 3 /* CompletionKind.MemberLike */ &&
135720
- isClassLikeMemberCompletion(symbol, location)) {
136020
+ isClassLikeMemberCompletion(symbol, location, sourceFile)) {
135721
136021
  var importAdder = void 0;
135722
136022
  (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
135723
136023
  sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
@@ -135789,7 +136089,7 @@ var ts;
135789
136089
  data: data,
135790
136090
  };
135791
136091
  }
135792
- function isClassLikeMemberCompletion(symbol, location) {
136092
+ function isClassLikeMemberCompletion(symbol, location, sourceFile) {
135793
136093
  // TODO: support JS files.
135794
136094
  if (ts.isInJSFile(location)) {
135795
136095
  return false;
@@ -135823,6 +136123,7 @@ var ts;
135823
136123
  location.parent.parent &&
135824
136124
  ts.isClassElement(location.parent) &&
135825
136125
  location === location.parent.name &&
136126
+ location.parent.getLastToken(sourceFile) === location.parent.name &&
135826
136127
  ts.isClassLike(location.parent.parent)) ||
135827
136128
  (location.parent &&
135828
136129
  ts.isSyntaxList(location) &&
@@ -142984,6 +143285,12 @@ var ts;
142984
143285
  var label = ts.getTargetLabel(node.parent, node.text);
142985
143286
  return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
142986
143287
  }
143288
+ if (node.kind === 105 /* SyntaxKind.ReturnKeyword */) {
143289
+ var functionDeclaration = ts.findAncestor(node.parent, function (n) {
143290
+ return ts.isClassStaticBlockDeclaration(n) ? "quit" : ts.isFunctionLikeDeclaration(n);
143291
+ });
143292
+ return functionDeclaration ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] : undefined;
143293
+ }
142987
143294
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
142988
143295
  var classDecl = node.parent.parent;
142989
143296
  var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
@@ -143119,13 +143426,16 @@ var ts;
143119
143426
  if (!baseDeclaration)
143120
143427
  return;
143121
143428
  var baseTypeNode = ts.getEffectiveBaseTypeNode(baseDeclaration);
143122
- var baseType = baseTypeNode ? typeChecker.getTypeAtLocation(baseTypeNode) : undefined;
143123
- if (!baseType)
143429
+ if (!baseTypeNode)
143430
+ return;
143431
+ var expression = ts.skipParentheses(baseTypeNode.expression);
143432
+ var base = ts.isClassExpression(expression) ? expression.symbol : typeChecker.getSymbolAtLocation(expression);
143433
+ if (!base)
143124
143434
  return;
143125
143435
  var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(classElement.name));
143126
143436
  var symbol = ts.hasStaticModifier(classElement)
143127
- ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbolAtLocation(baseType.symbol, baseDeclaration), name)
143128
- : typeChecker.getPropertyOfType(baseType, name);
143437
+ ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbol(base), name)
143438
+ : typeChecker.getPropertyOfType(typeChecker.getDeclaredTypeOfSymbol(base), name);
143129
143439
  if (!symbol)
143130
143440
  return;
143131
143441
  return getDefinitionFromSymbol(typeChecker, symbol, node);
@@ -143832,19 +144142,24 @@ var ts;
143832
144142
  return getCommentOwnerInfoWorker(commentOwner.initializer, options);
143833
144143
  case 260 /* SyntaxKind.ClassDeclaration */:
143834
144144
  case 261 /* SyntaxKind.InterfaceDeclaration */:
143835
- case 168 /* SyntaxKind.PropertySignature */:
143836
144145
  case 263 /* SyntaxKind.EnumDeclaration */:
143837
144146
  case 302 /* SyntaxKind.EnumMember */:
143838
144147
  case 262 /* SyntaxKind.TypeAliasDeclaration */:
143839
144148
  return { commentOwner: commentOwner };
144149
+ case 168 /* SyntaxKind.PropertySignature */: {
144150
+ var host_1 = commentOwner;
144151
+ return host_1.type && ts.isFunctionTypeNode(host_1.type)
144152
+ ? { commentOwner: commentOwner, parameters: host_1.type.parameters, hasReturn: hasReturn(host_1.type, options) }
144153
+ : { commentOwner: commentOwner };
144154
+ }
143840
144155
  case 240 /* SyntaxKind.VariableStatement */: {
143841
144156
  var varStatement = commentOwner;
143842
144157
  var varDeclarations = varStatement.declarationList.declarations;
143843
- var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer
144158
+ var host_2 = varDeclarations.length === 1 && varDeclarations[0].initializer
143844
144159
  ? getRightHandSideOfAssignment(varDeclarations[0].initializer)
143845
144160
  : undefined;
143846
- return host_1
143847
- ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) }
144161
+ return host_2
144162
+ ? { commentOwner: commentOwner, parameters: host_2.parameters, hasReturn: hasReturn(host_2, options) }
143848
144163
  : { commentOwner: commentOwner };
143849
144164
  }
143850
144165
  case 308 /* SyntaxKind.SourceFile */:
@@ -143874,7 +144189,7 @@ var ts;
143874
144189
  }
143875
144190
  function hasReturn(node, options) {
143876
144191
  return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) &&
143877
- (ts.isArrowFunction(node) && ts.isExpression(node.body)
144192
+ (ts.isFunctionTypeNode(node) || ts.isArrowFunction(node) && ts.isExpression(node.body)
143878
144193
  || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }));
143879
144194
  }
143880
144195
  function getRightHandSideOfAssignment(rightHandSide) {
@@ -144915,23 +145230,39 @@ var ts;
144915
145230
  * 2) Coalescing imports from the same module
144916
145231
  * 3) Sorting imports
144917
145232
  */
144918
- function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) {
145233
+ function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
144919
145234
  var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
144920
- var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
145235
+ var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
145236
+ var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
145237
+ var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
145238
+ var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
145239
+ var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
145240
+ var processImportsOfSameModuleSpecifier = function (importGroup) {
145241
+ var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
145242
+ return shouldSort
145243
+ ? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
145244
+ : processedDeclarations;
145245
+ };
144921
145246
  // All of the old ImportDeclarations in the file, in syntactic order.
144922
145247
  var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
144923
- topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144924
- // All of the old ExportDeclarations in the file, in syntactic order.
144925
- var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
144926
- organizeImportsWorker(topLevelExportDecls, coalesceExports);
145248
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
145249
+ // Exports are always used
145250
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
145251
+ // All of the old ExportDeclarations in the file, in syntactic order.
145252
+ var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
145253
+ organizeImportsWorker(topLevelExportDecls, coalesceExports);
145254
+ }
144927
145255
  for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
144928
145256
  var ambientModule = _a[_i];
144929
145257
  if (!ambientModule.body)
144930
145258
  continue;
144931
145259
  var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
144932
- ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144933
- var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
144934
- organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
145260
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
145261
+ // Exports are always used
145262
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
145263
+ var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
145264
+ organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
145265
+ }
144935
145266
  }
144936
145267
  return changeTracker.getChanges();
144937
145268
  function organizeImportsWorker(oldImportDecls, coalesce) {
@@ -144944,8 +145275,12 @@ var ts;
144944
145275
  // Consider: we could do a more careful check that this trivia is actually a header,
144945
145276
  // but the consequences of being wrong are very minor.
144946
145277
  ts.suppressLeadingTrivia(oldImportDecls[0]);
144947
- var oldImportGroups = ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); });
144948
- var sortedImportGroups = ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); });
145278
+ var oldImportGroups = shouldCombine
145279
+ ? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
145280
+ : [oldImportDecls];
145281
+ var sortedImportGroups = shouldSort
145282
+ ? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
145283
+ : oldImportGroups;
144949
145284
  var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
144950
145285
  return getExternalModuleName(importGroup[0].moduleSpecifier)
144951
145286
  ? coalesce(importGroup)
@@ -145009,11 +145344,7 @@ var ts;
145009
145344
  }
145010
145345
  return false;
145011
145346
  }
145012
- function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
145013
- // As a precaution, consider unused import detection to be destructive (GH #43051)
145014
- if (skipDestructiveCodeActions) {
145015
- return oldImports;
145016
- }
145347
+ function removeUnusedImports(oldImports, sourceFile, program) {
145017
145348
  var typeChecker = program.getTypeChecker();
145018
145349
  var compilerOptions = program.getCompilerOptions();
145019
145350
  var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
@@ -145869,7 +146200,7 @@ var ts;
145869
146200
  return bestMatch;
145870
146201
  }
145871
146202
  function betterMatch(a, b) {
145872
- return ts.min(a, b, compareMatches);
146203
+ return ts.min([a, b], compareMatches);
145873
146204
  }
145874
146205
  function compareMatches(a, b) {
145875
146206
  return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
@@ -146478,8 +146809,8 @@ var ts;
146478
146809
  }
146479
146810
  if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
146480
146811
  var stack = [ts.scanner.getToken()];
146481
- var token = ts.scanner.scan();
146482
146812
  loop: while (ts.length(stack)) {
146813
+ var token = ts.scanner.scan();
146483
146814
  switch (token) {
146484
146815
  case 1 /* SyntaxKind.EndOfFileToken */:
146485
146816
  break loop;
@@ -146507,7 +146838,6 @@ var ts;
146507
146838
  }
146508
146839
  break;
146509
146840
  }
146510
- token = ts.scanner.scan();
146511
146841
  }
146512
146842
  nextToken();
146513
146843
  }
@@ -148986,7 +149316,7 @@ var ts;
148986
149316
  tags = signature.getJsDocTags();
148987
149317
  if (allSignatures.length > 1 && documentation.length === 0 && tags.length === 0) {
148988
149318
  documentation = allSignatures[0].getDocumentationComment(typeChecker);
148989
- tags = allSignatures[0].getJsDocTags();
149319
+ tags = allSignatures[0].getJsDocTags().filter(function (tag) { return tag.name !== "deprecated"; }); // should only include @deprecated JSDoc tag on the first overload (#49368)
148990
149320
  }
148991
149321
  }
148992
149322
  function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
@@ -149329,7 +149659,7 @@ var ts;
149329
149659
  return false;
149330
149660
  }
149331
149661
  function shouldRescanJsxText(node) {
149332
- return ts.isJsxText(node);
149662
+ return ts.isJsxText(node) || ts.isJsxElement(node) && (lastTokenInfo === null || lastTokenInfo === void 0 ? void 0 : lastTokenInfo.token.kind) === 11 /* SyntaxKind.JsxText */;
149333
149663
  }
149334
149664
  function shouldRescanSlashToken(container) {
149335
149665
  return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
@@ -150098,10 +150428,10 @@ var ts;
150098
150428
  !nodeIsInDecoratorContext(context.nextTokenParent);
150099
150429
  }
150100
150430
  function nodeIsInDecoratorContext(node) {
150101
- while (ts.isExpressionNode(node)) {
150431
+ while (node && ts.isExpression(node)) {
150102
150432
  node = node.parent;
150103
150433
  }
150104
- return node.kind === 167 /* SyntaxKind.Decorator */;
150434
+ return node && node.kind === 167 /* SyntaxKind.Decorator */;
150105
150435
  }
150106
150436
  function isStartOfVariableDeclarationList(context) {
150107
150437
  return context.currentTokenParent.kind === 258 /* SyntaxKind.VariableDeclarationList */ &&
@@ -153019,6 +153349,26 @@ var ts;
153019
153349
  function startPositionToDeleteNodeInList(sourceFile, node) {
153020
153350
  return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
153021
153351
  }
153352
+ function endPositionToDeleteNodeInList(sourceFile, node, prevNode, nextNode) {
153353
+ var end = startPositionToDeleteNodeInList(sourceFile, nextNode);
153354
+ if (prevNode === undefined || ts.positionsAreOnSameLine(getAdjustedEndPosition(sourceFile, node, {}), end, sourceFile)) {
153355
+ return end;
153356
+ }
153357
+ var token = ts.findPrecedingToken(nextNode.getStart(sourceFile), sourceFile);
153358
+ if (isSeparator(node, token)) {
153359
+ var prevToken = ts.findPrecedingToken(node.getStart(sourceFile), sourceFile);
153360
+ if (isSeparator(prevNode, prevToken)) {
153361
+ var pos = ts.skipTrivia(sourceFile.text, token.getEnd(), /*stopAfterLineBreak*/ true, /*stopAtComments*/ true);
153362
+ if (ts.positionsAreOnSameLine(prevToken.getStart(sourceFile), token.getStart(sourceFile), sourceFile)) {
153363
+ return ts.isLineBreak(sourceFile.text.charCodeAt(pos - 1)) ? pos - 1 : pos;
153364
+ }
153365
+ if (ts.isLineBreak(sourceFile.text.charCodeAt(pos))) {
153366
+ return pos;
153367
+ }
153368
+ }
153369
+ }
153370
+ return end;
153371
+ }
153022
153372
  function getClassOrObjectBraceEnds(cls, sourceFile) {
153023
153373
  var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
153024
153374
  var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
@@ -153576,7 +153926,7 @@ var ts;
153576
153926
  deletedNodesInLists.add(node);
153577
153927
  changes.deleteRange(sourceFile, {
153578
153928
  pos: startPositionToDeleteNodeInList(sourceFile, node),
153579
- end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
153929
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : endPositionToDeleteNodeInList(sourceFile, node, containingList[index - 1], containingList[index + 1]),
153580
153930
  });
153581
153931
  }
153582
153932
  })(textChanges = ts.textChanges || (ts.textChanges = {}));
@@ -154046,6 +154396,15 @@ var ts;
154046
154396
  });
154047
154397
  }
154048
154398
  function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
154399
+ if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
154400
+ var exprType = checker.getTypeAtLocation(insertionSite);
154401
+ var asyncIter = checker.getAsyncIterableType();
154402
+ if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
154403
+ var forOf = insertionSite.parent;
154404
+ changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
154405
+ return;
154406
+ }
154407
+ }
154049
154408
  if (ts.isBinaryExpression(insertionSite)) {
154050
154409
  for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
154051
154410
  var side = _a[_i];
@@ -157771,6 +158130,143 @@ var ts;
157771
158130
  })(ts || (ts = {}));
157772
158131
  /* @internal */
157773
158132
  var ts;
158133
+ (function (ts) {
158134
+ var codefix;
158135
+ (function (codefix) {
158136
+ var fixId = "fixImportNonExportedMember";
158137
+ var errorCodes = [
158138
+ ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
158139
+ ];
158140
+ codefix.registerCodeFix({
158141
+ errorCodes: errorCodes,
158142
+ fixIds: [fixId],
158143
+ getCodeActions: function (context) {
158144
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
158145
+ var info = getInfo(sourceFile, span.start, program);
158146
+ if (info === undefined)
158147
+ return undefined;
158148
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
158149
+ return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId, ts.Diagnostics.Export_all_referenced_locals)];
158150
+ },
158151
+ getAllCodeActions: function (context) {
158152
+ var program = context.program;
158153
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
158154
+ var exports = new ts.Map();
158155
+ codefix.eachDiagnostic(context, errorCodes, function (diag) {
158156
+ var info = getInfo(diag.file, diag.start, program);
158157
+ if (info === undefined)
158158
+ return undefined;
158159
+ var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
158160
+ if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
158161
+ changes.insertExportModifier(moduleSourceFile, node);
158162
+ }
158163
+ else {
158164
+ var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
158165
+ if (exportName.isTypeOnly) {
158166
+ moduleExports.typeOnlyExports.push(exportName);
158167
+ }
158168
+ else {
158169
+ moduleExports.exports.push(exportName);
158170
+ }
158171
+ exports.set(moduleSourceFile, moduleExports);
158172
+ }
158173
+ });
158174
+ exports.forEach(function (moduleExports, moduleSourceFile) {
158175
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
158176
+ if (exportDeclaration && exportDeclaration.isTypeOnly) {
158177
+ doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
158178
+ doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
158179
+ }
158180
+ else {
158181
+ doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
158182
+ }
158183
+ });
158184
+ }));
158185
+ }
158186
+ });
158187
+ function getInfo(sourceFile, pos, program) {
158188
+ var _a;
158189
+ var token = ts.getTokenAtPosition(sourceFile, pos);
158190
+ if (ts.isIdentifier(token)) {
158191
+ var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
158192
+ if (importDeclaration === undefined)
158193
+ return undefined;
158194
+ var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
158195
+ if (moduleSpecifier === undefined)
158196
+ return undefined;
158197
+ var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
158198
+ if (resolvedModule === undefined)
158199
+ return undefined;
158200
+ var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
158201
+ if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
158202
+ return undefined;
158203
+ var moduleSymbol = moduleSourceFile.symbol;
158204
+ var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
158205
+ if (locals === undefined)
158206
+ return undefined;
158207
+ var localSymbol = locals.get(token.escapedText);
158208
+ if (localSymbol === undefined)
158209
+ return undefined;
158210
+ var node = getNodeOfSymbol(localSymbol);
158211
+ if (node === undefined)
158212
+ return undefined;
158213
+ var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
158214
+ return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
158215
+ }
158216
+ return undefined;
158217
+ }
158218
+ function doChange(changes, program, _a) {
158219
+ var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
158220
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
158221
+ if (exportDeclaration) {
158222
+ updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
158223
+ }
158224
+ else if (ts.canHaveExportModifier(node)) {
158225
+ changes.insertExportModifier(moduleSourceFile, node);
158226
+ }
158227
+ else {
158228
+ createExport(changes, program, moduleSourceFile, [exportName]);
158229
+ }
158230
+ }
158231
+ function doChanges(changes, program, sourceFile, moduleExports, node) {
158232
+ if (ts.length(moduleExports)) {
158233
+ if (node) {
158234
+ updateExport(changes, program, sourceFile, node, moduleExports);
158235
+ }
158236
+ else {
158237
+ createExport(changes, program, sourceFile, moduleExports);
158238
+ }
158239
+ }
158240
+ }
158241
+ function tryGetExportDeclaration(sourceFile, isTypeOnly) {
158242
+ var predicate = function (node) {
158243
+ return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
158244
+ };
158245
+ return ts.findLast(sourceFile.statements, predicate);
158246
+ }
158247
+ function updateExport(changes, program, sourceFile, node, names) {
158248
+ var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
158249
+ var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
158250
+ changes.replaceNode(sourceFile, node, ts.factory.updateExportDeclaration(node, node.modifiers, node.isTypeOnly, ts.factory.createNamedExports(ts.factory.createNodeArray(__spreadArray(__spreadArray([], namedExports, true), createExportSpecifiers(names, allowTypeModifier), true), /*hasTrailingComma*/ namedExports.hasTrailingComma)), node.moduleSpecifier, node.assertClause));
158251
+ }
158252
+ function createExport(changes, program, sourceFile, names) {
158253
+ changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
158254
+ }
158255
+ function createExportSpecifiers(names, allowTypeModifier) {
158256
+ return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
158257
+ }
158258
+ function getNodeOfSymbol(symbol) {
158259
+ if (symbol.valueDeclaration === undefined) {
158260
+ return ts.firstOrUndefined(symbol.declarations);
158261
+ }
158262
+ var declaration = symbol.valueDeclaration;
158263
+ var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
158264
+ return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
158265
+ }
158266
+ })(codefix = ts.codefix || (ts.codefix = {}));
158267
+ })(ts || (ts = {}));
158268
+ /* @internal */
158269
+ var ts;
157774
158270
  (function (ts) {
157775
158271
  var codefix;
157776
158272
  (function (codefix) {
@@ -158301,7 +158797,7 @@ var ts;
158301
158797
  var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
158302
158798
  if (argIndex < 0)
158303
158799
  return undefined;
158304
- var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */));
158800
+ var signature = checker.getResolvedSignature(parent.parent);
158305
158801
  if (!(signature && signature.declaration && signature.parameters[argIndex]))
158306
158802
  return undefined;
158307
158803
  var param = signature.parameters[argIndex].valueDeclaration;
@@ -158348,13 +158844,13 @@ var ts;
158348
158844
  if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
158349
158845
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
158350
158846
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
158351
- if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
158847
+ if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
158352
158848
  return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
158353
158849
  }
158354
158850
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
158355
158851
  if (sourceFile.commonJsModuleIndicator)
158356
158852
  return undefined;
158357
- if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
158853
+ if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
158358
158854
  return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
158359
158855
  }
158360
158856
  }
@@ -158364,7 +158860,7 @@ var ts;
158364
158860
  return undefined;
158365
158861
  // Prefer to change the class instead of the interface if they are merged
158366
158862
  var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
158367
- if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
158863
+ if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
158368
158864
  var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
158369
158865
  if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
158370
158866
  return undefined;
@@ -158376,14 +158872,11 @@ var ts;
158376
158872
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
158377
158873
  }
158378
158874
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
158379
- if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158875
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158380
158876
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
158381
158877
  }
158382
158878
  return undefined;
158383
158879
  }
158384
- function isSourceFileFromLibrary(program, node) {
158385
- return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
158386
- }
158387
158880
  function getActionsForMissingMemberDeclaration(context, info) {
158388
158881
  return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
158389
158882
  createActionsForAddMissingMemberInTypeScriptFile(context, info);
@@ -163809,8 +164302,8 @@ var ts;
163809
164302
  var i = 0;
163810
164303
  for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
163811
164304
  var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
163812
- var description = functionExtraction.description;
163813
164305
  if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
164306
+ var description = functionExtraction.description;
163814
164307
  if (functionExtraction.errors.length === 0) {
163815
164308
  // Don't issue refactorings with duplicated names.
163816
164309
  // Scopes come back in "innermost first" order, so extractions will
@@ -163834,15 +164327,15 @@ var ts;
163834
164327
  }
163835
164328
  }
163836
164329
  if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
164330
+ var description = constantExtraction.description;
163837
164331
  if (constantExtraction.errors.length === 0) {
163838
164332
  // Don't issue refactorings with duplicated names.
163839
164333
  // Scopes come back in "innermost first" order, so extractions will
163840
164334
  // preferentially go into nearer scopes
163841
- var description_1 = constantExtraction.description;
163842
- if (!usedConstantNames.has(description_1)) {
163843
- usedConstantNames.set(description_1, true);
164335
+ if (!usedConstantNames.has(description)) {
164336
+ usedConstantNames.set(description, true);
163844
164337
  constantActions.push({
163845
- description: description_1,
164338
+ description: description,
163846
164339
  name: "constant_scope_".concat(i),
163847
164340
  kind: extractConstantAction.kind
163848
164341
  });
@@ -163987,7 +164480,6 @@ var ts;
163987
164480
  var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
163988
164481
  // Do the same for the ending position
163989
164482
  var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
163990
- var declarations = [];
163991
164483
  // We'll modify these flags as we walk the tree to collect data
163992
164484
  // about what things need to be done as part of the extraction.
163993
164485
  var rangeFacts = RangeFacts.None;
@@ -164030,7 +164522,7 @@ var ts;
164030
164522
  // the expression.
164031
164523
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
164032
164524
  }
164033
- return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
164525
+ return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
164034
164526
  }
164035
164527
  if (ts.isReturnStatement(start) && !start.expression) {
164036
164528
  // Makes no sense to extract an expression-less return statement.
@@ -164042,7 +164534,7 @@ var ts;
164042
164534
  if (errors) {
164043
164535
  return { errors: errors };
164044
164536
  }
164045
- return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
164537
+ return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
164046
164538
  /**
164047
164539
  * Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
164048
164540
  * @param node The unrefined extraction node.
@@ -164054,10 +164546,10 @@ var ts;
164054
164546
  }
164055
164547
  }
164056
164548
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
164057
- var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164549
+ var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164058
164550
  var numInitializers = 0;
164059
164551
  var lastInitializer = void 0;
164060
- for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
164552
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
164061
164553
  var declaration = declarations_5[_i];
164062
164554
  if (declaration.initializer) {
164063
164555
  numInitializers++;
@@ -164157,7 +164649,6 @@ var ts;
164157
164649
  (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
164158
164650
  return true;
164159
164651
  }
164160
- declarations.push(node.symbol);
164161
164652
  }
164162
164653
  // Some things can't be extracted in certain situations
164163
164654
  switch (node.kind) {
@@ -165882,7 +166373,7 @@ var ts;
165882
166373
  function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
165883
166374
  var checker = program.getTypeChecker();
165884
166375
  var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective);
165885
- if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
166376
+ if (oldFile.externalModuleIndicator === undefined && oldFile.commonJsModuleIndicator === undefined && usage.oldImportsNeededByNewFile.size() === 0) {
165886
166377
  deleteMovedStatements(oldFile, toMove.ranges, changes);
165887
166378
  return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
165888
166379
  }
@@ -166123,7 +166614,12 @@ var ts;
166123
166614
  switch (name.kind) {
166124
166615
  case 79 /* SyntaxKind.Identifier */:
166125
166616
  if (isUnused(name)) {
166126
- changes.delete(sourceFile, name);
166617
+ if (varDecl.initializer && ts.isRequireCall(varDecl.initializer, /*requireStringLiteralLikeArgument*/ true)) {
166618
+ changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && ts.length(varDecl.parent.declarations) === 1 ? varDecl.parent.parent : varDecl);
166619
+ }
166620
+ else {
166621
+ changes.delete(sourceFile, name);
166622
+ }
166127
166623
  }
166128
166624
  break;
166129
166625
  case 204 /* SyntaxKind.ArrayBindingPattern */:
@@ -166355,6 +166851,9 @@ var ts;
166355
166851
  ts.copyEntries(this.map, clone.map);
166356
166852
  return clone;
166357
166853
  };
166854
+ SymbolSet.prototype.size = function () {
166855
+ return this.map.size;
166856
+ };
166358
166857
  return SymbolSet;
166359
166858
  }());
166360
166859
  function isTopLevelDeclaration(node) {
@@ -166443,7 +166942,8 @@ var ts;
166443
166942
  if (useEs6Exports) {
166444
166943
  return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText)));
166445
166944
  }
166446
- return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
166945
+ return !!sourceFile.symbol && !!sourceFile.symbol.exports &&
166946
+ getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
166447
166947
  }
166448
166948
  function addExport(decl, useEs6Exports) {
166449
166949
  return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
@@ -168203,8 +168703,8 @@ var ts;
168203
168703
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
168204
168704
  }
168205
168705
  };
168206
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168207
- var declaration = declarations_7[_i];
168706
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
168707
+ var declaration = declarations_6[_i];
168208
168708
  _loop_20(declaration);
168209
168709
  }
168210
168710
  }
@@ -168230,8 +168730,8 @@ var ts;
168230
168730
  if (inheritedDocs)
168231
168731
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
168232
168732
  };
168233
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
168234
- var declaration = declarations_8[_i];
168733
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168734
+ var declaration = declarations_7[_i];
168235
168735
  _loop_21(declaration);
168236
168736
  }
168237
168737
  }
@@ -169401,12 +169901,14 @@ var ts;
169401
169901
  return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
169402
169902
  }
169403
169903
  function organizeImports(args, formatOptions, preferences) {
169904
+ var _a;
169404
169905
  if (preferences === void 0) { preferences = ts.emptyOptions; }
169405
169906
  synchronizeHostData();
169406
169907
  ts.Debug.assert(args.type === "file");
169407
169908
  var sourceFile = getValidSourceFile(args.fileName);
169408
169909
  var formatContext = ts.formatting.getFormatContext(formatOptions, host);
169409
- return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions);
169910
+ var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
169911
+ return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
169410
169912
  }
169411
169913
  function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
169412
169914
  if (preferences === void 0) { preferences = ts.emptyOptions; }
@@ -171986,6 +172488,12 @@ var ts;
171986
172488
  CommandTypes["ProvideInlayHints"] = "provideInlayHints";
171987
172489
  // NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
171988
172490
  })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {}));
172491
+ var OrganizeImportsMode;
172492
+ (function (OrganizeImportsMode) {
172493
+ OrganizeImportsMode["All"] = "All";
172494
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
172495
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
172496
+ })(OrganizeImportsMode = protocol.OrganizeImportsMode || (protocol.OrganizeImportsMode = {}));
171989
172497
  var WatchFileKind;
171990
172498
  (function (WatchFileKind) {
171991
172499
  WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
@@ -172872,6 +173380,7 @@ var ts;
172872
173380
  this.watchOptions = watchOptions;
172873
173381
  this.rootFiles = [];
172874
173382
  this.rootFilesMap = new ts.Map();
173383
+ /*@internal*/
172875
173384
  this.plugins = [];
172876
173385
  /*@internal*/
172877
173386
  /**
@@ -173400,6 +173909,7 @@ var ts;
173400
173909
  this.directoryStructureHost = undefined;
173401
173910
  this.exportMapCache = undefined;
173402
173911
  this.projectErrors = undefined;
173912
+ this.plugins.length = 0;
173403
173913
  // Clean up file watchers waiting for missing files
173404
173914
  if (this.missingFilesMap) {
173405
173915
  ts.clearMap(this.missingFilesMap, ts.closeFileWatcher);
@@ -174073,35 +174583,39 @@ var ts;
174073
174583
  Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) {
174074
174584
  return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
174075
174585
  };
174586
+ /*@internal*/
174587
+ Project.prototype.getGlobalPluginSearchPaths = function () {
174588
+ // Search any globally-specified probe paths, then our peer node_modules
174589
+ return __spreadArray(__spreadArray([], this.projectService.pluginProbeLocations, true), [
174590
+ // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174591
+ ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
174592
+ ], false);
174593
+ };
174076
174594
  Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
174595
+ if (!this.projectService.globalPlugins.length)
174596
+ return;
174077
174597
  var host = this.projectService.host;
174078
174598
  if (!host.require && !host.importPlugin) {
174079
174599
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
174080
174600
  return;
174081
174601
  }
174082
- // Search any globally-specified probe paths, then our peer node_modules
174083
- var searchPaths = __spreadArray(__spreadArray([], this.projectService.pluginProbeLocations, true), [
174084
- // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174085
- ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
174086
- ], false);
174087
- if (this.projectService.globalPlugins) {
174088
- var _loop_1 = function (globalPluginName) {
174089
- // Skip empty names from odd commandline parses
174090
- if (!globalPluginName)
174091
- return "continue";
174092
- // Skip already-locally-loaded plugins
174093
- if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; }))
174094
- return "continue";
174095
- // Provide global: true so plugins can detect why they can't find their config
174096
- this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName));
174097
- this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides);
174098
- };
174099
- var this_1 = this;
174100
- // Enable global plugins with synthetic configuration entries
174101
- for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
174102
- var globalPluginName = _a[_i];
174103
- _loop_1(globalPluginName);
174104
- }
174602
+ // Enable global plugins with synthetic configuration entries
174603
+ var searchPaths = this.getGlobalPluginSearchPaths();
174604
+ var _loop_1 = function (globalPluginName) {
174605
+ // Skip empty names from odd commandline parses
174606
+ if (!globalPluginName)
174607
+ return "continue";
174608
+ // Skip already-locally-loaded plugins
174609
+ if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; }))
174610
+ return "continue";
174611
+ // Provide global: true so plugins can detect why they can't find their config
174612
+ this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName));
174613
+ this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides);
174614
+ };
174615
+ var this_1 = this;
174616
+ for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
174617
+ var globalPluginName = _a[_i];
174618
+ _loop_1(globalPluginName);
174105
174619
  }
174106
174620
  };
174107
174621
  /**
@@ -174832,14 +175346,16 @@ var ts;
174832
175346
  };
174833
175347
  /*@internal*/
174834
175348
  ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
175349
+ var _a;
175350
+ this.plugins.length = 0;
175351
+ if (!((_a = options.plugins) === null || _a === void 0 ? void 0 : _a.length) && !this.projectService.globalPlugins.length)
175352
+ return;
174835
175353
  var host = this.projectService.host;
174836
175354
  if (!host.require && !host.importPlugin) {
174837
175355
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
174838
175356
  return;
174839
175357
  }
174840
- // Search our peer node_modules, then any globally-specified probe paths
174841
- // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174842
- var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true);
175358
+ var searchPaths = this.getGlobalPluginSearchPaths();
174843
175359
  if (this.projectService.allowLocalPluginLoads) {
174844
175360
  var local = ts.getDirectoryPath(this.canonicalConfigFilePath);
174845
175361
  this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths"));
@@ -174847,8 +175363,8 @@ var ts;
174847
175363
  }
174848
175364
  // Enable tsconfig-specified plugins
174849
175365
  if (options.plugins) {
174850
- for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) {
174851
- var pluginConfigEntry = _a[_i];
175366
+ for (var _i = 0, _b = options.plugins; _i < _b.length; _i++) {
175367
+ var pluginConfigEntry = _b[_i];
174852
175368
  this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
174853
175369
  }
174854
175370
  }
@@ -175693,18 +176209,20 @@ var ts;
175693
176209
  return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName);
175694
176210
  };
175695
176211
  /* @internal */
175696
- ProjectService.prototype.tryGetDefaultProjectForFile = function (fileName) {
175697
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
176212
+ ProjectService.prototype.tryGetDefaultProjectForFile = function (fileNameOrScriptInfo) {
176213
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
175698
176214
  return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined;
175699
176215
  };
175700
176216
  /* @internal */
175701
- ProjectService.prototype.ensureDefaultProjectForFile = function (fileName) {
175702
- return this.tryGetDefaultProjectForFile(fileName) || this.doEnsureDefaultProjectForFile(fileName);
176217
+ ProjectService.prototype.ensureDefaultProjectForFile = function (fileNameOrScriptInfo) {
176218
+ return this.tryGetDefaultProjectForFile(fileNameOrScriptInfo) || this.doEnsureDefaultProjectForFile(fileNameOrScriptInfo);
175703
176219
  };
175704
- ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) {
176220
+ ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileNameOrScriptInfo) {
175705
176221
  this.ensureProjectStructuresUptoDate();
175706
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
175707
- return scriptInfo ? scriptInfo.getDefaultProject() : (this.logErrorForScriptInfoNotFound(fileName), server.Errors.ThrowNoProject());
176222
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
176223
+ return scriptInfo ?
176224
+ scriptInfo.getDefaultProject() :
176225
+ (this.logErrorForScriptInfoNotFound(ts.isString(fileNameOrScriptInfo) ? fileNameOrScriptInfo : fileNameOrScriptInfo.fileName), server.Errors.ThrowNoProject());
175708
176226
  };
175709
176227
  ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) {
175710
176228
  this.ensureProjectStructuresUptoDate();
@@ -177876,7 +178394,7 @@ var ts;
177876
178394
  if (this.serverMode !== ts.LanguageServiceMode.Semantic || !this.eventHandler || !scriptInfo.isJavaScript() || !ts.addToSeen(this.allJsFilesForOpenFileTelemetry, scriptInfo.path)) {
177877
178395
  return;
177878
178396
  }
177879
- var project = scriptInfo.getDefaultProject();
178397
+ var project = this.ensureDefaultProjectForFile(scriptInfo);
177880
178398
  if (!project.languageServiceEnabled) {
177881
178399
  return;
177882
178400
  }
@@ -180476,6 +180994,10 @@ var ts;
180476
180994
  this.projectService.logErrorForScriptInfoNotFound(args.file);
180477
180995
  return server.Errors.ThrowNoProject();
180478
180996
  }
180997
+ else if (!getScriptInfoEnsuringProjectsUptoDate) {
180998
+ // Ensure there are containing projects are present
180999
+ this.projectService.ensureDefaultProjectForFile(scriptInfo);
181000
+ }
180479
181001
  projects = scriptInfo.containingProjects;
180480
181002
  symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo);
180481
181003
  }
@@ -180544,6 +181066,7 @@ var ts;
180544
181066
  var references = getReferencesWorker(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
180545
181067
  if (!simplifiedResult)
180546
181068
  return references;
181069
+ var preferences = this.getPreferences(file);
180547
181070
  var defaultProject = this.getDefaultProject(args);
180548
181071
  var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file);
180549
181072
  var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position);
@@ -180552,7 +181075,7 @@ var ts;
180552
181075
  var symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0;
180553
181076
  var symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)) : "";
180554
181077
  var refs = ts.flatMap(references, function (referencedSymbol) {
180555
- return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
181078
+ return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
180556
181079
  });
180557
181080
  return { refs: refs, symbolName: symbolName, symbolStartOffset: symbolStartOffset, symbolDisplayString: symbolDisplayString };
180558
181081
  };
@@ -180560,6 +181083,7 @@ var ts;
180560
181083
  var _this = this;
180561
181084
  var projects = this.getProjects(args);
180562
181085
  var fileName = args.file;
181086
+ var preferences = this.getPreferences(server.toNormalizedPath(fileName));
180563
181087
  var references = [];
180564
181088
  var seen = createDocumentSpanSet();
180565
181089
  forEachProjectInProjects(projects, /*path*/ undefined, function (project) {
@@ -180578,7 +181102,7 @@ var ts;
180578
181102
  });
180579
181103
  if (!simplifiedResult)
180580
181104
  return references;
180581
- var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
181105
+ var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
180582
181106
  return {
180583
181107
  refs: refs,
180584
181108
  symbolName: "\"".concat(args.file, "\"")
@@ -180602,13 +181126,7 @@ var ts;
180602
181126
  return this.getFileAndProjectWorker(args.file, args.projectFileName);
180603
181127
  };
180604
181128
  Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) {
180605
- // Since this is syntactic operation, there should always be project for the file
180606
- // throw if we dont get project
180607
- var file = server.toNormalizedPath(args.file);
180608
- var project = this.getProject(args.projectFileName) || this.projectService.ensureDefaultProjectForFile(file);
180609
- if (!project) {
180610
- return server.Errors.ThrowNoProject();
180611
- }
181129
+ var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
180612
181130
  return {
180613
181131
  file: file,
180614
181132
  languageService: project.getLanguageService(/*ensureSynchronized*/ false)
@@ -181149,11 +181667,12 @@ var ts;
181149
181667
  }
181150
181668
  };
181151
181669
  Session.prototype.organizeImports = function (args, simplifiedResult) {
181670
+ var _a;
181152
181671
  ts.Debug.assert(args.scope.type === "file");
181153
- var _a = this.getFileAndProject(args.scope.args), file = _a.file, project = _a.project;
181672
+ var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
181154
181673
  var changes = project.getLanguageService().organizeImports({
181155
181674
  fileName: file,
181156
- skipDestructiveCodeActions: args.skipDestructiveCodeActions,
181675
+ mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
181157
181676
  type: "file",
181158
181677
  }, this.getFormatOptions(file), this.getPreferences(file));
181159
181678
  if (simplifiedResult) {
@@ -181647,14 +182166,18 @@ var ts;
181647
182166
  }
181648
182167
  return text;
181649
182168
  }
181650
- function referenceEntryToReferencesResponseItem(projectService, _a) {
182169
+ function referenceEntryToReferencesResponseItem(projectService, _a, _b) {
181651
182170
  var fileName = _a.fileName, textSpan = _a.textSpan, contextSpan = _a.contextSpan, isWriteAccess = _a.isWriteAccess, isDefinition = _a.isDefinition;
182171
+ var disableLineTextInReferences = _b.disableLineTextInReferences;
181652
182172
  var scriptInfo = ts.Debug.checkDefined(projectService.getScriptInfo(fileName));
181653
182173
  var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo);
181654
- var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1);
181655
- var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
182174
+ var lineText = disableLineTextInReferences ? undefined : getLineText(scriptInfo, span);
181656
182175
  return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition });
181657
182176
  }
182177
+ function getLineText(scriptInfo, span) {
182178
+ var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1);
182179
+ return scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
182180
+ }
181658
182181
  function isCompletionEntryData(data) {
181659
182182
  return data === undefined || data && typeof data === "object"
181660
182183
  && typeof data.exportName === "string"