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.
@@ -95,11 +95,11 @@ var ts;
95
95
  (function (ts) {
96
96
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
97
97
  // If changing the text in this section, be sure to test `configurePrerelease` too.
98
- ts.versionMajorMinor = "4.9";
98
+ ts.versionMajorMinor = "5.0";
99
99
  // The following is baselined as a literal template type without intervention
100
100
  /** The version of the TypeScript compiler release */
101
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
102
- ts.version = "".concat(ts.versionMajorMinor, ".1-beta");
102
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221101");
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -1891,8 +1891,8 @@ var ts;
1891
1891
  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);
1892
1892
  }
1893
1893
  ts.compareTextSpans = compareTextSpans;
1894
- function min(a, b, compare) {
1895
- return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b;
1894
+ function min(items, compare) {
1895
+ return reduceLeft(items, function (x, y) { return compare(x, y) === -1 /* Comparison.LessThan */ ? x : y; });
1896
1896
  }
1897
1897
  ts.min = min;
1898
1898
  /**
@@ -3205,11 +3205,13 @@ var ts;
3205
3205
  // > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
3206
3206
  // > MUST NOT include leading zeroes.
3207
3207
  var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
3208
+ var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
3208
3209
  // https://semver.org/#spec-item-10
3209
3210
  // > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
3210
3211
  // > identifiers immediately following the patch or pre-release version. Identifiers MUST
3211
3212
  // > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
3212
3213
  var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
3214
+ var buildPartRegExp = /^[a-z0-9-]+$/i;
3213
3215
  // https://semver.org/#spec-item-9
3214
3216
  // > Numeric identifiers MUST NOT include leading zeroes.
3215
3217
  var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
@@ -3229,13 +3231,15 @@ var ts;
3229
3231
  ts.Debug.assert(major >= 0, "Invalid argument: major");
3230
3232
  ts.Debug.assert(minor >= 0, "Invalid argument: minor");
3231
3233
  ts.Debug.assert(patch >= 0, "Invalid argument: patch");
3232
- ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
3233
- ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
3234
+ var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
3235
+ var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
3236
+ ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
3237
+ ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
3234
3238
  this.major = major;
3235
3239
  this.minor = minor;
3236
3240
  this.patch = patch;
3237
- this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
3238
- this.build = build ? build.split(".") : ts.emptyArray;
3241
+ this.prerelease = prereleaseArray;
3242
+ this.build = buildArray;
3239
3243
  }
3240
3244
  Version.tryParse = function (text) {
3241
3245
  var result = tryParseComponents(text);
@@ -3274,6 +3278,10 @@ var ts;
3274
3278
  default: return ts.Debug.assertNever(field);
3275
3279
  }
3276
3280
  };
3281
+ Version.prototype.with = function (fields) {
3282
+ 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;
3283
+ return new Version(major, minor, patch, prerelease, build);
3284
+ };
3277
3285
  Version.prototype.toString = function () {
3278
3286
  var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
3279
3287
  if (ts.some(this.prerelease))
@@ -3282,7 +3290,7 @@ var ts;
3282
3290
  result += "+".concat(this.build.join("."));
3283
3291
  return result;
3284
3292
  };
3285
- Version.zero = new Version(0, 0, 0);
3293
+ Version.zero = new Version(0, 0, 0, ["0"]);
3286
3294
  return Version;
3287
3295
  }());
3288
3296
  ts.Version = Version;
@@ -3365,6 +3373,10 @@ var ts;
3365
3373
  }
3366
3374
  return undefined;
3367
3375
  };
3376
+ /**
3377
+ * Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
3378
+ * in `node-semver`.
3379
+ */
3368
3380
  VersionRange.prototype.test = function (version) {
3369
3381
  if (typeof version === "string")
3370
3382
  version = new Version(version);
@@ -3475,19 +3487,20 @@ var ts;
3475
3487
  break;
3476
3488
  case "<":
3477
3489
  case ">=":
3478
- comparators.push(createComparator(operator, version));
3490
+ comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
3491
+ createComparator(operator, version));
3479
3492
  break;
3480
3493
  case "<=":
3481
3494
  case ">":
3482
- comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
3483
- isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
3495
+ comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
3496
+ isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
3484
3497
  createComparator(operator, version));
3485
3498
  break;
3486
3499
  case "=":
3487
3500
  case undefined:
3488
3501
  if (isWildcard(minor) || isWildcard(patch)) {
3489
- comparators.push(createComparator(">=", version));
3490
- comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
3502
+ comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
3503
+ comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
3491
3504
  }
3492
3505
  else {
3493
3506
  comparators.push(createComparator("=", version));
@@ -5096,8 +5109,8 @@ var ts;
5096
5109
  NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
5097
5110
  NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
5098
5111
  NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
5099
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper";
5100
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding";
5112
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAccessInAsync"] = 2048] = "MethodWithSuperPropertyAccessInAsync";
5113
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAssignmentInAsync"] = 4096] = "MethodWithSuperPropertyAssignmentInAsync";
5101
5114
  NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
5102
5115
  NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
5103
5116
  NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
@@ -6732,7 +6745,7 @@ var ts;
6732
6745
  }
6733
6746
  /*@internal*/
6734
6747
  function createSystemWatchFunctions(_a) {
6735
- 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;
6748
+ 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;
6736
6749
  var pollingWatches = new ts.Map();
6737
6750
  var fsWatches = new ts.Map();
6738
6751
  var fsWatchesRecursive = new ts.Map();
@@ -6798,8 +6811,8 @@ var ts;
6798
6811
  return useNonPollingWatchers ?
6799
6812
  // Use notifications from FS to watch with falling back to fs.watchFile
6800
6813
  generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
6801
- // Default to do not use fixed polling interval
6802
- { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.UseFsEvents };
6814
+ // Default to using fs events
6815
+ { watchFile: ts.WatchFileKind.UseFsEvents };
6803
6816
  }
6804
6817
  }
6805
6818
  function generateWatchFileOptions(watchFile, fallbackPolling, options) {
@@ -7071,7 +7084,6 @@ var ts;
7071
7084
  tscWatchFile: process.env.TSC_WATCHFILE,
7072
7085
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
7073
7086
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
7074
- defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7075
7087
  inodeWatching: isLinuxOrMacOs,
7076
7088
  sysLog: sysLog,
7077
7089
  }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
@@ -9582,6 +9594,10 @@ var ts;
9582
9594
  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"),
9583
9595
  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"),
9584
9596
  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}'"),
9597
+ 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}."),
9598
+ Matched_0_condition_1: diag(6403, ts.DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."),
9599
+ 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}'."),
9600
+ Saw_non_matching_condition_0: diag(6405, ts.DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
9585
9601
  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}'"),
9586
9602
  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."),
9587
9603
  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."),
@@ -9898,6 +9914,8 @@ var ts;
9898
9914
  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}\""),
9899
9915
  Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
9900
9916
  Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
9917
+ Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
9918
+ Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
9901
9919
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9902
9920
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9903
9921
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -11355,7 +11373,7 @@ var ts;
11355
11373
  return -1;
11356
11374
  }
11357
11375
  function peekExtendedUnicodeEscape() {
11358
- if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11376
+ if (codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11359
11377
  var start_2 = pos;
11360
11378
  pos += 3;
11361
11379
  var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
@@ -21658,6 +21676,32 @@ var ts;
21658
21676
  return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21659
21677
  }
21660
21678
  ts.getParameterTypeNode = getParameterTypeNode;
21679
+ function isTypeDeclaration(node) {
21680
+ switch (node.kind) {
21681
+ case 165 /* SyntaxKind.TypeParameter */:
21682
+ case 260 /* SyntaxKind.ClassDeclaration */:
21683
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
21684
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
21685
+ case 263 /* SyntaxKind.EnumDeclaration */:
21686
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
21687
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
21688
+ case 342 /* SyntaxKind.JSDocEnumTag */:
21689
+ return true;
21690
+ case 270 /* SyntaxKind.ImportClause */:
21691
+ return node.isTypeOnly;
21692
+ case 273 /* SyntaxKind.ImportSpecifier */:
21693
+ case 278 /* SyntaxKind.ExportSpecifier */:
21694
+ return node.parent.parent.isTypeOnly;
21695
+ default:
21696
+ return false;
21697
+ }
21698
+ }
21699
+ ts.isTypeDeclaration = isTypeDeclaration;
21700
+ function canHaveExportModifier(node) {
21701
+ return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
21702
+ || ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
21703
+ }
21704
+ ts.canHaveExportModifier = canHaveExportModifier;
21661
21705
  })(ts || (ts = {}));
21662
21706
  /* @internal */
21663
21707
  var ts;
@@ -21666,13 +21710,11 @@ var ts;
21666
21710
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21667
21711
  */
21668
21712
  function createBaseNodeFactory() {
21669
- // tslint:disable variable-name
21670
21713
  var NodeConstructor;
21671
21714
  var TokenConstructor;
21672
21715
  var IdentifierConstructor;
21673
21716
  var PrivateIdentifierConstructor;
21674
21717
  var SourceFileConstructor;
21675
- // tslint:enable variable-name
21676
21718
  return {
21677
21719
  createBaseSourceFileNode: createBaseSourceFileNode,
21678
21720
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -23136,7 +23178,7 @@ var ts;
23136
23178
  return node;
23137
23179
  }
23138
23180
  // @api
23139
- function createIdentifier(text, typeArguments, originalKeywordKind) {
23181
+ function createIdentifier(text, typeArguments, originalKeywordKind, hasExtendedUnicodeEscape) {
23140
23182
  var node = createBaseIdentifier(text, originalKeywordKind);
23141
23183
  if (typeArguments) {
23142
23184
  // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
@@ -23145,6 +23187,10 @@ var ts;
23145
23187
  if (node.originalKeywordKind === 133 /* SyntaxKind.AwaitKeyword */) {
23146
23188
  node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */;
23147
23189
  }
23190
+ if (hasExtendedUnicodeEscape) {
23191
+ node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
23192
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
23193
+ }
23148
23194
  return node;
23149
23195
  }
23150
23196
  // @api
@@ -27600,11 +27646,9 @@ var ts;
27600
27646
  rawTextScanner.setText("`" + rawText + "`");
27601
27647
  break;
27602
27648
  case 15 /* SyntaxKind.TemplateHead */:
27603
- // tslint:disable-next-line no-invalid-template-strings
27604
27649
  rawTextScanner.setText("`" + rawText + "${");
27605
27650
  break;
27606
27651
  case 16 /* SyntaxKind.TemplateMiddle */:
27607
- // tslint:disable-next-line no-invalid-template-strings
27608
27652
  rawTextScanner.setText("}" + rawText + "${");
27609
27653
  break;
27610
27654
  case 17 /* SyntaxKind.TemplateTail */:
@@ -27963,7 +28007,6 @@ var ts;
27963
28007
  return node;
27964
28008
  }
27965
28009
  ts.createInputFiles = createInputFiles;
27966
- // tslint:disable-next-line variable-name
27967
28010
  var SourceMapSource;
27968
28011
  /**
27969
28012
  * Create an external source map source file reference
@@ -28755,6 +28798,8 @@ var ts;
28755
28798
  // - The verb (`next`, `throw`, or `return` method) to delegate to the expression
28756
28799
  // of a `yield*`.
28757
28800
  // - The result of evaluating the verb delegated to the expression of a `yield*`.
28801
+ // g A temporary variable that holds onto the generator object until the generator
28802
+ // is started, allowing it to also act as the `suspendedStart` state.
28758
28803
  //
28759
28804
  // functions:
28760
28805
  // verb(n) Creates a bound callback to the `step` function for opcode `n`.
@@ -28793,7 +28838,7 @@ var ts;
28793
28838
  importName: "__generator",
28794
28839
  scoped: false,
28795
28840
  priority: 6,
28796
- 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 };"
28841
+ 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 };"
28797
28842
  };
28798
28843
  // ES Module Helpers
28799
28844
  ts.createBindingHelper = {
@@ -32097,13 +32142,11 @@ var ts;
32097
32142
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32098
32143
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32099
32144
  // capture constructors in 'initializeState' to avoid null checks
32100
- // tslint:disable variable-name
32101
32145
  var NodeConstructor;
32102
32146
  var TokenConstructor;
32103
32147
  var IdentifierConstructor;
32104
32148
  var PrivateIdentifierConstructor;
32105
32149
  var SourceFileConstructor;
32106
- // tslint:enable variable-name
32107
32150
  function countNode(node) {
32108
32151
  nodeCount++;
32109
32152
  return node;
@@ -33079,8 +33122,9 @@ var ts;
33079
33122
  // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
33080
33123
  var originalKeywordKind = token();
33081
33124
  var text = internIdentifier(scanner.getTokenValue());
33125
+ var hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
33082
33126
  nextTokenWithoutCheck();
33083
- return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
33127
+ return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind, hasExtendedUnicodeEscape), pos);
33084
33128
  }
33085
33129
  if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
33086
33130
  parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
@@ -40329,9 +40373,6 @@ var ts;
40329
40373
  name: "listFilesOnly",
40330
40374
  type: "boolean",
40331
40375
  category: ts.Diagnostics.Command_line_Options,
40332
- affectsSemanticDiagnostics: true,
40333
- affectsEmit: true,
40334
- affectsMultiFileEmitBuildInfo: true,
40335
40376
  isCommandLineOnly: true,
40336
40377
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
40337
40378
  defaultValueDescription: false,
@@ -42059,12 +42100,14 @@ var ts;
42059
42100
  return config;
42060
42101
  }
42061
42102
  ts.convertToTSConfig = convertToTSConfig;
42103
+ /*@internal*/
42062
42104
  function optionMapToObject(optionMap) {
42063
42105
  return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
42064
42106
  var _a;
42065
42107
  return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
42066
42108
  }, {}));
42067
42109
  }
42110
+ ts.optionMapToObject = optionMapToObject;
42068
42111
  function filterSameAsDefaultInclude(specs) {
42069
42112
  if (!ts.length(specs))
42070
42113
  return undefined;
@@ -42113,9 +42156,11 @@ var ts;
42113
42156
  });
42114
42157
  }
42115
42158
  ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
42159
+ /* @internal */
42116
42160
  function serializeCompilerOptions(options, pathOptions) {
42117
42161
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
42118
42162
  }
42163
+ ts.serializeCompilerOptions = serializeCompilerOptions;
42119
42164
  function serializeWatchOptions(options) {
42120
42165
  return serializeOptionBaseObject(options, getWatchOptionsNameMap());
42121
42166
  }
@@ -42219,12 +42264,23 @@ var ts;
42219
42264
  }
42220
42265
  function writeConfigurations() {
42221
42266
  // Filter applicable options to place in the file
42222
- var categorizedOptions = ts.createMultiMap();
42267
+ var categorizedOptions = new ts.Map();
42268
+ // Set allowed categories in order
42269
+ categorizedOptions.set(ts.Diagnostics.Projects, []);
42270
+ categorizedOptions.set(ts.Diagnostics.Language_and_Environment, []);
42271
+ categorizedOptions.set(ts.Diagnostics.Modules, []);
42272
+ categorizedOptions.set(ts.Diagnostics.JavaScript_Support, []);
42273
+ categorizedOptions.set(ts.Diagnostics.Emit, []);
42274
+ categorizedOptions.set(ts.Diagnostics.Interop_Constraints, []);
42275
+ categorizedOptions.set(ts.Diagnostics.Type_Checking, []);
42276
+ categorizedOptions.set(ts.Diagnostics.Completeness, []);
42223
42277
  for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
42224
42278
  var option = optionDeclarations_1[_i];
42225
- var category = option.category;
42226
42279
  if (isAllowedOptionForOutput(option)) {
42227
- categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
42280
+ var listForCategory = categorizedOptions.get(option.category);
42281
+ if (!listForCategory)
42282
+ categorizedOptions.set(option.category, listForCategory = []);
42283
+ listForCategory.push(option);
42228
42284
  }
42229
42285
  }
42230
42286
  // Serialize all options and their descriptions
@@ -42235,7 +42291,7 @@ var ts;
42235
42291
  if (entries.length !== 0) {
42236
42292
  entries.push({ value: "" });
42237
42293
  }
42238
- entries.push({ value: "/* ".concat(category, " */") });
42294
+ entries.push({ value: "/* ".concat(ts.getLocaleSpecificMessage(category), " */") });
42239
42295
  for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
42240
42296
  var option = options_1[_i];
42241
42297
  var optionName = void 0;
@@ -44277,6 +44333,9 @@ var ts;
44277
44333
  requestContainingDirectory: containingDirectory,
44278
44334
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44279
44335
  };
44336
+ if (traceEnabled && ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) <= ts.ModuleResolutionKind.NodeNext) {
44337
+ trace(host, ts.Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(function (c) { return "'".concat(c, "'"); }).join(", "));
44338
+ }
44280
44339
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
44281
44340
  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);
44282
44341
  function tryResolve(extensions) {
@@ -44866,7 +44925,7 @@ var ts;
44866
44925
  }
44867
44926
  if (mainExport) {
44868
44927
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
44869
- return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
44928
+ return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false, ".");
44870
44929
  }
44871
44930
  }
44872
44931
  else if (allKeysStartWithDot(scope.contents.packageJsonContent.exports)) {
@@ -44946,7 +45005,7 @@ var ts;
44946
45005
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44947
45006
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
44948
45007
  var target = lookupTable[moduleName];
44949
- return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
45008
+ return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
44950
45009
  }
44951
45010
  var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
44952
45011
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
@@ -44955,17 +45014,17 @@ var ts;
44955
45014
  var target = lookupTable[potentialTarget];
44956
45015
  var starPos = potentialTarget.indexOf("*");
44957
45016
  var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
44958
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
45017
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
44959
45018
  }
44960
45019
  else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
44961
45020
  var target = lookupTable[potentialTarget];
44962
45021
  var subpath = moduleName.substring(potentialTarget.length - 1);
44963
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
45022
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
44964
45023
  }
44965
45024
  else if (ts.startsWith(moduleName, potentialTarget)) {
44966
45025
  var target = lookupTable[potentialTarget];
44967
45026
  var subpath = moduleName.substring(potentialTarget.length);
44968
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
45027
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false, potentialTarget);
44969
45028
  }
44970
45029
  }
44971
45030
  function matchesPatternWithTrailer(target, name) {
@@ -44982,7 +45041,7 @@ var ts;
44982
45041
  */
44983
45042
  function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
44984
45043
  return loadModuleFromTargetImportOrExport;
44985
- function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
45044
+ function loadModuleFromTargetImportOrExport(target, subpath, pattern, key) {
44986
45045
  if (typeof target === "string") {
44987
45046
  if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
44988
45047
  if (state.traceEnabled) {
@@ -44993,6 +45052,8 @@ var ts;
44993
45052
  if (!ts.startsWith(target, "./")) {
44994
45053
  if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
44995
45054
  var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
45055
+ traceIfEnabled(state, ts.Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
45056
+ traceIfEnabled(state, ts.Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
44996
45057
  var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
44997
45058
  return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
44998
45059
  }
@@ -45019,6 +45080,9 @@ var ts;
45019
45080
  }
45020
45081
  return toSearchResult(/*value*/ undefined);
45021
45082
  }
45083
+ if (state.traceEnabled) {
45084
+ trace(state.host, ts.Diagnostics.Using_0_subpath_1_with_target_2, isImports ? "imports" : "exports", key, pattern ? target.replace(/\*/g, subpath) : target + subpath);
45085
+ }
45022
45086
  var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
45023
45087
  var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
45024
45088
  if (inputLink)
@@ -45028,14 +45092,18 @@ var ts;
45028
45092
  else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
45029
45093
  if (!Array.isArray(target)) {
45030
45094
  for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
45031
- var key = _a[_i];
45032
- if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
45033
- var subTarget = target[key];
45034
- var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
45095
+ var condition = _a[_i];
45096
+ if (condition === "default" || state.conditions.indexOf(condition) >= 0 || isApplicableVersionedTypesKey(state.conditions, condition)) {
45097
+ traceIfEnabled(state, ts.Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
45098
+ var subTarget = target[condition];
45099
+ var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern, key);
45035
45100
  if (result) {
45036
45101
  return result;
45037
45102
  }
45038
45103
  }
45104
+ else {
45105
+ traceIfEnabled(state, ts.Diagnostics.Saw_non_matching_condition_0, condition);
45106
+ }
45039
45107
  }
45040
45108
  return undefined;
45041
45109
  }
@@ -45048,7 +45116,7 @@ var ts;
45048
45116
  }
45049
45117
  for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
45050
45118
  var elem = target_2[_b];
45051
- var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
45119
+ var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern, key);
45052
45120
  if (result) {
45053
45121
  return result;
45054
45122
  }
@@ -45464,6 +45532,15 @@ var ts;
45464
45532
  function toSearchResult(value) {
45465
45533
  return value !== undefined ? { value: value } : undefined;
45466
45534
  }
45535
+ function traceIfEnabled(state, diagnostic) {
45536
+ var args = [];
45537
+ for (var _i = 2; _i < arguments.length; _i++) {
45538
+ args[_i - 2] = arguments[_i];
45539
+ }
45540
+ if (state.traceEnabled) {
45541
+ trace.apply(void 0, __spreadArray([state.host, diagnostic], args, false));
45542
+ }
45543
+ }
45467
45544
  })(ts || (ts = {}));
45468
45545
  /* @internal */
45469
45546
  var ts;
@@ -49055,8 +49132,6 @@ var ts;
49055
49132
  IntersectionState[IntersectionState["None"] = 0] = "None";
49056
49133
  IntersectionState[IntersectionState["Source"] = 1] = "Source";
49057
49134
  IntersectionState[IntersectionState["Target"] = 2] = "Target";
49058
- IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
49059
- IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
49060
49135
  })(IntersectionState || (IntersectionState = {}));
49061
49136
  var RecursionFlags;
49062
49137
  (function (RecursionFlags) {
@@ -49475,6 +49550,12 @@ var ts;
49475
49550
  getOptionalType: function () { return optionalType; },
49476
49551
  getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
49477
49552
  getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
49553
+ getAsyncIterableType: function () {
49554
+ var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
49555
+ if (type === emptyGenericType)
49556
+ return undefined;
49557
+ return type;
49558
+ },
49478
49559
  isSymbolAccessible: isSymbolAccessible,
49479
49560
  isArrayType: isArrayType,
49480
49561
  isTupleType: isTupleType,
@@ -50312,9 +50393,9 @@ var ts;
50312
50393
  return symbol;
50313
50394
  }
50314
50395
  if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
50315
- var target = resolveAlias(symbol);
50316
- // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors
50317
- if (target === unknownSymbol || target.flags & meaning) {
50396
+ var targetFlags = getAllSymbolFlags(symbol);
50397
+ // `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
50398
+ if (targetFlags & meaning) {
50318
50399
  return symbol;
50319
50400
  }
50320
50401
  }
@@ -50947,8 +51028,8 @@ var ts;
50947
51028
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50948
51029
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50949
51030
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
51031
+ !checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
50950
51032
  !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
50951
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50952
51033
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50953
51034
  var suggestion = void 0;
50954
51035
  var suggestedLib = void 0;
@@ -51035,7 +51116,7 @@ var ts;
51035
51116
  }
51036
51117
  }
51037
51118
  if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
51038
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
51119
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
51039
51120
  if (typeOnlyDeclaration) {
51040
51121
  var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
51041
51122
  ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
@@ -51198,7 +51279,7 @@ var ts;
51198
51279
  return false;
51199
51280
  }
51200
51281
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
51201
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) {
51282
+ if (meaning & 111551 /* SymbolFlags.Value */) {
51202
51283
  if (isPrimitiveTypeName(name)) {
51203
51284
  if (isExtendedByInterface(errorLocation)) {
51204
51285
  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));
@@ -51209,7 +51290,8 @@ var ts;
51209
51290
  return true;
51210
51291
  }
51211
51292
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51212
- if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) {
51293
+ var allFlags = symbol && getAllSymbolFlags(symbol);
51294
+ if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
51213
51295
  var rawName = ts.unescapeLeadingUnderscores(name);
51214
51296
  if (isES2015OrLaterConstructorName(name)) {
51215
51297
  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);
@@ -51257,16 +51339,16 @@ var ts;
51257
51339
  }
51258
51340
  return false;
51259
51341
  }
51260
- function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
51261
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) {
51262
- var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51342
+ function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
51343
+ if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
51344
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51263
51345
  if (symbol) {
51264
51346
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
51265
51347
  return true;
51266
51348
  }
51267
51349
  }
51268
- else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) {
51269
- var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51350
+ else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
51351
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51270
51352
  if (symbol) {
51271
51353
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
51272
51354
  return true;
@@ -51856,6 +51938,52 @@ var ts;
51856
51938
  }
51857
51939
  return undefined;
51858
51940
  }
51941
+ /**
51942
+ * Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
51943
+ * is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
51944
+ * with another exported symbol, e.g.
51945
+ * ```ts
51946
+ * // a.ts
51947
+ * export const a = 0;
51948
+ * // b.ts
51949
+ * export { a } from "./a";
51950
+ * export type a = number;
51951
+ * // c.ts
51952
+ * import { a } from "./b";
51953
+ * ```
51954
+ * Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
51955
+ * from b.ts, even though there is still more alias to resolve. Consequently, if we were
51956
+ * trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
51957
+ * the local symbol and on the symbol returned by `resolveAlias` is not enough.
51958
+ * @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
51959
+ * combined flags of all alias targets otherwise.
51960
+ */
51961
+ function getAllSymbolFlags(symbol) {
51962
+ var flags = symbol.flags;
51963
+ var seenSymbols;
51964
+ while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
51965
+ var target = resolveAlias(symbol);
51966
+ if (target === unknownSymbol) {
51967
+ return 67108863 /* SymbolFlags.All */;
51968
+ }
51969
+ // Optimizations - try to avoid creating or adding to
51970
+ // `seenSymbols` if possible
51971
+ if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
51972
+ break;
51973
+ }
51974
+ if (target.flags & 2097152 /* SymbolFlags.Alias */) {
51975
+ if (seenSymbols) {
51976
+ seenSymbols.add(target);
51977
+ }
51978
+ else {
51979
+ seenSymbols = new ts.Set([symbol, target]);
51980
+ }
51981
+ }
51982
+ flags |= target.flags;
51983
+ symbol = target;
51984
+ }
51985
+ return flags;
51986
+ }
51859
51987
  /**
51860
51988
  * Marks a symbol as type-only if its declaration is syntactically type-only.
51861
51989
  * If it is not itself marked type-only, but resolves to a type-only alias
@@ -51901,19 +52029,25 @@ var ts;
51901
52029
  return !!aliasDeclarationLinks.typeOnlyDeclaration;
51902
52030
  }
51903
52031
  /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
51904
- function getTypeOnlyAliasDeclaration(symbol) {
52032
+ function getTypeOnlyAliasDeclaration(symbol, include) {
51905
52033
  if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
51906
52034
  return undefined;
51907
52035
  }
51908
52036
  var links = getSymbolLinks(symbol);
51909
- return links.typeOnlyDeclaration || undefined;
52037
+ if (include === undefined) {
52038
+ return links.typeOnlyDeclaration || undefined;
52039
+ }
52040
+ if (links.typeOnlyDeclaration) {
52041
+ return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
52042
+ }
52043
+ return undefined;
51910
52044
  }
51911
52045
  function markExportAsReferenced(node) {
51912
52046
  var symbol = getSymbolOfNode(node);
51913
52047
  var target = resolveAlias(symbol);
51914
52048
  if (target) {
51915
52049
  var markAlias = target === unknownSymbol ||
51916
- ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
52050
+ ((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
51917
52051
  if (markAlias) {
51918
52052
  markAliasSymbolAsReferenced(symbol);
51919
52053
  }
@@ -51933,8 +52067,7 @@ var ts;
51933
52067
  // This way a chain of imports can be elided if ultimately the final input is only used in a type
51934
52068
  // position.
51935
52069
  if (ts.isInternalModuleImportEqualsDeclaration(node)) {
51936
- var target = resolveSymbol(symbol);
51937
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
52070
+ if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
51938
52071
  // import foo = <symbol>
51939
52072
  checkExpressionCached(node.moduleReference);
51940
52073
  }
@@ -52756,7 +52889,7 @@ var ts;
52756
52889
  }
52757
52890
  function symbolIsValue(symbol, includeTypeOnlyMembers) {
52758
52891
  return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
52759
- symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52892
+ symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52760
52893
  }
52761
52894
  function findConstructorDeclaration(node) {
52762
52895
  var members = node.members;
@@ -53025,8 +53158,10 @@ var ts;
53025
53158
  return true;
53026
53159
  }
53027
53160
  // Qualify if the symbol from symbol table has same meaning as expected
53028
- symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53029
- if (symbolFromSymbolTable.flags & meaning) {
53161
+ var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
53162
+ symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53163
+ var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
53164
+ if (flags & meaning) {
53030
53165
  qualify = true;
53031
53166
  return true;
53032
53167
  }
@@ -55338,7 +55473,7 @@ var ts;
55338
55473
  // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
55339
55474
  var indices = ts.indicesOf(statements);
55340
55475
  var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
55341
- if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
55476
+ if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
55342
55477
  for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
55343
55478
  var index_1 = associatedIndices_1[_i];
55344
55479
  statements[index_1] = addExportModifier(statements[index_1]);
@@ -55372,15 +55507,6 @@ var ts;
55372
55507
  }
55373
55508
  return statements;
55374
55509
  }
55375
- function canHaveExportModifier(node) {
55376
- return ts.isEnumDeclaration(node) ||
55377
- ts.isVariableStatement(node) ||
55378
- ts.isFunctionDeclaration(node) ||
55379
- ts.isClassDeclaration(node) ||
55380
- (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
55381
- ts.isInterfaceDeclaration(node) ||
55382
- isTypeDeclaration(node);
55383
- }
55384
55510
  function addExportModifier(node) {
55385
55511
  var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
55386
55512
  return ts.factory.updateModifiers(node, flags);
@@ -55627,7 +55753,7 @@ var ts;
55627
55753
  (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
55628
55754
  if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
55629
55755
  enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
55630
- canHaveExportModifier(node)) {
55756
+ ts.canHaveExportModifier(node)) {
55631
55757
  // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
55632
55758
  newModifierFlags |= 1 /* ModifierFlags.Export */;
55633
55759
  }
@@ -55683,7 +55809,7 @@ var ts;
55683
55809
  return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
55684
55810
  }
55685
55811
  function isTypeOnlyNamespace(symbol) {
55686
- return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); });
55812
+ return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
55687
55813
  }
55688
55814
  function serializeModule(symbol, symbolName, modifierFlags) {
55689
55815
  var members = getNamespaceMembersForSerialization(symbol);
@@ -57597,16 +57723,32 @@ var ts;
57597
57723
  return getTypeFromTypeNode(typeNode);
57598
57724
  }
57599
57725
  }
57726
+ function isParameterOfContextSensitiveSignature(symbol) {
57727
+ var decl = symbol.valueDeclaration;
57728
+ if (!decl) {
57729
+ return false;
57730
+ }
57731
+ if (ts.isBindingElement(decl)) {
57732
+ decl = ts.walkUpBindingElementsAndPatterns(decl);
57733
+ }
57734
+ if (ts.isParameter(decl)) {
57735
+ return isContextSensitiveFunctionOrObjectLiteralMethod(decl.parent);
57736
+ }
57737
+ return false;
57738
+ }
57600
57739
  function getTypeOfVariableOrParameterOrProperty(symbol) {
57601
57740
  var links = getSymbolLinks(symbol);
57602
57741
  if (!links.type) {
57603
57742
  var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
57604
57743
  // For a contextually typed parameter it is possible that a type has already
57605
57744
  // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
57606
- // to preserve this type.
57607
- if (!links.type) {
57745
+ // to preserve this type. In fact, we need to _prefer_ that type, but it won't
57746
+ // be assigned until contextual typing is complete, so we need to defer in
57747
+ // cases where contextual typing may take place.
57748
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
57608
57749
  links.type = type;
57609
57750
  }
57751
+ return type;
57610
57752
  }
57611
57753
  return links.type;
57612
57754
  }
@@ -57903,7 +58045,7 @@ var ts;
57903
58045
  links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
57904
58046
  : isDuplicatedCommonJSExport(symbol.declarations) ? autoType
57905
58047
  : declaredType ? declaredType
57906
- : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
58048
+ : getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
57907
58049
  : errorType;
57908
58050
  }
57909
58051
  return links.type;
@@ -59786,7 +59928,20 @@ var ts;
59786
59928
  return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
59787
59929
  }
59788
59930
  function isGenericMappedType(type) {
59789
- return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type));
59931
+ if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
59932
+ var constraint = getConstraintTypeFromMappedType(type);
59933
+ if (isGenericIndexType(constraint)) {
59934
+ return true;
59935
+ }
59936
+ // A mapped type is generic if the 'as' clause references generic types other than the iteration type.
59937
+ // To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
59938
+ // type and check whether the resulting type is generic.
59939
+ var nameType = getNameTypeFromMappedType(type);
59940
+ if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
59941
+ return true;
59942
+ }
59943
+ }
59944
+ return false;
59790
59945
  }
59791
59946
  function resolveStructuredTypeMembers(type) {
59792
59947
  if (!type.members) {
@@ -60256,7 +60411,7 @@ var ts;
60256
60411
  var indexTypes;
60257
60412
  var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
60258
60413
  // Flags we want to propagate to the result if they exist in all source symbols
60259
- var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */;
60414
+ var optionalFlag;
60260
60415
  var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
60261
60416
  var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
60262
60417
  var mergedInstantiations = false;
@@ -60267,11 +60422,14 @@ var ts;
60267
60422
  var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
60268
60423
  var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
60269
60424
  if (prop) {
60270
- if (isUnion) {
60271
- optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60272
- }
60273
- else {
60274
- optionalFlag &= prop.flags;
60425
+ if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
60426
+ optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
60427
+ if (isUnion) {
60428
+ optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60429
+ }
60430
+ else {
60431
+ optionalFlag &= prop.flags;
60432
+ }
60275
60433
  }
60276
60434
  if (!singleProp) {
60277
60435
  singleProp = prop;
@@ -60390,7 +60548,7 @@ var ts;
60390
60548
  propTypes.push(type);
60391
60549
  }
60392
60550
  ts.addRange(propTypes, indexTypes);
60393
- var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
60551
+ var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
60394
60552
  result.containingType = containingType;
60395
60553
  if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
60396
60554
  result.valueDeclaration = firstValueDeclaration;
@@ -63103,8 +63261,14 @@ var ts;
63103
63261
  return getStringLiteralType(text);
63104
63262
  }
63105
63263
  newTexts.push(text);
63106
- if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63107
- return stringType;
63264
+ if (ts.every(newTexts, function (t) { return t === ""; })) {
63265
+ if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63266
+ return stringType;
63267
+ }
63268
+ // Normalize `${Mapping<xxx>}` into Mapping<xxx>
63269
+ if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
63270
+ return newTypes[0];
63271
+ }
63108
63272
  }
63109
63273
  var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
63110
63274
  var type = templateLiteralTypes.get(id);
@@ -63163,12 +63327,14 @@ var ts;
63163
63327
  }
63164
63328
  function getStringMappingType(symbol, type) {
63165
63329
  return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
63166
- // Mapping<Mapping<T>> === Mapping<T>
63167
- type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63168
- isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
63169
- type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63170
- type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63171
- type;
63330
+ type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63331
+ type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63332
+ // Mapping<Mapping<T>> === Mapping<T>
63333
+ type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63334
+ type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
63335
+ // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
63336
+ isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
63337
+ type;
63172
63338
  }
63173
63339
  function applyStringMapping(symbol, str) {
63174
63340
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -63333,7 +63499,18 @@ var ts;
63333
63499
  return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63334
63500
  }
63335
63501
  errorIfWritingToReadonlyIndex(indexInfo);
63336
- return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63502
+ // When accessing an enum object with its own type,
63503
+ // e.g. E[E.A] for enum E { A }, undefined shouldn't
63504
+ // be included in the result type
63505
+ if ((accessFlags & 1 /* AccessFlags.IncludeUndefined */) &&
63506
+ !(objectType.symbol &&
63507
+ objectType.symbol.flags & (256 /* SymbolFlags.RegularEnum */ | 128 /* SymbolFlags.ConstEnum */) &&
63508
+ (indexType.symbol &&
63509
+ indexType.flags & 1024 /* TypeFlags.EnumLiteral */ &&
63510
+ getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
63511
+ return getUnionType([indexInfo.type, undefinedType]);
63512
+ }
63513
+ return indexInfo.type;
63337
63514
  }
63338
63515
  if (indexType.flags & 131072 /* TypeFlags.Never */) {
63339
63516
  return neverType;
@@ -63436,10 +63613,11 @@ var ts;
63436
63613
  accessNode;
63437
63614
  }
63438
63615
  function isPatternLiteralPlaceholderType(type) {
63439
- return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type));
63616
+ return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
63440
63617
  }
63441
63618
  function isPatternLiteralType(type) {
63442
- return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
63619
+ return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
63620
+ !!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
63443
63621
  }
63444
63622
  function isGenericType(type) {
63445
63623
  return !!getGenericObjectFlags(type);
@@ -63718,18 +63896,23 @@ var ts;
63718
63896
  var result;
63719
63897
  var extraTypes;
63720
63898
  var tailCount = 0;
63721
- var _loop_20 = function () {
63899
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
63900
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
63901
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
63902
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63903
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
63904
+ while (true) {
63722
63905
  if (tailCount === 1000) {
63723
63906
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
63724
63907
  result = errorType;
63725
- return "break";
63908
+ break;
63726
63909
  }
63727
63910
  var isUnwrapped = isTypicalNondistributiveConditional(root);
63728
63911
  var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
63729
63912
  var checkTypeInstantiable = isGenericType(checkType);
63730
63913
  var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
63731
63914
  if (checkType === wildcardType || extendsType === wildcardType) {
63732
- return { value: wildcardType };
63915
+ return wildcardType;
63733
63916
  }
63734
63917
  var combinedMapper = void 0;
63735
63918
  if (root.inferTypeParameters) {
@@ -63762,11 +63945,7 @@ var ts;
63762
63945
  }
63763
63946
  }
63764
63947
  }
63765
- // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
63766
- // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
63767
- // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
63768
- // so in those cases we refain from performing inference and retain the uninfered type parameter
63769
- if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
63948
+ if (!checkTypeInstantiable) {
63770
63949
  // We don't want inferences from constraints as they may cause us to eagerly resolve the
63771
63950
  // conditional type instead of deferring resolution. Also, we always want strict function
63772
63951
  // types rules (i.e. proper contravariance) for inferences.
@@ -63798,14 +63977,14 @@ var ts;
63798
63977
  var newRoot = falseType_1.root;
63799
63978
  if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
63800
63979
  root = newRoot;
63801
- return "continue";
63980
+ continue;
63802
63981
  }
63803
63982
  if (canTailRecurse(falseType_1, mapper)) {
63804
- return "continue";
63983
+ continue;
63805
63984
  }
63806
63985
  }
63807
63986
  result = instantiateType(falseType_1, mapper);
63808
- return "break";
63987
+ break;
63809
63988
  }
63810
63989
  // Return trueType for a definitely true extends check. We check instantiations of the two
63811
63990
  // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
@@ -63816,10 +63995,10 @@ var ts;
63816
63995
  var trueType_1 = getTypeFromTypeNode(root.node.trueType);
63817
63996
  var trueMapper = combinedMapper || mapper;
63818
63997
  if (canTailRecurse(trueType_1, trueMapper)) {
63819
- return "continue";
63998
+ continue;
63820
63999
  }
63821
64000
  result = instantiateType(trueType_1, trueMapper);
63822
- return "break";
64001
+ break;
63823
64002
  }
63824
64003
  }
63825
64004
  // Return a deferred type for a check that is neither definitely true nor definitely false
@@ -63831,19 +64010,7 @@ var ts;
63831
64010
  result.combinedMapper = combinedMapper;
63832
64011
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
63833
64012
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
63834
- return "break";
63835
- };
63836
- // We loop here for an immediately nested conditional type in the false position, effectively treating
63837
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
63838
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
63839
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63840
- // cases we increment the tail recursion counter and stop after 1000 iterations.
63841
- while (true) {
63842
- var state_6 = _loop_20();
63843
- if (typeof state_6 === "object")
63844
- return state_6.value;
63845
- if (state_6 === "break")
63846
- break;
64013
+ break;
63847
64014
  }
63848
64015
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
63849
64016
  // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -66297,7 +66464,7 @@ var ts;
66297
66464
  return 0 /* Ternary.False */;
66298
66465
  }
66299
66466
  }
66300
- var isPerformingCommonPropertyChecks = (relation !== comparableRelation || !(source.flags & 1048576 /* TypeFlags.Union */) && isLiteralType(source)) &&
66467
+ var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
66301
66468
  !(intersectionState & 2 /* IntersectionState.Target */) &&
66302
66469
  source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
66303
66470
  target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
@@ -66325,27 +66492,6 @@ var ts;
66325
66492
  var result_7 = skipCaching ?
66326
66493
  unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
66327
66494
  recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
66328
- // For certain combinations involving intersections and optional, excess, or mismatched properties we need
66329
- // an extra property check where the intersection is viewed as a single object. The following are motivating
66330
- // examples that all should be errors, but aren't without this extra property check:
66331
- //
66332
- // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
66333
- //
66334
- // declare let wrong: { a: { y: string } };
66335
- // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
66336
- //
66337
- // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
66338
- // x = y; // Mismatched property in source intersection
66339
- // }
66340
- //
66341
- // We suppress recursive intersection property checks because they can generate lots of work when relating
66342
- // recursive intersections that are structurally similar but not exactly identical. See #37854.
66343
- if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
66344
- 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 */); }))) {
66345
- inPropertyCheck = true;
66346
- result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
66347
- inPropertyCheck = false;
66348
- }
66349
66495
  if (result_7) {
66350
66496
  return result_7;
66351
66497
  }
@@ -66457,7 +66603,7 @@ var ts;
66457
66603
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
66458
66604
  checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
66459
66605
  }
66460
- var _loop_21 = function (prop) {
66606
+ var _loop_20 = function (prop) {
66461
66607
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
66462
66608
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
66463
66609
  if (reportErrors) {
@@ -66520,9 +66666,9 @@ var ts;
66520
66666
  };
66521
66667
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
66522
66668
  var prop = _b[_i];
66523
- var state_7 = _loop_21(prop);
66524
- if (typeof state_7 === "object")
66525
- return state_7.value;
66669
+ var state_6 = _loop_20(prop);
66670
+ if (typeof state_6 === "object")
66671
+ return state_6.value;
66526
66672
  }
66527
66673
  return false;
66528
66674
  }
@@ -66743,8 +66889,7 @@ var ts;
66743
66889
  if (overflow) {
66744
66890
  return 0 /* Ternary.False */;
66745
66891
  }
66746
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0);
66747
- var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
66892
+ var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
66748
66893
  var entry = relation.get(id);
66749
66894
  if (entry !== undefined) {
66750
66895
  if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
@@ -66774,7 +66919,7 @@ var ts;
66774
66919
  // A key that starts with "*" is an indication that we have type references that reference constrained
66775
66920
  // type parameters. For such keys we also check against the key we would have gotten if all type parameters
66776
66921
  // were unconstrained.
66777
- var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
66922
+ var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
66778
66923
  for (var i = 0; i < maybeCount; i++) {
66779
66924
  // If source and target are already being compared, consider them related with assumptions
66780
66925
  if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
@@ -66861,7 +67006,7 @@ var ts;
66861
67006
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
66862
67007
  var saveErrorInfo = captureErrorCalculationState();
66863
67008
  var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
66864
- if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
67009
+ if (relation !== identityRelation) {
66865
67010
  // The combined constraint of an intersection type is the intersection of the constraints of
66866
67011
  // the constituents. When an intersection type contains instantiable types with union type
66867
67012
  // constraints, there are situations where we need to examine the combined constraint. One is
@@ -66875,10 +67020,33 @@ var ts;
66875
67020
  // needs to have its constraint hoisted into an intersection with said type parameter, this way
66876
67021
  // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
66877
67022
  // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
66878
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
66879
- if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66880
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66881
- result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
67023
+ if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
67024
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
67025
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
67026
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
67027
+ result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
67028
+ }
67029
+ }
67030
+ // For certain combinations involving intersections and optional, excess, or mismatched properties we need
67031
+ // an extra property check where the intersection is viewed as a single object. The following are motivating
67032
+ // examples that all should be errors, but aren't without this extra property check:
67033
+ //
67034
+ // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
67035
+ //
67036
+ // declare let wrong: { a: { y: string } };
67037
+ // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
67038
+ //
67039
+ // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
67040
+ // x = y; // Mismatched property in source intersection
67041
+ // }
67042
+ //
67043
+ // We suppress recursive intersection property checks because they can generate lots of work when relating
67044
+ // recursive intersections that are structurally similar but not exactly identical. See #37854.
67045
+ if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
67046
+ 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 */); }))) {
67047
+ inPropertyCheck = true;
67048
+ result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
67049
+ inPropertyCheck = false;
66882
67050
  }
66883
67051
  }
66884
67052
  if (result) {
@@ -66887,9 +67055,6 @@ var ts;
66887
67055
  return result;
66888
67056
  }
66889
67057
  function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
66890
- if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
66891
- return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
66892
- }
66893
67058
  var result;
66894
67059
  var originalErrorInfo;
66895
67060
  var varianceCheckFailed = false;
@@ -66990,7 +67155,7 @@ var ts;
66990
67155
  // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
66991
67156
  var constraint = getConstraintOfTypeParameter(source);
66992
67157
  if (constraint && hasNonCircularBaseConstraint(source)) {
66993
- while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
67158
+ while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
66994
67159
  if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
66995
67160
  return result;
66996
67161
  }
@@ -67513,11 +67678,11 @@ var ts;
67513
67678
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
67514
67679
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
67515
67680
  var matchingTypes = [];
67516
- var _loop_22 = function (combination) {
67681
+ var _loop_21 = function (combination) {
67517
67682
  var hasMatch = false;
67518
67683
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
67519
67684
  var type = _d[_c];
67520
- var _loop_23 = function (i) {
67685
+ var _loop_22 = function (i) {
67521
67686
  var sourceProperty = sourcePropertiesFiltered[i];
67522
67687
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
67523
67688
  if (!targetProperty)
@@ -67533,8 +67698,8 @@ var ts;
67533
67698
  }
67534
67699
  };
67535
67700
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
67536
- var state_9 = _loop_23(i);
67537
- switch (state_9) {
67701
+ var state_8 = _loop_22(i);
67702
+ switch (state_8) {
67538
67703
  case "continue-outer": continue outer;
67539
67704
  }
67540
67705
  }
@@ -67547,9 +67712,9 @@ var ts;
67547
67712
  };
67548
67713
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
67549
67714
  var combination = discriminantCombinations_1[_a];
67550
- var state_8 = _loop_22(combination);
67551
- if (typeof state_8 === "object")
67552
- return state_8.value;
67715
+ var state_7 = _loop_21(combination);
67716
+ if (typeof state_7 === "object")
67717
+ return state_7.value;
67553
67718
  }
67554
67719
  // Compare the remaining non-discriminant properties of each match.
67555
67720
  var result = -1 /* Ternary.True */;
@@ -67646,7 +67811,7 @@ var ts;
67646
67811
  return 0 /* Ternary.False */;
67647
67812
  }
67648
67813
  // When checking for comparability, be more lenient with optional properties.
67649
- if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67814
+ if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67650
67815
  // TypeScript 1.0 spec (April 2014): 3.8.3
67651
67816
  // S is a subtype of a type T, and T is a supertype of S if ...
67652
67817
  // S' and T are object types and, for each member M in T..
@@ -68254,7 +68419,7 @@ var ts;
68254
68419
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
68255
68420
  links.variances = ts.emptyArray;
68256
68421
  var variances = [];
68257
- var _loop_24 = function (tp) {
68422
+ var _loop_23 = function (tp) {
68258
68423
  var modifiers = getVarianceModifiers(tp);
68259
68424
  var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
68260
68425
  modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
@@ -68292,7 +68457,7 @@ var ts;
68292
68457
  };
68293
68458
  for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
68294
68459
  var tp = typeParameters_2[_i];
68295
- _loop_24(tp);
68460
+ _loop_23(tp);
68296
68461
  }
68297
68462
  links.variances = variances;
68298
68463
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
@@ -68746,8 +68911,7 @@ var ts;
68746
68911
  return !!(type.flags & 109440 /* TypeFlags.Unit */);
68747
68912
  }
68748
68913
  function isUnitLikeType(type) {
68749
- return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) :
68750
- !!(type.flags & 109440 /* TypeFlags.Unit */);
68914
+ return isUnitType(getBaseConstraintOrType(type));
68751
68915
  }
68752
68916
  function extractUnitType(type) {
68753
68917
  return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type;
@@ -69626,7 +69790,7 @@ var ts;
69626
69790
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
69627
69791
  }
69628
69792
  function isMemberOfStringMapping(source, target) {
69629
- if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) {
69793
+ if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
69630
69794
  return true;
69631
69795
  }
69632
69796
  if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
@@ -70250,7 +70414,7 @@ var ts;
70250
70414
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
70251
70415
  // succeed. That would be a pointless and confusing outcome.
70252
70416
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
70253
- var _loop_25 = function (i) {
70417
+ var _loop_24 = function (i) {
70254
70418
  var source_1 = matches ? matches[i] : neverType;
70255
70419
  var target_3 = types[i];
70256
70420
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -70300,7 +70464,7 @@ var ts;
70300
70464
  inferFromTypes(source_1, target_3);
70301
70465
  };
70302
70466
  for (var i = 0; i < types.length; i++) {
70303
- _loop_25(i);
70467
+ _loop_24(i);
70304
70468
  }
70305
70469
  }
70306
70470
  }
@@ -70752,7 +70916,7 @@ var ts;
70752
70916
  }
70753
70917
  if (ts.isEntityNameExpression(node.argumentExpression)) {
70754
70918
  var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
70755
- if (!symbol || !isConstVariable(symbol))
70919
+ if (!symbol || !(isConstVariable(symbol) || (symbol.flags & 8 /* SymbolFlags.EnumMember */)))
70756
70920
  return undefined;
70757
70921
  var declaration = symbol.valueDeclaration;
70758
70922
  if (declaration === undefined)
@@ -70766,7 +70930,12 @@ var ts;
70766
70930
  }
70767
70931
  if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70768
70932
  var initializer = ts.getEffectiveInitializer(declaration);
70769
- return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70933
+ if (initializer) {
70934
+ return tryGetNameFromType(getTypeOfExpression(initializer));
70935
+ }
70936
+ if (ts.isEnumMember(declaration)) {
70937
+ return ts.getTextOfPropertyName(declaration.name);
70938
+ }
70770
70939
  }
70771
70940
  }
70772
70941
  return undefined;
@@ -70824,7 +70993,7 @@ var ts;
70824
70993
  function mapTypesByKeyProperty(types, name) {
70825
70994
  var map = new ts.Map();
70826
70995
  var count = 0;
70827
- var _loop_26 = function (type) {
70996
+ var _loop_25 = function (type) {
70828
70997
  if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
70829
70998
  var discriminant = getTypeOfPropertyOfType(type, name);
70830
70999
  if (discriminant) {
@@ -70850,9 +71019,9 @@ var ts;
70850
71019
  };
70851
71020
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70852
71021
  var type = types_15[_i];
70853
- var state_10 = _loop_26(type);
70854
- if (typeof state_10 === "object")
70855
- return state_10.value;
71022
+ var state_9 = _loop_25(type);
71023
+ if (typeof state_9 === "object")
71024
+ return state_9.value;
70856
71025
  }
70857
71026
  return count >= 10 && count * 2 >= types.length ? map : undefined;
70858
71027
  }
@@ -71449,6 +71618,7 @@ var ts;
71449
71618
  ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
71450
71619
  }
71451
71620
  function getExplicitTypeOfSymbol(symbol, diagnostic) {
71621
+ symbol = resolveSymbol(symbol);
71452
71622
  if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) {
71453
71623
  return getTypeOfSymbol(symbol);
71454
71624
  }
@@ -71487,7 +71657,7 @@ var ts;
71487
71657
  switch (node.kind) {
71488
71658
  case 79 /* SyntaxKind.Identifier */:
71489
71659
  var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
71490
- return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic);
71660
+ return getExplicitTypeOfSymbol(symbol, diagnostic);
71491
71661
  case 108 /* SyntaxKind.ThisKeyword */:
71492
71662
  return getExplicitThisType(node);
71493
71663
  case 106 /* SyntaxKind.SuperKeyword */:
@@ -71974,7 +72144,7 @@ var ts;
71974
72144
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71975
72145
  }
71976
72146
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
71977
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72147
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71978
72148
  }
71979
72149
  else {
71980
72150
  if (strictNullChecks) {
@@ -72255,7 +72425,7 @@ var ts;
72255
72425
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72256
72426
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72257
72427
  }
72258
- function narrowByInKeyword(type, nameType, assumeTrue) {
72428
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72259
72429
  var name = getPropertyNameFromType(nameType);
72260
72430
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72261
72431
  if (isKnownProperty) {
@@ -72336,7 +72506,7 @@ var ts;
72336
72506
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72337
72507
  }
72338
72508
  if (isMatchingReference(reference, target)) {
72339
- return narrowByInKeyword(type, leftType, assumeTrue);
72509
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72340
72510
  }
72341
72511
  }
72342
72512
  break;
@@ -72525,7 +72695,7 @@ var ts;
72525
72695
  neverType;
72526
72696
  });
72527
72697
  }
72528
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72698
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72529
72699
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72530
72700
  if (!witnesses) {
72531
72701
  return type;
@@ -72913,15 +73083,15 @@ var ts;
72913
73083
  });
72914
73084
  }
72915
73085
  function markAliasReferenced(symbol, location) {
72916
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
73086
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
72917
73087
  var target = resolveAlias(symbol);
72918
- if (target.flags & 111551 /* SymbolFlags.Value */) {
73088
+ if (getAllSymbolFlags(target) & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */)) {
72919
73089
  // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
72920
73090
  // (because the const enum value will not be inlined), or if (2) the alias is an export
72921
73091
  // of a const enum declaration that will be preserved.
72922
73092
  if (compilerOptions.isolatedModules ||
72923
73093
  ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) ||
72924
- !isConstEnumOrConstEnumOnlyModule(target)) {
73094
+ !isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
72925
73095
  markAliasSymbolAsReferenced(symbol);
72926
73096
  }
72927
73097
  else {
@@ -73149,7 +73319,7 @@ var ts;
73149
73319
  // We only look for uninitialized variables in strict null checking mode, and only when we can analyze
73150
73320
  // the entire control flow graph from the variable's declaration (i.e. when the flow container and
73151
73321
  // declaration container are the same).
73152
- var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
73322
+ var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
73153
73323
  type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 ||
73154
73324
  isInTypeQuery(node) || node.parent.kind === 278 /* SyntaxKind.ExportSpecifier */) ||
73155
73325
  node.parent.kind === 232 /* SyntaxKind.NonNullExpression */ ||
@@ -73178,6 +73348,12 @@ var ts;
73178
73348
  }
73179
73349
  return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
73180
73350
  }
73351
+ function isSameScopedBindingElement(node, declaration) {
73352
+ if (ts.isBindingElement(declaration)) {
73353
+ var bindingElement = ts.findAncestor(node, ts.isBindingElement);
73354
+ return bindingElement && ts.getRootDeclaration(bindingElement) === ts.getRootDeclaration(declaration);
73355
+ }
73356
+ }
73181
73357
  function shouldMarkIdentifierAliasReferenced(node) {
73182
73358
  var _a;
73183
73359
  var parent = node.parent;
@@ -73519,12 +73695,17 @@ var ts;
73519
73695
  var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
73520
73696
  var container = immediateContainer;
73521
73697
  var needToCaptureLexicalThis = false;
73698
+ var inAsyncFunction = false;
73522
73699
  // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
73523
73700
  if (!isCallExpression) {
73524
73701
  while (container && container.kind === 216 /* SyntaxKind.ArrowFunction */) {
73702
+ if (ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73703
+ inAsyncFunction = true;
73525
73704
  container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
73526
73705
  needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
73527
73706
  }
73707
+ if (container && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73708
+ inAsyncFunction = true;
73528
73709
  }
73529
73710
  var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
73530
73711
  var nodeCheckFlag = 0;
@@ -73630,12 +73811,12 @@ var ts;
73630
73811
  // as a call expression cannot be used as the target of a destructuring assignment while a property access can.
73631
73812
  //
73632
73813
  // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
73633
- if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */)) {
73814
+ if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && inAsyncFunction) {
73634
73815
  if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
73635
- getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */;
73816
+ getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */;
73636
73817
  }
73637
73818
  else {
73638
- getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */;
73819
+ getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */;
73639
73820
  }
73640
73821
  }
73641
73822
  if (needToCaptureLexicalThis) {
@@ -74331,9 +74512,10 @@ var ts;
74331
74512
  function instantiateContextualType(contextualType, node, contextFlags) {
74332
74513
  if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
74333
74514
  var inferenceContext = getInferenceContext(node);
74334
- // If no inferences have been made, nothing is gained from instantiating as type parameters
74335
- // would just be replaced with their defaults similar to the apparent type.
74336
- if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
74515
+ // If no inferences have been made, and none of the type parameters for which we are inferring
74516
+ // specify default types, nothing is gained from instantiating as type parameters would just be
74517
+ // replaced with their constraints similar to the apparent type.
74518
+ if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
74337
74519
  // For contextual signatures we incorporate all inferences made so far, e.g. from return
74338
74520
  // types as well as arguments to the left in a function call.
74339
74521
  return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
@@ -77307,7 +77489,7 @@ var ts;
77307
77489
  if (spreadIndex >= 0) {
77308
77490
  // Create synthetic arguments from spreads of tuple types.
77309
77491
  var effectiveArgs_1 = args.slice(0, spreadIndex);
77310
- var _loop_27 = function (i) {
77492
+ var _loop_26 = function (i) {
77311
77493
  var arg = args[i];
77312
77494
  // We can call checkExpressionCached because spread expressions never have a contextual type.
77313
77495
  var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -77324,7 +77506,7 @@ var ts;
77324
77506
  }
77325
77507
  };
77326
77508
  for (var i = spreadIndex; i < args.length; i++) {
77327
- _loop_27(i);
77509
+ _loop_26(i);
77328
77510
  }
77329
77511
  return effectiveArgs_1;
77330
77512
  }
@@ -77653,7 +77835,7 @@ var ts;
77653
77835
  var min_3 = Number.MAX_VALUE;
77654
77836
  var minIndex = 0;
77655
77837
  var i_1 = 0;
77656
- var _loop_28 = function (c) {
77838
+ var _loop_27 = function (c) {
77657
77839
  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)); };
77658
77840
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
77659
77841
  if (diags_2) {
@@ -77671,7 +77853,7 @@ var ts;
77671
77853
  };
77672
77854
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
77673
77855
  var c = candidatesForArgumentError_1[_a];
77674
- _loop_28(c);
77856
+ _loop_27(c);
77675
77857
  }
77676
77858
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
77677
77859
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -77829,7 +78011,7 @@ var ts;
77829
78011
  }
77830
78012
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
77831
78013
  var parameters = [];
77832
- var _loop_29 = function (i) {
78014
+ var _loop_28 = function (i) {
77833
78015
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
77834
78016
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
77835
78017
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -77837,7 +78019,7 @@ var ts;
77837
78019
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
77838
78020
  };
77839
78021
  for (var i = 0; i < maxNonRestParam; i++) {
77840
- _loop_29(i);
78022
+ _loop_28(i);
77841
78023
  }
77842
78024
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
77843
78025
  var flags = 0 /* SignatureFlags.None */;
@@ -78807,7 +78989,7 @@ var ts;
78807
78989
  if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
78808
78990
  symbol = resolveAlias(symbol);
78809
78991
  }
78810
- return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78992
+ return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78811
78993
  }
78812
78994
  return false;
78813
78995
  }
@@ -79469,7 +79651,17 @@ var ts;
79469
79651
  }
79470
79652
  function isExhaustiveSwitchStatement(node) {
79471
79653
  var links = getNodeLinks(node);
79472
- return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
79654
+ if (links.isExhaustive === undefined) {
79655
+ links.isExhaustive = 0; // Indicate resolution is in process
79656
+ var exhaustive = computeExhaustiveSwitchStatement(node);
79657
+ if (links.isExhaustive === 0) {
79658
+ links.isExhaustive = exhaustive;
79659
+ }
79660
+ }
79661
+ else if (links.isExhaustive === 0) {
79662
+ links.isExhaustive = false; // Resolve circularity to false
79663
+ }
79664
+ return links.isExhaustive;
79473
79665
  }
79474
79666
  function computeExhaustiveSwitchStatement(node) {
79475
79667
  if (node.expression.kind === 218 /* SyntaxKind.TypeOfExpression */) {
@@ -79477,7 +79669,7 @@ var ts;
79477
79669
  if (!witnesses) {
79478
79670
  return false;
79479
79671
  }
79480
- var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression));
79672
+ var operandConstraint = getBaseConstraintOrType(checkExpressionCached(node.expression.expression));
79481
79673
  // Get the not-equal flags for all handled cases.
79482
79674
  var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
79483
79675
  if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) {
@@ -79487,7 +79679,7 @@ var ts;
79487
79679
  // A missing not-equal flag indicates that the type wasn't handled by some case.
79488
79680
  return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
79489
79681
  }
79490
- var type = getTypeOfExpression(node.expression);
79682
+ var type = checkExpressionCached(node.expression);
79491
79683
  if (!isLiteralType(type)) {
79492
79684
  return false;
79493
79685
  }
@@ -81181,6 +81373,9 @@ var ts;
81181
81373
  function hasInferenceCandidates(info) {
81182
81374
  return !!(info.candidates || info.contraCandidates);
81183
81375
  }
81376
+ function hasInferenceCandidatesOrDefault(info) {
81377
+ return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
81378
+ }
81184
81379
  function hasOverlappingInferences(a, b) {
81185
81380
  for (var i = 0; i < a.length; i++) {
81186
81381
  if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
@@ -81882,7 +82077,7 @@ var ts;
81882
82077
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
81883
82078
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
81884
82079
  var indexSignatureMap_1 = new ts.Map();
81885
- var _loop_30 = function (declaration) {
82080
+ var _loop_29 = function (declaration) {
81886
82081
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
81887
82082
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
81888
82083
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -81897,7 +82092,7 @@ var ts;
81897
82092
  };
81898
82093
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
81899
82094
  var declaration = _a[_i];
81900
- _loop_30(declaration);
82095
+ _loop_29(declaration);
81901
82096
  }
81902
82097
  indexSignatureMap_1.forEach(function (entry) {
81903
82098
  if (entry.declarations.length > 1) {
@@ -82174,7 +82369,7 @@ var ts;
82174
82369
  }
82175
82370
  var symbol = getNodeLinks(node).resolvedSymbol;
82176
82371
  if (symbol) {
82177
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
82372
+ if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
82178
82373
  addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
82179
82374
  }
82180
82375
  if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
@@ -82777,7 +82972,7 @@ var ts;
82777
82972
  return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
82778
82973
  }
82779
82974
  // primitives with a `{ then() }` won't be unwrapped/adopted.
82780
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82975
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82781
82976
  return undefined;
82782
82977
  }
82783
82978
  var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
@@ -82844,7 +83039,7 @@ var ts;
82844
83039
  * Determines whether a type is an object with a callable `then` member.
82845
83040
  */
82846
83041
  function isThenableType(type) {
82847
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
83042
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82848
83043
  // primitive types cannot be considered "thenable" since they are not objects.
82849
83044
  return false;
82850
83045
  }
@@ -82878,7 +83073,7 @@ var ts;
82878
83073
  // 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`,
82879
83074
  // or is promise-like.
82880
83075
  if (baseConstraint ?
82881
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83076
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
82882
83077
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
82883
83078
  return true;
82884
83079
  }
@@ -83552,7 +83747,7 @@ var ts;
83552
83747
  }
83553
83748
  function errorUnusedLocal(declaration, name, addDiagnostic) {
83554
83749
  var node = ts.getNameOfDeclaration(declaration) || declaration;
83555
- var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
83750
+ var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
83556
83751
  addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
83557
83752
  }
83558
83753
  function isIdentifierThatStartsWithUnderscore(node) {
@@ -84982,7 +85177,16 @@ var ts;
84982
85177
  var message = allowAsyncIterables
84983
85178
  ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
84984
85179
  : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
84985
- return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
85180
+ var suggestAwait =
85181
+ // for (const x of Promise<...>) or [...Promise<...>]
85182
+ !!getAwaitedTypeOfPromise(type)
85183
+ // for (const x of AsyncIterable<...>)
85184
+ || (!allowAsyncIterables &&
85185
+ ts.isForOfStatement(errorNode.parent) &&
85186
+ errorNode.parent.expression === errorNode &&
85187
+ getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
85188
+ isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
85189
+ return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
84986
85190
  }
84987
85191
  /**
84988
85192
  * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
@@ -85497,7 +85701,7 @@ var ts;
85497
85701
  var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
85498
85702
  name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
85499
85703
  var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
85500
- var _loop_31 = function (info) {
85704
+ var _loop_30 = function (info) {
85501
85705
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
85502
85706
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
85503
85707
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -85514,7 +85718,7 @@ var ts;
85514
85718
  };
85515
85719
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
85516
85720
  var info = indexInfos_9[_i];
85517
- _loop_31(info);
85721
+ _loop_30(info);
85518
85722
  }
85519
85723
  }
85520
85724
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -85522,7 +85726,7 @@ var ts;
85522
85726
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
85523
85727
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
85524
85728
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
85525
- var _loop_32 = function (info) {
85729
+ var _loop_31 = function (info) {
85526
85730
  if (info === checkInfo)
85527
85731
  return "continue";
85528
85732
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -85537,7 +85741,7 @@ var ts;
85537
85741
  };
85538
85742
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
85539
85743
  var info = indexInfos_10[_i];
85540
- _loop_32(info);
85744
+ _loop_31(info);
85541
85745
  }
85542
85746
  }
85543
85747
  function checkTypeNameIsReserved(name, message) {
@@ -85592,7 +85796,7 @@ var ts;
85592
85796
  }
85593
85797
  else {
85594
85798
  ts.forEach(jsdocParameters, function (_a, index) {
85595
- var name = _a.name;
85799
+ var name = _a.name, isNameFirst = _a.isNameFirst;
85596
85800
  if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
85597
85801
  return;
85598
85802
  }
@@ -85602,7 +85806,9 @@ var ts;
85602
85806
  }
85603
85807
  }
85604
85808
  else {
85605
- errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
85809
+ if (!isNameFirst) {
85810
+ errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
85811
+ }
85606
85812
  }
85607
85813
  });
85608
85814
  }
@@ -85857,7 +86063,7 @@ var ts;
85857
86063
  var baseTypes = baseTypeNode && getBaseTypes(type);
85858
86064
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
85859
86065
  var baseStaticType = getBaseConstructorTypeOfClass(type);
85860
- var _loop_33 = function (member) {
86066
+ var _loop_32 = function (member) {
85861
86067
  if (ts.hasAmbientModifier(member)) {
85862
86068
  return "continue";
85863
86069
  }
@@ -85874,7 +86080,7 @@ var ts;
85874
86080
  };
85875
86081
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85876
86082
  var member = _a[_i];
85877
- _loop_33(member);
86083
+ _loop_32(member);
85878
86084
  }
85879
86085
  }
85880
86086
  /**
@@ -85962,7 +86168,7 @@ var ts;
85962
86168
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
85963
86169
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
85964
86170
  var issuedMemberError = false;
85965
- var _loop_34 = function (member) {
86171
+ var _loop_33 = function (member) {
85966
86172
  if (ts.isStatic(member)) {
85967
86173
  return "continue";
85968
86174
  }
@@ -85981,7 +86187,7 @@ var ts;
85981
86187
  };
85982
86188
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85983
86189
  var member = _a[_i];
85984
- _loop_34(member);
86190
+ _loop_33(member);
85985
86191
  }
85986
86192
  if (!issuedMemberError) {
85987
86193
  // check again with diagnostics to generate a less-specific error
@@ -86052,7 +86258,7 @@ var ts;
86052
86258
  var _a, _b, _c, _d;
86053
86259
  // NOTE: assignability is checked in checkClassDeclaration
86054
86260
  var baseProperties = getPropertiesOfType(baseType);
86055
- var _loop_35 = function (baseProperty) {
86261
+ var _loop_34 = function (baseProperty) {
86056
86262
  var base = getTargetSymbol(baseProperty);
86057
86263
  if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
86058
86264
  return "continue";
@@ -86162,8 +86368,8 @@ var ts;
86162
86368
  };
86163
86369
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
86164
86370
  var baseProperty = baseProperties_1[_i];
86165
- var state_11 = _loop_35(baseProperty);
86166
- switch (state_11) {
86371
+ var state_10 = _loop_34(baseProperty);
86372
+ switch (state_10) {
86167
86373
  case "continue-basePropertyCheck": continue basePropertyCheck;
86168
86374
  }
86169
86375
  }
@@ -86682,12 +86888,11 @@ var ts;
86682
86888
  }
86683
86889
  }
86684
86890
  function checkModuleAugmentationElement(node, isGlobalAugmentation) {
86685
- var _a;
86686
86891
  switch (node.kind) {
86687
86892
  case 240 /* SyntaxKind.VariableStatement */:
86688
86893
  // error each individual name in variable statement instead of marking the entire variable statement
86689
- for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) {
86690
- var decl = _b[_i];
86894
+ for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
86895
+ var decl = _a[_i];
86691
86896
  checkModuleAugmentationElement(decl, isGlobalAugmentation);
86692
86897
  }
86693
86898
  break;
@@ -86703,8 +86908,8 @@ var ts;
86703
86908
  case 257 /* SyntaxKind.VariableDeclaration */:
86704
86909
  var name = node.name;
86705
86910
  if (ts.isBindingPattern(name)) {
86706
- for (var _c = 0, _d = name.elements; _c < _d.length; _c++) {
86707
- var el = _d[_c];
86911
+ for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
86912
+ var el = _c[_b];
86708
86913
  // mark individual names in binding pattern
86709
86914
  checkModuleAugmentationElement(el, isGlobalAugmentation);
86710
86915
  }
@@ -86720,18 +86925,6 @@ var ts;
86720
86925
  if (isGlobalAugmentation) {
86721
86926
  return;
86722
86927
  }
86723
- var symbol = getSymbolOfNode(node);
86724
- if (symbol) {
86725
- // module augmentations cannot introduce new names on the top level scope of the module
86726
- // this is done it two steps
86727
- // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error
86728
- // 2. main check - report error if value declaration of the parent symbol is module augmentation)
86729
- var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */);
86730
- if (!reportError) {
86731
- // symbol should not originate in augmentation
86732
- reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
86733
- }
86734
- }
86735
86928
  break;
86736
86929
  }
86737
86930
  }
@@ -86833,10 +87026,11 @@ var ts;
86833
87026
  }
86834
87027
  return;
86835
87028
  }
87029
+ var targetFlags = getAllSymbolFlags(target);
86836
87030
  var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
86837
87031
  (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
86838
87032
  (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
86839
- if (target.flags & excludedMeanings) {
87033
+ if (targetFlags & excludedMeanings) {
86840
87034
  var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
86841
87035
  ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
86842
87036
  ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
@@ -86846,7 +87040,7 @@ var ts;
86846
87040
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
86847
87041
  && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
86848
87042
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
86849
- var isType = !(target.flags & 111551 /* SymbolFlags.Value */);
87043
+ var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
86850
87044
  if (isType || typeOnlyAlias) {
86851
87045
  switch (node.kind) {
86852
87046
  case 270 /* SyntaxKind.ImportClause */:
@@ -87006,14 +87200,15 @@ var ts;
87006
87200
  if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
87007
87201
  var target = resolveAlias(getSymbolOfNode(node));
87008
87202
  if (target !== unknownSymbol) {
87009
- if (target.flags & 111551 /* SymbolFlags.Value */) {
87203
+ var targetFlags = getAllSymbolFlags(target);
87204
+ if (targetFlags & 111551 /* SymbolFlags.Value */) {
87010
87205
  // Target is a value symbol, check that it is not hidden by a local declaration with the same name
87011
87206
  var moduleName = ts.getFirstIdentifier(node.moduleReference);
87012
87207
  if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
87013
87208
  error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
87014
87209
  }
87015
87210
  }
87016
- if (target.flags & 788968 /* SymbolFlags.Type */) {
87211
+ if (targetFlags & 788968 /* SymbolFlags.Type */) {
87017
87212
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
87018
87213
  }
87019
87214
  }
@@ -87152,7 +87347,7 @@ var ts;
87152
87347
  markExportAsReferenced(node);
87153
87348
  }
87154
87349
  var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
87155
- if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87350
+ if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87156
87351
  checkExpressionCached(node.propertyName || node.name);
87157
87352
  }
87158
87353
  }
@@ -87199,7 +87394,7 @@ var ts;
87199
87394
  markAliasReferenced(sym, id);
87200
87395
  // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
87201
87396
  var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
87202
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87397
+ if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87203
87398
  // However if it is a value, we need to check it's being used correctly
87204
87399
  checkExpressionCached(node.expression);
87205
87400
  }
@@ -87871,29 +88066,9 @@ var ts;
87871
88066
  }
87872
88067
  function isTypeDeclarationName(name) {
87873
88068
  return name.kind === 79 /* SyntaxKind.Identifier */ &&
87874
- isTypeDeclaration(name.parent) &&
88069
+ ts.isTypeDeclaration(name.parent) &&
87875
88070
  ts.getNameOfDeclaration(name.parent) === name;
87876
88071
  }
87877
- function isTypeDeclaration(node) {
87878
- switch (node.kind) {
87879
- case 165 /* SyntaxKind.TypeParameter */:
87880
- case 260 /* SyntaxKind.ClassDeclaration */:
87881
- case 261 /* SyntaxKind.InterfaceDeclaration */:
87882
- case 262 /* SyntaxKind.TypeAliasDeclaration */:
87883
- case 263 /* SyntaxKind.EnumDeclaration */:
87884
- case 348 /* SyntaxKind.JSDocTypedefTag */:
87885
- case 341 /* SyntaxKind.JSDocCallbackTag */:
87886
- case 342 /* SyntaxKind.JSDocEnumTag */:
87887
- return true;
87888
- case 270 /* SyntaxKind.ImportClause */:
87889
- return node.isTypeOnly;
87890
- case 273 /* SyntaxKind.ImportSpecifier */:
87891
- case 278 /* SyntaxKind.ExportSpecifier */:
87892
- return node.parent.parent.isTypeOnly;
87893
- default:
87894
- return false;
87895
- }
87896
- }
87897
88072
  // True if the given identifier is part of a type reference
87898
88073
  function isTypeReferenceIdentifier(node) {
87899
88074
  while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
@@ -88326,7 +88501,7 @@ var ts;
88326
88501
  var baseType = ts.firstOrUndefined(getBaseTypes(classType));
88327
88502
  return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
88328
88503
  }
88329
- if (isTypeDeclaration(node)) {
88504
+ if (ts.isTypeDeclaration(node)) {
88330
88505
  // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
88331
88506
  var symbol = getSymbolOfNode(node);
88332
88507
  return getDeclaredTypeOfSymbol(symbol);
@@ -88521,7 +88696,7 @@ var ts;
88521
88696
  return symbolLinks.exportsSomeValue;
88522
88697
  function isValue(s) {
88523
88698
  s = resolveSymbol(s);
88524
- return s && !!(s.flags & 111551 /* SymbolFlags.Value */);
88699
+ return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
88525
88700
  }
88526
88701
  }
88527
88702
  function isNameOfModuleOrEnumDeclaration(node) {
@@ -88574,7 +88749,7 @@ var ts;
88574
88749
  var symbol = getReferencedValueOrAliasSymbol(node);
88575
88750
  // We should only get the declaration of an alias if there isn't a local value
88576
88751
  // declaration for the symbol
88577
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
88752
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
88578
88753
  return getDeclarationOfAliasSymbol(symbol);
88579
88754
  }
88580
88755
  }
@@ -88662,7 +88837,7 @@ var ts;
88662
88837
  case 273 /* SyntaxKind.ImportSpecifier */:
88663
88838
  case 278 /* SyntaxKind.ExportSpecifier */:
88664
88839
  var symbol = getSymbolOfNode(node);
88665
- return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
88840
+ return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
88666
88841
  case 275 /* SyntaxKind.ExportDeclaration */:
88667
88842
  var exportClause = node.exportClause;
88668
88843
  return !!exportClause && (ts.isNamespaceExport(exportClause) ||
@@ -88684,6 +88859,7 @@ var ts;
88684
88859
  return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
88685
88860
  }
88686
88861
  function isAliasResolvedToValue(symbol) {
88862
+ var _a;
88687
88863
  if (!symbol) {
88688
88864
  return false;
88689
88865
  }
@@ -88693,7 +88869,7 @@ var ts;
88693
88869
  }
88694
88870
  // const enums and modules that contain only const enums are not considered values from the emit perspective
88695
88871
  // unless 'preserveConstEnums' option is set to true
88696
- return !!(target.flags & 111551 /* SymbolFlags.Value */) &&
88872
+ return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
88697
88873
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
88698
88874
  }
88699
88875
  function isConstEnumOrConstEnumOnlyModule(s) {
@@ -88708,7 +88884,7 @@ var ts;
88708
88884
  }
88709
88885
  var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
88710
88886
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
88711
- target.flags & 111551 /* SymbolFlags.Value */ &&
88887
+ getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
88712
88888
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
88713
88889
  // An `export import ... =` of a value symbol is always considered referenced
88714
88890
  return true;
@@ -98362,8 +98538,11 @@ var ts;
98362
98538
  }
98363
98539
  return ts.visitEachChild(node, visitor, context);
98364
98540
  case 174 /* SyntaxKind.GetAccessor */:
98541
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitGetAccessorDeclaration, node);
98365
98542
  case 175 /* SyntaxKind.SetAccessor */:
98543
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitSetAccessorDeclaration, node);
98366
98544
  case 173 /* SyntaxKind.Constructor */:
98545
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitConstructorDeclaration, node);
98367
98546
  case 260 /* SyntaxKind.ClassDeclaration */:
98368
98547
  case 228 /* SyntaxKind.ClassExpression */:
98369
98548
  return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
@@ -98464,6 +98643,9 @@ var ts;
98464
98643
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
98465
98644
  /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
98466
98645
  }
98646
+ function visitConstructorDeclaration(node) {
98647
+ return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98648
+ }
98467
98649
  /**
98468
98650
  * Visits a MethodDeclaration node.
98469
98651
  *
@@ -98478,7 +98660,14 @@ var ts;
98478
98660
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
98479
98661
  /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
98480
98662
  ? transformAsyncFunctionBody(node)
98481
- : ts.visitFunctionBody(node.body, visitor, context));
98663
+ : transformMethodBody(node));
98664
+ }
98665
+ function visitGetAccessorDeclaration(node) {
98666
+ return factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context),
98667
+ /*type*/ undefined, transformMethodBody(node));
98668
+ }
98669
+ function visitSetAccessorDeclaration(node) {
98670
+ return factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98482
98671
  }
98483
98672
  /**
98484
98673
  * Visits a FunctionDeclaration node.
@@ -98592,6 +98781,42 @@ var ts;
98592
98781
  }
98593
98782
  return false;
98594
98783
  }
98784
+ function transformMethodBody(node) {
98785
+ ts.Debug.assertIsDefined(node.body);
98786
+ var savedCapturedSuperProperties = capturedSuperProperties;
98787
+ var savedHasSuperElementAccess = hasSuperElementAccess;
98788
+ capturedSuperProperties = new ts.Set();
98789
+ hasSuperElementAccess = false;
98790
+ var updated = ts.visitFunctionBody(node.body, visitor, context);
98791
+ // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98792
+ // This step isn't needed if we eventually transform this to ES5.
98793
+ var originalMethod = ts.getOriginalNode(node, ts.isFunctionLikeDeclaration);
98794
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ &&
98795
+ resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) &&
98796
+ (ts.getFunctionFlags(originalMethod) & 3 /* FunctionFlags.AsyncGenerator */) !== 3 /* FunctionFlags.AsyncGenerator */;
98797
+ if (emitSuperHelpers) {
98798
+ enableSubstitutionForAsyncMethodsWithSuper();
98799
+ if (capturedSuperProperties.size) {
98800
+ var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
98801
+ substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
98802
+ var statements = updated.statements.slice();
98803
+ ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
98804
+ updated = factory.updateBlock(updated, statements);
98805
+ }
98806
+ if (hasSuperElementAccess) {
98807
+ // Emit helpers for super element access expressions (`super[x]`).
98808
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98809
+ ts.addEmitHelper(updated, ts.advancedAsyncSuperHelper);
98810
+ }
98811
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98812
+ ts.addEmitHelper(updated, ts.asyncSuperHelper);
98813
+ }
98814
+ }
98815
+ }
98816
+ capturedSuperProperties = savedCapturedSuperProperties;
98817
+ hasSuperElementAccess = savedHasSuperElementAccess;
98818
+ return updated;
98819
+ }
98595
98820
  function transformAsyncFunctionBody(node) {
98596
98821
  resumeLexicalEnvironment();
98597
98822
  var original = ts.getOriginalNode(node, ts.isFunctionLike);
@@ -98624,7 +98849,7 @@ var ts;
98624
98849
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
98625
98850
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98626
98851
  // This step isn't needed if we eventually transform this to ES5.
98627
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
98852
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
98628
98853
  if (emitSuperHelpers) {
98629
98854
  enableSubstitutionForAsyncMethodsWithSuper();
98630
98855
  if (capturedSuperProperties.size) {
@@ -98637,10 +98862,10 @@ var ts;
98637
98862
  ts.setTextRange(block, node.body);
98638
98863
  if (emitSuperHelpers && hasSuperElementAccess) {
98639
98864
  // Emit helpers for super element access expressions (`super[x]`).
98640
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
98865
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98641
98866
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
98642
98867
  }
98643
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
98868
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98644
98869
  ts.addEmitHelper(block, ts.asyncSuperHelper);
98645
98870
  }
98646
98871
  }
@@ -98712,7 +98937,7 @@ var ts;
98712
98937
  // If we need to support substitutions for `super` in an async method,
98713
98938
  // we should track it here.
98714
98939
  if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
98715
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
98940
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
98716
98941
  if (superContainerFlags !== enclosingSuperContainerFlags) {
98717
98942
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
98718
98943
  enclosingSuperContainerFlags = superContainerFlags;
@@ -98789,7 +99014,7 @@ var ts;
98789
99014
  || kind === 175 /* SyntaxKind.SetAccessor */;
98790
99015
  }
98791
99016
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
98792
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99017
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98793
99018
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
98794
99019
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
98795
99020
  }
@@ -98804,7 +99029,7 @@ var ts;
98804
99029
  function createSuperAccessVariableStatement(factory, resolver, node, names) {
98805
99030
  // Create a variable declaration with a getter/setter (if binding) definition for each name:
98806
99031
  // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
98807
- var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0;
99032
+ var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) !== 0;
98808
99033
  var accessors = [];
98809
99034
  names.forEach(function (_, key) {
98810
99035
  var name = ts.unescapeLeadingUnderscores(key);
@@ -99297,11 +99522,22 @@ var ts;
99297
99522
  }
99298
99523
  return node;
99299
99524
  }
99300
- function convertForOfStatementHead(node, boundValue) {
99301
- var binding = ts.createForOfBindingStatement(factory, node.initializer, boundValue);
99525
+ function convertForOfStatementHead(node, boundValue, nonUserCode) {
99526
+ var value = factory.createTempVariable(hoistVariableDeclaration);
99527
+ var iteratorValueExpression = factory.createAssignment(value, boundValue);
99528
+ var iteratorValueStatement = factory.createExpressionStatement(iteratorValueExpression);
99529
+ ts.setSourceMapRange(iteratorValueStatement, node.expression);
99530
+ var exitNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createFalse());
99531
+ var exitNonUserCodeStatement = factory.createExpressionStatement(exitNonUserCodeExpression);
99532
+ ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
99533
+ var enterNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createTrue());
99534
+ var enterNonUserCodeStatement = factory.createExpressionStatement(enterNonUserCodeExpression);
99535
+ ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
99536
+ var statements = [];
99537
+ var binding = ts.createForOfBindingStatement(factory, node.initializer, value);
99538
+ statements.push(ts.visitNode(binding, visitor, ts.isStatement));
99302
99539
  var bodyLocation;
99303
99540
  var statementsLocation;
99304
- var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
99305
99541
  var statement = ts.visitIterationBody(node.statement, visitor, context);
99306
99542
  if (ts.isBlock(statement)) {
99307
99543
  ts.addRange(statements, statement.statements);
@@ -99311,8 +99547,16 @@ var ts;
99311
99547
  else {
99312
99548
  statements.push(statement);
99313
99549
  }
99314
- return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
99550
+ var body = ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
99315
99551
  /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */);
99552
+ return factory.createBlock([
99553
+ iteratorValueStatement,
99554
+ exitNonUserCodeStatement,
99555
+ factory.createTryStatement(body,
99556
+ /*catchClause*/ undefined, factory.createBlock([
99557
+ enterNonUserCodeStatement
99558
+ ]))
99559
+ ]);
99316
99560
  }
99317
99561
  function createDownlevelAwait(expression) {
99318
99562
  return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
@@ -99323,6 +99567,8 @@ var ts;
99323
99567
  var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
99324
99568
  var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined);
99325
99569
  var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(/*recordTempVariable*/ undefined);
99570
+ var nonUserCode = factory.createTempVariable(/*recordTempVariable*/ undefined);
99571
+ var done = factory.createTempVariable(hoistVariableDeclaration);
99326
99572
  var errorRecord = factory.createUniqueName("e");
99327
99573
  var catchVariable = factory.getGeneratedNameForNode(errorRecord);
99328
99574
  var returnMethod = factory.createTempVariable(/*recordTempVariable*/ undefined);
@@ -99339,12 +99585,17 @@ var ts;
99339
99585
  callValues;
99340
99586
  var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(
99341
99587
  /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
99588
+ factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
99342
99589
  ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
99343
99590
  factory.createVariableDeclaration(result)
99344
99591
  ]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
99345
- /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)),
99592
+ /*condition*/ factory.inlineExpressions([
99593
+ factory.createAssignment(result, createDownlevelAwait(callNext)),
99594
+ factory.createAssignment(done, getDone),
99595
+ factory.createLogicalNot(done)
99596
+ ]),
99346
99597
  /*incrementor*/ undefined,
99347
- /*statement*/ convertForOfStatementHead(node, getValue)),
99598
+ /*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)),
99348
99599
  /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
99349
99600
  ts.setOriginalNode(forStatement, node);
99350
99601
  return factory.createTryStatement(factory.createBlock([
@@ -99356,7 +99607,7 @@ var ts;
99356
99607
  ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([
99357
99608
  factory.createTryStatement(
99358
99609
  /*tryBlock*/ factory.createBlock([
99359
- 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 */)
99610
+ 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 */)
99360
99611
  ]),
99361
99612
  /*catchClause*/ undefined,
99362
99613
  /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([
@@ -99512,7 +99763,7 @@ var ts;
99512
99763
  /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
99513
99764
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
99514
99765
  // This step isn't needed if we eventually transform this to ES5.
99515
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
99766
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
99516
99767
  if (emitSuperHelpers) {
99517
99768
  enableSubstitutionForAsyncMethodsWithSuper();
99518
99769
  var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
@@ -99523,10 +99774,10 @@ var ts;
99523
99774
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
99524
99775
  var block = factory.updateBlock(node.body, statements);
99525
99776
  if (emitSuperHelpers && hasSuperElementAccess) {
99526
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99777
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99527
99778
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
99528
99779
  }
99529
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
99780
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
99530
99781
  ts.addEmitHelper(block, ts.asyncSuperHelper);
99531
99782
  }
99532
99783
  }
@@ -99655,7 +99906,7 @@ var ts;
99655
99906
  // If we need to support substitutions for `super` in an async method,
99656
99907
  // we should track it here.
99657
99908
  if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
99658
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
99909
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
99659
99910
  if (superContainerFlags !== enclosingSuperContainerFlags) {
99660
99911
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
99661
99912
  enclosingSuperContainerFlags = superContainerFlags;
@@ -99732,7 +99983,7 @@ var ts;
99732
99983
  || kind === 175 /* SyntaxKind.SetAccessor */;
99733
99984
  }
99734
99985
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
99735
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99986
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99736
99987
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
99737
99988
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
99738
99989
  }
@@ -101201,11 +101452,13 @@ var ts;
101201
101452
  return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
101202
101453
  }
101203
101454
  function visitIdentifier(node) {
101204
- if (!convertedLoopState) {
101205
- return node;
101455
+ if (convertedLoopState) {
101456
+ if (resolver.isArgumentsLocalBinding(node)) {
101457
+ return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101458
+ }
101206
101459
  }
101207
- if (resolver.isArgumentsLocalBinding(node)) {
101208
- return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101460
+ if (node.hasExtendedUnicodeEscape) {
101461
+ return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
101209
101462
  }
101210
101463
  return node;
101211
101464
  }
@@ -105352,7 +105605,6 @@ var ts;
105352
105605
  return node;
105353
105606
  }
105354
105607
  function transformAndEmitForInStatement(node) {
105355
- // TODO(rbuckton): Source map locations
105356
105608
  if (containsYield(node)) {
105357
105609
  // [source]
105358
105610
  // for (var p in o) {
@@ -105360,34 +105612,41 @@ var ts;
105360
105612
  // }
105361
105613
  //
105362
105614
  // [intermediate]
105363
- // .local _a, _b, _i
105364
- // _a = [];
105365
- // for (_b in o) _a.push(_b);
105615
+ // .local _b, _a, _c, _i
105616
+ // _b = [];
105617
+ // _a = o;
105618
+ // for (_c in _a) _b.push(_c);
105366
105619
  // _i = 0;
105367
105620
  // .loop incrementLabel, endLoopLabel
105368
105621
  // .mark conditionLabel
105369
- // .brfalse endLoopLabel, (_i < _a.length)
105370
- // p = _a[_i];
105622
+ // .brfalse endLoopLabel, (_i < _b.length)
105623
+ // _c = _b[_i];
105624
+ // .brfalse incrementLabel, (_c in _a)
105625
+ // p = _c;
105371
105626
  // /*body*/
105372
105627
  // .mark incrementLabel
105373
- // _b++;
105628
+ // _c++;
105374
105629
  // .br conditionLabel
105375
105630
  // .endloop
105376
105631
  // .mark endLoopLabel
105377
- var keysArray = declareLocal(); // _a
105378
- var key = declareLocal(); // _b
105632
+ var obj = declareLocal(); // _a
105633
+ var keysArray = declareLocal(); // _b
105634
+ var key = declareLocal(); // _c
105379
105635
  var keysIndex = factory.createLoopVariable(); // _i
105380
105636
  var initializer = node.initializer;
105381
105637
  hoistVariableDeclaration(keysIndex);
105638
+ emitAssignment(obj, ts.visitNode(node.expression, visitor, ts.isExpression));
105382
105639
  emitAssignment(keysArray, factory.createArrayLiteralExpression());
105383
- emitStatement(factory.createForInStatement(key, ts.visitNode(node.expression, visitor, ts.isExpression), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
105640
+ emitStatement(factory.createForInStatement(key, obj, factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
105384
105641
  /*typeArguments*/ undefined, [key]))));
105385
105642
  emitAssignment(keysIndex, factory.createNumericLiteral(0));
105386
105643
  var conditionLabel = defineLabel();
105387
105644
  var incrementLabel = defineLabel();
105388
- var endLabel = beginLoopBlock(incrementLabel);
105645
+ var endLoopLabel = beginLoopBlock(incrementLabel);
105389
105646
  markLabel(conditionLabel);
105390
- emitBreakWhenFalse(endLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
105647
+ emitBreakWhenFalse(endLoopLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
105648
+ emitAssignment(key, factory.createElementAccessExpression(keysArray, keysIndex));
105649
+ emitBreakWhenFalse(incrementLabel, factory.createBinaryExpression(key, 101 /* SyntaxKind.InKeyword */, obj));
105391
105650
  var variable = void 0;
105392
105651
  if (ts.isVariableDeclarationList(initializer)) {
105393
105652
  for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
@@ -105400,7 +105659,7 @@ var ts;
105400
105659
  variable = ts.visitNode(initializer, visitor, ts.isExpression);
105401
105660
  ts.Debug.assert(ts.isLeftHandSideExpression(variable));
105402
105661
  }
105403
- emitAssignment(variable, factory.createElementAccessExpression(keysArray, keysIndex));
105662
+ emitAssignment(variable, key);
105404
105663
  transformAndEmitEmbeddedStatement(node.statement);
105405
105664
  markLabel(incrementLabel);
105406
105665
  emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
@@ -107241,7 +107500,7 @@ var ts;
107241
107500
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107242
107501
  case ts.ModuleKind.CommonJS:
107243
107502
  default:
107244
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107503
+ return createImportCallExpressionCommonJS(argument);
107245
107504
  }
107246
107505
  }
107247
107506
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107264,7 +107523,7 @@ var ts;
107264
107523
  return factory.createConditionalExpression(
107265
107524
  /*condition*/ factory.createIdentifier("__syncRequire"),
107266
107525
  /*questionToken*/ undefined,
107267
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107526
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107268
107527
  /*colonToken*/ undefined,
107269
107528
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107270
107529
  }
@@ -107273,7 +107532,7 @@ var ts;
107273
107532
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107274
107533
  /*condition*/ factory.createIdentifier("__syncRequire"),
107275
107534
  /*questionToken*/ undefined,
107276
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107535
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107277
107536
  /*colonToken*/ undefined,
107278
107537
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107279
107538
  }
@@ -107323,14 +107582,20 @@ var ts;
107323
107582
  }
107324
107583
  return promise;
107325
107584
  }
107326
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107327
- // import("./blah")
107585
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107586
+ // import(x)
107328
107587
  // emit as
107329
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107588
+ // var _a;
107589
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107330
107590
  // We have to wrap require in then callback so that require is done in asynchronously
107331
107591
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107332
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107333
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107592
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107593
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107594
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107595
+ /*typeArguments*/ undefined,
107596
+ /*argumentsArray*/ []);
107597
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107598
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107334
107599
  if (ts.getESModuleInterop(compilerOptions)) {
107335
107600
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107336
107601
  }
@@ -107351,14 +107616,9 @@ var ts;
107351
107616
  /*typeParameters*/ undefined,
107352
107617
  /*parameters*/ [],
107353
107618
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107354
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107355
- // that this new function expression indicates it captures 'this' so that the
107356
- // es2015 transformer will properly substitute 'this' with '_this'.
107357
- if (containsLexicalThis) {
107358
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107359
- }
107360
107619
  }
107361
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107620
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107621
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107362
107622
  }
107363
107623
  function getHelperExpressionForExport(node, innerExpr) {
107364
107624
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
@@ -118351,14 +118611,16 @@ var ts;
118351
118611
  }
118352
118612
  return setReadFileCache(key, fileName);
118353
118613
  };
118354
- var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
118614
+ var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
118355
118615
  var key = toPath(fileName);
118356
- var value = sourceFileCache.get(key);
118616
+ var impliedNodeFormat = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.impliedNodeFormat : undefined;
118617
+ var forImpliedNodeFormat = sourceFileCache.get(impliedNodeFormat);
118618
+ var value = forImpliedNodeFormat === null || forImpliedNodeFormat === void 0 ? void 0 : forImpliedNodeFormat.get(key);
118357
118619
  if (value)
118358
118620
  return value;
118359
- var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
118621
+ var sourceFile = getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
118360
118622
  if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) {
118361
- sourceFileCache.set(key, sourceFile);
118623
+ sourceFileCache.set(impliedNodeFormat, (forImpliedNodeFormat || new ts.Map()).set(key, sourceFile));
118362
118624
  }
118363
118625
  return sourceFile;
118364
118626
  } : undefined;
@@ -118383,13 +118645,15 @@ var ts;
118383
118645
  var value = readFileCache.get(key);
118384
118646
  if (value !== undefined && value !== data) {
118385
118647
  readFileCache.delete(key);
118386
- sourceFileCache.delete(key);
118648
+ sourceFileCache.forEach(function (map) { return map.delete(key); });
118387
118649
  }
118388
118650
  else if (getSourceFileWithCache) {
118389
- var sourceFile = sourceFileCache.get(key);
118390
- if (sourceFile && sourceFile.text !== data) {
118391
- sourceFileCache.delete(key);
118392
- }
118651
+ sourceFileCache.forEach(function (map) {
118652
+ var sourceFile = map.get(key);
118653
+ if (sourceFile && sourceFile.text !== data) {
118654
+ map.delete(key);
118655
+ }
118656
+ });
118393
118657
  }
118394
118658
  originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
118395
118659
  };
@@ -122531,10 +122795,16 @@ var ts;
122531
122795
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
122532
122796
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
122533
122797
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122798
+ // We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged,
122799
+ // which will eg be depedent on change in options like declarationDir and outDir options are unchanged.
122800
+ // We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because
122801
+ // oldCompilerOptions can be undefined if there was change in say module from None to some other option
122802
+ // 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
122803
+ // but that option change does not affect d.ts file name so emitSignatures should still be reused.
122534
122804
  var canCopyEmitSignatures = compilerOptions.composite &&
122535
122805
  (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
122536
122806
  !outFilePath &&
122537
- !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
122807
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122538
122808
  if (useOldState) {
122539
122809
  // Copy old state's changed files set
122540
122810
  (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
@@ -123080,7 +123350,8 @@ var ts;
123080
123350
  for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
123081
123351
  var path = _c[_b];
123082
123352
  if (ts.tryAddToSet(seenFiles, path)) {
123083
- (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]);
123353
+ var fileId = toFileId(path), emitKind = state.affectedFilesPendingEmitKind.get(path);
123354
+ (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push(emitKind === 1 /* BuilderFileEmit.Full */ ? fileId : [fileId]);
123084
123355
  }
123085
123356
  }
123086
123357
  }
@@ -123559,6 +123830,10 @@ var ts;
123559
123830
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
123560
123831
  }
123561
123832
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
123833
+ function toBuilderFileEmit(value) {
123834
+ return ts.isNumber(value) ? 1 /* BuilderFileEmit.Full */ : 0 /* BuilderFileEmit.DtsOnly */;
123835
+ }
123836
+ ts.toBuilderFileEmit = toBuilderFileEmit;
123562
123837
  function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
123563
123838
  var _a, _b, _c, _d;
123564
123839
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
@@ -123600,8 +123875,8 @@ var ts;
123600
123875
  exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
123601
123876
  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]; }),
123602
123877
  hasReusableDiagnostic: true,
123603
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
123604
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
123878
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }),
123879
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, toBuilderFileEmit),
123605
123880
  affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
123606
123881
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
123607
123882
  latestChangedDtsFile: latestChangedDtsFile,
@@ -123749,7 +124024,7 @@ var ts;
123749
124024
  var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
123750
124025
  if (isNonDirectorySeparatorRoot &&
123751
124026
  dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
123752
- pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart
124027
+ pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) { // Dos style nextPart
123753
124028
  nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
123754
124029
  if (nextDirectorySeparator === -1) {
123755
124030
  // ignore "//vda1cs4850/c$/folderAtRoot"
@@ -125003,7 +125278,7 @@ var ts;
125003
125278
  });
125004
125279
  // Sort by paths closest to importing file Name directory
125005
125280
  var sortedPaths = [];
125006
- var _loop_36 = function (directory) {
125281
+ var _loop_35 = function (directory) {
125007
125282
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
125008
125283
  var pathsInDirectory;
125009
125284
  allFileNames.forEach(function (_a, fileName) {
@@ -125027,9 +125302,9 @@ var ts;
125027
125302
  };
125028
125303
  var out_directory_1;
125029
125304
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
125030
- var state_12 = _loop_36(directory);
125305
+ var state_11 = _loop_35(directory);
125031
125306
  directory = out_directory_1;
125032
- if (state_12 === "break")
125307
+ if (state_11 === "break")
125033
125308
  break;
125034
125309
  }
125035
125310
  if (allFileNames.size) {
@@ -125098,7 +125373,7 @@ var ts;
125098
125373
  }
125099
125374
  function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
125100
125375
  for (var key in paths) {
125101
- var _loop_37 = function (patternText_1) {
125376
+ var _loop_36 = function (patternText_1) {
125102
125377
  var pattern = ts.normalizePath(patternText_1);
125103
125378
  var indexOfStar = pattern.indexOf("*");
125104
125379
  // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
@@ -125165,9 +125440,9 @@ var ts;
125165
125440
  };
125166
125441
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
125167
125442
  var patternText_1 = _a[_i];
125168
- var state_13 = _loop_37(patternText_1);
125169
- if (typeof state_13 === "object")
125170
- return state_13.value;
125443
+ var state_12 = _loop_36(patternText_1);
125444
+ if (typeof state_12 === "object")
125445
+ return state_12.value;
125171
125446
  }
125172
125447
  }
125173
125448
  function validateEnding(_a) {
@@ -125255,15 +125530,21 @@ var ts;
125255
125530
  return undefined;
125256
125531
  }
125257
125532
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
125258
- var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125259
- if (normalizedTargetPath === undefined) {
125533
+ var normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125534
+ if (normalizedTargetPaths === undefined) {
125535
+ return undefined;
125536
+ }
125537
+ var normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125538
+ var relativePaths = ts.flatMap(normalizedSourcePaths, function (sourcePath) {
125539
+ return ts.map(normalizedTargetPaths, function (targetPath) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName)); });
125540
+ });
125541
+ var shortest = ts.min(relativePaths, ts.compareNumberOfDirectorySeparators);
125542
+ if (!shortest) {
125260
125543
  return undefined;
125261
125544
  }
125262
- var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125263
- var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
125264
125545
  return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
125265
- ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
125266
- : ts.removeFileExtension(relativePath);
125546
+ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions)
125547
+ : ts.removeFileExtension(shortest);
125267
125548
  }
125268
125549
  function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
125269
125550
  var path = _a.path, isRedirect = _a.isRedirect;
@@ -125400,8 +125681,8 @@ var ts;
125400
125681
  }
125401
125682
  }
125402
125683
  }
125403
- function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125404
- return ts.firstDefined(rootDirs, function (rootDir) {
125684
+ function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125685
+ return ts.mapDefined(rootDirs, function (rootDir) {
125405
125686
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
125406
125687
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
125407
125688
  });
@@ -127969,8 +128250,15 @@ var ts;
127969
128250
  }
127970
128251
  if (buildInfo.program) {
127971
128252
  // If there are pending changes that are not emitted, project is out of date
128253
+ // When there are syntax errors, changeFileSet will have list of files changed (irrespective of noEmit)
128254
+ // But in case of semantic error we need special treatment.
128255
+ // Checking presence of affectedFilesPendingEmit list is fast and good way to tell if there were semantic errors and file emit was blocked
128256
+ // 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
128257
+ // 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
127972
128258
  if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
127973
- (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
128259
+ (!project.options.noEmit ?
128260
+ (_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length :
128261
+ ts.some(buildInfo.program.semanticDiagnosticsPerFile, ts.isArray))) {
127974
128262
  return {
127975
128263
  type: ts.UpToDateStatusType.OutOfDateBuildInfo,
127976
128264
  buildInfoFile: buildInfoPath
@@ -129151,6 +129439,12 @@ var ts;
129151
129439
  SemanticClassificationFormat["Original"] = "original";
129152
129440
  SemanticClassificationFormat["TwentyTwenty"] = "2020";
129153
129441
  })(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
129442
+ var OrganizeImportsMode;
129443
+ (function (OrganizeImportsMode) {
129444
+ OrganizeImportsMode["All"] = "All";
129445
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
129446
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
129447
+ })(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
129154
129448
  var CompletionTriggerKind;
129155
129449
  (function (CompletionTriggerKind) {
129156
129450
  /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
@@ -130196,6 +130490,8 @@ var ts;
130196
130490
  return lastTypeNode;
130197
130491
  }
130198
130492
  function getContextualTypeFromParentOrAncestorTypeNode(node, checker) {
130493
+ if (node.flags & (8388608 /* NodeFlags.JSDoc */ & ~262144 /* NodeFlags.JavaScriptFile */))
130494
+ return undefined;
130199
130495
  var contextualType = getContextualTypeFromParent(node, checker);
130200
130496
  if (contextualType)
130201
130497
  return contextualType;
@@ -132682,6 +132978,10 @@ var ts;
132682
132978
  return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
132683
132979
  }
132684
132980
  ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
132981
+ function isSourceFileFromLibrary(program, node) {
132982
+ return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
132983
+ }
132984
+ ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
132685
132985
  // #endregion
132686
132986
  })(ts || (ts = {}));
132687
132987
  /*@internal*/
@@ -135708,7 +136008,7 @@ var ts;
135708
136008
  if (preferences.includeCompletionsWithClassMemberSnippets &&
135709
136009
  preferences.includeCompletionsWithInsertText &&
135710
136010
  completionKind === 3 /* CompletionKind.MemberLike */ &&
135711
- isClassLikeMemberCompletion(symbol, location)) {
136011
+ isClassLikeMemberCompletion(symbol, location, sourceFile)) {
135712
136012
  var importAdder = void 0;
135713
136013
  (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
135714
136014
  sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
@@ -135780,7 +136080,7 @@ var ts;
135780
136080
  data: data,
135781
136081
  };
135782
136082
  }
135783
- function isClassLikeMemberCompletion(symbol, location) {
136083
+ function isClassLikeMemberCompletion(symbol, location, sourceFile) {
135784
136084
  // TODO: support JS files.
135785
136085
  if (ts.isInJSFile(location)) {
135786
136086
  return false;
@@ -135814,6 +136114,7 @@ var ts;
135814
136114
  location.parent.parent &&
135815
136115
  ts.isClassElement(location.parent) &&
135816
136116
  location === location.parent.name &&
136117
+ location.parent.getLastToken(sourceFile) === location.parent.name &&
135817
136118
  ts.isClassLike(location.parent.parent)) ||
135818
136119
  (location.parent &&
135819
136120
  ts.isSyntaxList(location) &&
@@ -142975,6 +143276,12 @@ var ts;
142975
143276
  var label = ts.getTargetLabel(node.parent, node.text);
142976
143277
  return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
142977
143278
  }
143279
+ if (node.kind === 105 /* SyntaxKind.ReturnKeyword */) {
143280
+ var functionDeclaration = ts.findAncestor(node.parent, function (n) {
143281
+ return ts.isClassStaticBlockDeclaration(n) ? "quit" : ts.isFunctionLikeDeclaration(n);
143282
+ });
143283
+ return functionDeclaration ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] : undefined;
143284
+ }
142978
143285
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
142979
143286
  var classDecl = node.parent.parent;
142980
143287
  var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
@@ -143110,13 +143417,16 @@ var ts;
143110
143417
  if (!baseDeclaration)
143111
143418
  return;
143112
143419
  var baseTypeNode = ts.getEffectiveBaseTypeNode(baseDeclaration);
143113
- var baseType = baseTypeNode ? typeChecker.getTypeAtLocation(baseTypeNode) : undefined;
143114
- if (!baseType)
143420
+ if (!baseTypeNode)
143421
+ return;
143422
+ var expression = ts.skipParentheses(baseTypeNode.expression);
143423
+ var base = ts.isClassExpression(expression) ? expression.symbol : typeChecker.getSymbolAtLocation(expression);
143424
+ if (!base)
143115
143425
  return;
143116
143426
  var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(classElement.name));
143117
143427
  var symbol = ts.hasStaticModifier(classElement)
143118
- ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbolAtLocation(baseType.symbol, baseDeclaration), name)
143119
- : typeChecker.getPropertyOfType(baseType, name);
143428
+ ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbol(base), name)
143429
+ : typeChecker.getPropertyOfType(typeChecker.getDeclaredTypeOfSymbol(base), name);
143120
143430
  if (!symbol)
143121
143431
  return;
143122
143432
  return getDefinitionFromSymbol(typeChecker, symbol, node);
@@ -143823,19 +144133,24 @@ var ts;
143823
144133
  return getCommentOwnerInfoWorker(commentOwner.initializer, options);
143824
144134
  case 260 /* SyntaxKind.ClassDeclaration */:
143825
144135
  case 261 /* SyntaxKind.InterfaceDeclaration */:
143826
- case 168 /* SyntaxKind.PropertySignature */:
143827
144136
  case 263 /* SyntaxKind.EnumDeclaration */:
143828
144137
  case 302 /* SyntaxKind.EnumMember */:
143829
144138
  case 262 /* SyntaxKind.TypeAliasDeclaration */:
143830
144139
  return { commentOwner: commentOwner };
144140
+ case 168 /* SyntaxKind.PropertySignature */: {
144141
+ var host_1 = commentOwner;
144142
+ return host_1.type && ts.isFunctionTypeNode(host_1.type)
144143
+ ? { commentOwner: commentOwner, parameters: host_1.type.parameters, hasReturn: hasReturn(host_1.type, options) }
144144
+ : { commentOwner: commentOwner };
144145
+ }
143831
144146
  case 240 /* SyntaxKind.VariableStatement */: {
143832
144147
  var varStatement = commentOwner;
143833
144148
  var varDeclarations = varStatement.declarationList.declarations;
143834
- var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer
144149
+ var host_2 = varDeclarations.length === 1 && varDeclarations[0].initializer
143835
144150
  ? getRightHandSideOfAssignment(varDeclarations[0].initializer)
143836
144151
  : undefined;
143837
- return host_1
143838
- ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) }
144152
+ return host_2
144153
+ ? { commentOwner: commentOwner, parameters: host_2.parameters, hasReturn: hasReturn(host_2, options) }
143839
144154
  : { commentOwner: commentOwner };
143840
144155
  }
143841
144156
  case 308 /* SyntaxKind.SourceFile */:
@@ -143865,7 +144180,7 @@ var ts;
143865
144180
  }
143866
144181
  function hasReturn(node, options) {
143867
144182
  return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) &&
143868
- (ts.isArrowFunction(node) && ts.isExpression(node.body)
144183
+ (ts.isFunctionTypeNode(node) || ts.isArrowFunction(node) && ts.isExpression(node.body)
143869
144184
  || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }));
143870
144185
  }
143871
144186
  function getRightHandSideOfAssignment(rightHandSide) {
@@ -144906,23 +145221,39 @@ var ts;
144906
145221
  * 2) Coalescing imports from the same module
144907
145222
  * 3) Sorting imports
144908
145223
  */
144909
- function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) {
145224
+ function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
144910
145225
  var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
144911
- var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
145226
+ var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
145227
+ var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
145228
+ var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
145229
+ var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
145230
+ var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
145231
+ var processImportsOfSameModuleSpecifier = function (importGroup) {
145232
+ var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
145233
+ return shouldSort
145234
+ ? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
145235
+ : processedDeclarations;
145236
+ };
144912
145237
  // All of the old ImportDeclarations in the file, in syntactic order.
144913
145238
  var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
144914
- topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144915
- // All of the old ExportDeclarations in the file, in syntactic order.
144916
- var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
144917
- organizeImportsWorker(topLevelExportDecls, coalesceExports);
145239
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
145240
+ // Exports are always used
145241
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
145242
+ // All of the old ExportDeclarations in the file, in syntactic order.
145243
+ var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
145244
+ organizeImportsWorker(topLevelExportDecls, coalesceExports);
145245
+ }
144918
145246
  for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
144919
145247
  var ambientModule = _a[_i];
144920
145248
  if (!ambientModule.body)
144921
145249
  continue;
144922
145250
  var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
144923
- ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144924
- var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
144925
- organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
145251
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
145252
+ // Exports are always used
145253
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
145254
+ var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
145255
+ organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
145256
+ }
144926
145257
  }
144927
145258
  return changeTracker.getChanges();
144928
145259
  function organizeImportsWorker(oldImportDecls, coalesce) {
@@ -144935,8 +145266,12 @@ var ts;
144935
145266
  // Consider: we could do a more careful check that this trivia is actually a header,
144936
145267
  // but the consequences of being wrong are very minor.
144937
145268
  ts.suppressLeadingTrivia(oldImportDecls[0]);
144938
- var oldImportGroups = ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); });
144939
- var sortedImportGroups = ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); });
145269
+ var oldImportGroups = shouldCombine
145270
+ ? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
145271
+ : [oldImportDecls];
145272
+ var sortedImportGroups = shouldSort
145273
+ ? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
145274
+ : oldImportGroups;
144940
145275
  var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
144941
145276
  return getExternalModuleName(importGroup[0].moduleSpecifier)
144942
145277
  ? coalesce(importGroup)
@@ -145000,11 +145335,7 @@ var ts;
145000
145335
  }
145001
145336
  return false;
145002
145337
  }
145003
- function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
145004
- // As a precaution, consider unused import detection to be destructive (GH #43051)
145005
- if (skipDestructiveCodeActions) {
145006
- return oldImports;
145007
- }
145338
+ function removeUnusedImports(oldImports, sourceFile, program) {
145008
145339
  var typeChecker = program.getTypeChecker();
145009
145340
  var compilerOptions = program.getCompilerOptions();
145010
145341
  var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
@@ -145860,7 +146191,7 @@ var ts;
145860
146191
  return bestMatch;
145861
146192
  }
145862
146193
  function betterMatch(a, b) {
145863
- return ts.min(a, b, compareMatches);
146194
+ return ts.min([a, b], compareMatches);
145864
146195
  }
145865
146196
  function compareMatches(a, b) {
145866
146197
  return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
@@ -146469,8 +146800,8 @@ var ts;
146469
146800
  }
146470
146801
  if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
146471
146802
  var stack = [ts.scanner.getToken()];
146472
- var token = ts.scanner.scan();
146473
146803
  loop: while (ts.length(stack)) {
146804
+ var token = ts.scanner.scan();
146474
146805
  switch (token) {
146475
146806
  case 1 /* SyntaxKind.EndOfFileToken */:
146476
146807
  break loop;
@@ -146498,7 +146829,6 @@ var ts;
146498
146829
  }
146499
146830
  break;
146500
146831
  }
146501
- token = ts.scanner.scan();
146502
146832
  }
146503
146833
  nextToken();
146504
146834
  }
@@ -148977,7 +149307,7 @@ var ts;
148977
149307
  tags = signature.getJsDocTags();
148978
149308
  if (allSignatures.length > 1 && documentation.length === 0 && tags.length === 0) {
148979
149309
  documentation = allSignatures[0].getDocumentationComment(typeChecker);
148980
- tags = allSignatures[0].getJsDocTags();
149310
+ tags = allSignatures[0].getJsDocTags().filter(function (tag) { return tag.name !== "deprecated"; }); // should only include @deprecated JSDoc tag on the first overload (#49368)
148981
149311
  }
148982
149312
  }
148983
149313
  function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
@@ -149320,7 +149650,7 @@ var ts;
149320
149650
  return false;
149321
149651
  }
149322
149652
  function shouldRescanJsxText(node) {
149323
- return ts.isJsxText(node);
149653
+ return ts.isJsxText(node) || ts.isJsxElement(node) && (lastTokenInfo === null || lastTokenInfo === void 0 ? void 0 : lastTokenInfo.token.kind) === 11 /* SyntaxKind.JsxText */;
149324
149654
  }
149325
149655
  function shouldRescanSlashToken(container) {
149326
149656
  return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
@@ -150089,10 +150419,10 @@ var ts;
150089
150419
  !nodeIsInDecoratorContext(context.nextTokenParent);
150090
150420
  }
150091
150421
  function nodeIsInDecoratorContext(node) {
150092
- while (ts.isExpressionNode(node)) {
150422
+ while (node && ts.isExpression(node)) {
150093
150423
  node = node.parent;
150094
150424
  }
150095
- return node.kind === 167 /* SyntaxKind.Decorator */;
150425
+ return node && node.kind === 167 /* SyntaxKind.Decorator */;
150096
150426
  }
150097
150427
  function isStartOfVariableDeclarationList(context) {
150098
150428
  return context.currentTokenParent.kind === 258 /* SyntaxKind.VariableDeclarationList */ &&
@@ -153010,6 +153340,26 @@ var ts;
153010
153340
  function startPositionToDeleteNodeInList(sourceFile, node) {
153011
153341
  return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
153012
153342
  }
153343
+ function endPositionToDeleteNodeInList(sourceFile, node, prevNode, nextNode) {
153344
+ var end = startPositionToDeleteNodeInList(sourceFile, nextNode);
153345
+ if (prevNode === undefined || ts.positionsAreOnSameLine(getAdjustedEndPosition(sourceFile, node, {}), end, sourceFile)) {
153346
+ return end;
153347
+ }
153348
+ var token = ts.findPrecedingToken(nextNode.getStart(sourceFile), sourceFile);
153349
+ if (isSeparator(node, token)) {
153350
+ var prevToken = ts.findPrecedingToken(node.getStart(sourceFile), sourceFile);
153351
+ if (isSeparator(prevNode, prevToken)) {
153352
+ var pos = ts.skipTrivia(sourceFile.text, token.getEnd(), /*stopAfterLineBreak*/ true, /*stopAtComments*/ true);
153353
+ if (ts.positionsAreOnSameLine(prevToken.getStart(sourceFile), token.getStart(sourceFile), sourceFile)) {
153354
+ return ts.isLineBreak(sourceFile.text.charCodeAt(pos - 1)) ? pos - 1 : pos;
153355
+ }
153356
+ if (ts.isLineBreak(sourceFile.text.charCodeAt(pos))) {
153357
+ return pos;
153358
+ }
153359
+ }
153360
+ }
153361
+ return end;
153362
+ }
153013
153363
  function getClassOrObjectBraceEnds(cls, sourceFile) {
153014
153364
  var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
153015
153365
  var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
@@ -153567,7 +153917,7 @@ var ts;
153567
153917
  deletedNodesInLists.add(node);
153568
153918
  changes.deleteRange(sourceFile, {
153569
153919
  pos: startPositionToDeleteNodeInList(sourceFile, node),
153570
- end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
153920
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : endPositionToDeleteNodeInList(sourceFile, node, containingList[index - 1], containingList[index + 1]),
153571
153921
  });
153572
153922
  }
153573
153923
  })(textChanges = ts.textChanges || (ts.textChanges = {}));
@@ -154037,6 +154387,15 @@ var ts;
154037
154387
  });
154038
154388
  }
154039
154389
  function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
154390
+ if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
154391
+ var exprType = checker.getTypeAtLocation(insertionSite);
154392
+ var asyncIter = checker.getAsyncIterableType();
154393
+ if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
154394
+ var forOf = insertionSite.parent;
154395
+ changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
154396
+ return;
154397
+ }
154398
+ }
154040
154399
  if (ts.isBinaryExpression(insertionSite)) {
154041
154400
  for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
154042
154401
  var side = _a[_i];
@@ -157762,6 +158121,143 @@ var ts;
157762
158121
  })(ts || (ts = {}));
157763
158122
  /* @internal */
157764
158123
  var ts;
158124
+ (function (ts) {
158125
+ var codefix;
158126
+ (function (codefix) {
158127
+ var fixId = "fixImportNonExportedMember";
158128
+ var errorCodes = [
158129
+ ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
158130
+ ];
158131
+ codefix.registerCodeFix({
158132
+ errorCodes: errorCodes,
158133
+ fixIds: [fixId],
158134
+ getCodeActions: function (context) {
158135
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
158136
+ var info = getInfo(sourceFile, span.start, program);
158137
+ if (info === undefined)
158138
+ return undefined;
158139
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
158140
+ 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)];
158141
+ },
158142
+ getAllCodeActions: function (context) {
158143
+ var program = context.program;
158144
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
158145
+ var exports = new ts.Map();
158146
+ codefix.eachDiagnostic(context, errorCodes, function (diag) {
158147
+ var info = getInfo(diag.file, diag.start, program);
158148
+ if (info === undefined)
158149
+ return undefined;
158150
+ var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
158151
+ if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
158152
+ changes.insertExportModifier(moduleSourceFile, node);
158153
+ }
158154
+ else {
158155
+ var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
158156
+ if (exportName.isTypeOnly) {
158157
+ moduleExports.typeOnlyExports.push(exportName);
158158
+ }
158159
+ else {
158160
+ moduleExports.exports.push(exportName);
158161
+ }
158162
+ exports.set(moduleSourceFile, moduleExports);
158163
+ }
158164
+ });
158165
+ exports.forEach(function (moduleExports, moduleSourceFile) {
158166
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
158167
+ if (exportDeclaration && exportDeclaration.isTypeOnly) {
158168
+ doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
158169
+ doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
158170
+ }
158171
+ else {
158172
+ doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
158173
+ }
158174
+ });
158175
+ }));
158176
+ }
158177
+ });
158178
+ function getInfo(sourceFile, pos, program) {
158179
+ var _a;
158180
+ var token = ts.getTokenAtPosition(sourceFile, pos);
158181
+ if (ts.isIdentifier(token)) {
158182
+ var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
158183
+ if (importDeclaration === undefined)
158184
+ return undefined;
158185
+ var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
158186
+ if (moduleSpecifier === undefined)
158187
+ return undefined;
158188
+ var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
158189
+ if (resolvedModule === undefined)
158190
+ return undefined;
158191
+ var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
158192
+ if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
158193
+ return undefined;
158194
+ var moduleSymbol = moduleSourceFile.symbol;
158195
+ var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
158196
+ if (locals === undefined)
158197
+ return undefined;
158198
+ var localSymbol = locals.get(token.escapedText);
158199
+ if (localSymbol === undefined)
158200
+ return undefined;
158201
+ var node = getNodeOfSymbol(localSymbol);
158202
+ if (node === undefined)
158203
+ return undefined;
158204
+ var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
158205
+ return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
158206
+ }
158207
+ return undefined;
158208
+ }
158209
+ function doChange(changes, program, _a) {
158210
+ var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
158211
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
158212
+ if (exportDeclaration) {
158213
+ updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
158214
+ }
158215
+ else if (ts.canHaveExportModifier(node)) {
158216
+ changes.insertExportModifier(moduleSourceFile, node);
158217
+ }
158218
+ else {
158219
+ createExport(changes, program, moduleSourceFile, [exportName]);
158220
+ }
158221
+ }
158222
+ function doChanges(changes, program, sourceFile, moduleExports, node) {
158223
+ if (ts.length(moduleExports)) {
158224
+ if (node) {
158225
+ updateExport(changes, program, sourceFile, node, moduleExports);
158226
+ }
158227
+ else {
158228
+ createExport(changes, program, sourceFile, moduleExports);
158229
+ }
158230
+ }
158231
+ }
158232
+ function tryGetExportDeclaration(sourceFile, isTypeOnly) {
158233
+ var predicate = function (node) {
158234
+ return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
158235
+ };
158236
+ return ts.findLast(sourceFile.statements, predicate);
158237
+ }
158238
+ function updateExport(changes, program, sourceFile, node, names) {
158239
+ var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
158240
+ var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
158241
+ 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));
158242
+ }
158243
+ function createExport(changes, program, sourceFile, names) {
158244
+ changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
158245
+ }
158246
+ function createExportSpecifiers(names, allowTypeModifier) {
158247
+ return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
158248
+ }
158249
+ function getNodeOfSymbol(symbol) {
158250
+ if (symbol.valueDeclaration === undefined) {
158251
+ return ts.firstOrUndefined(symbol.declarations);
158252
+ }
158253
+ var declaration = symbol.valueDeclaration;
158254
+ var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
158255
+ return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
158256
+ }
158257
+ })(codefix = ts.codefix || (ts.codefix = {}));
158258
+ })(ts || (ts = {}));
158259
+ /* @internal */
158260
+ var ts;
157765
158261
  (function (ts) {
157766
158262
  var codefix;
157767
158263
  (function (codefix) {
@@ -158292,7 +158788,7 @@ var ts;
158292
158788
  var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
158293
158789
  if (argIndex < 0)
158294
158790
  return undefined;
158295
- var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */));
158791
+ var signature = checker.getResolvedSignature(parent.parent);
158296
158792
  if (!(signature && signature.declaration && signature.parameters[argIndex]))
158297
158793
  return undefined;
158298
158794
  var param = signature.parameters[argIndex].valueDeclaration;
@@ -158339,13 +158835,13 @@ var ts;
158339
158835
  if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
158340
158836
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
158341
158837
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
158342
- if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
158838
+ if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
158343
158839
  return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
158344
158840
  }
158345
158841
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
158346
158842
  if (sourceFile.commonJsModuleIndicator)
158347
158843
  return undefined;
158348
- if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
158844
+ if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
158349
158845
  return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
158350
158846
  }
158351
158847
  }
@@ -158355,7 +158851,7 @@ var ts;
158355
158851
  return undefined;
158356
158852
  // Prefer to change the class instead of the interface if they are merged
158357
158853
  var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
158358
- if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
158854
+ if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
158359
158855
  var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
158360
158856
  if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
158361
158857
  return undefined;
@@ -158367,14 +158863,11 @@ var ts;
158367
158863
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
158368
158864
  }
158369
158865
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
158370
- if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158866
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158371
158867
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
158372
158868
  }
158373
158869
  return undefined;
158374
158870
  }
158375
- function isSourceFileFromLibrary(program, node) {
158376
- return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
158377
- }
158378
158871
  function getActionsForMissingMemberDeclaration(context, info) {
158379
158872
  return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
158380
158873
  createActionsForAddMissingMemberInTypeScriptFile(context, info);
@@ -163800,8 +164293,8 @@ var ts;
163800
164293
  var i = 0;
163801
164294
  for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
163802
164295
  var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
163803
- var description = functionExtraction.description;
163804
164296
  if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
164297
+ var description = functionExtraction.description;
163805
164298
  if (functionExtraction.errors.length === 0) {
163806
164299
  // Don't issue refactorings with duplicated names.
163807
164300
  // Scopes come back in "innermost first" order, so extractions will
@@ -163825,15 +164318,15 @@ var ts;
163825
164318
  }
163826
164319
  }
163827
164320
  if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
164321
+ var description = constantExtraction.description;
163828
164322
  if (constantExtraction.errors.length === 0) {
163829
164323
  // Don't issue refactorings with duplicated names.
163830
164324
  // Scopes come back in "innermost first" order, so extractions will
163831
164325
  // preferentially go into nearer scopes
163832
- var description_1 = constantExtraction.description;
163833
- if (!usedConstantNames.has(description_1)) {
163834
- usedConstantNames.set(description_1, true);
164326
+ if (!usedConstantNames.has(description)) {
164327
+ usedConstantNames.set(description, true);
163835
164328
  constantActions.push({
163836
- description: description_1,
164329
+ description: description,
163837
164330
  name: "constant_scope_".concat(i),
163838
164331
  kind: extractConstantAction.kind
163839
164332
  });
@@ -163978,7 +164471,6 @@ var ts;
163978
164471
  var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
163979
164472
  // Do the same for the ending position
163980
164473
  var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
163981
- var declarations = [];
163982
164474
  // We'll modify these flags as we walk the tree to collect data
163983
164475
  // about what things need to be done as part of the extraction.
163984
164476
  var rangeFacts = RangeFacts.None;
@@ -164021,7 +164513,7 @@ var ts;
164021
164513
  // the expression.
164022
164514
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
164023
164515
  }
164024
- return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
164516
+ return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
164025
164517
  }
164026
164518
  if (ts.isReturnStatement(start) && !start.expression) {
164027
164519
  // Makes no sense to extract an expression-less return statement.
@@ -164033,7 +164525,7 @@ var ts;
164033
164525
  if (errors) {
164034
164526
  return { errors: errors };
164035
164527
  }
164036
- return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
164528
+ return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
164037
164529
  /**
164038
164530
  * Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
164039
164531
  * @param node The unrefined extraction node.
@@ -164045,10 +164537,10 @@ var ts;
164045
164537
  }
164046
164538
  }
164047
164539
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
164048
- var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164540
+ var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164049
164541
  var numInitializers = 0;
164050
164542
  var lastInitializer = void 0;
164051
- for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
164543
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
164052
164544
  var declaration = declarations_5[_i];
164053
164545
  if (declaration.initializer) {
164054
164546
  numInitializers++;
@@ -164148,7 +164640,6 @@ var ts;
164148
164640
  (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
164149
164641
  return true;
164150
164642
  }
164151
- declarations.push(node.symbol);
164152
164643
  }
164153
164644
  // Some things can't be extracted in certain situations
164154
164645
  switch (node.kind) {
@@ -165873,7 +166364,7 @@ var ts;
165873
166364
  function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
165874
166365
  var checker = program.getTypeChecker();
165875
166366
  var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective);
165876
- if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
166367
+ if (oldFile.externalModuleIndicator === undefined && oldFile.commonJsModuleIndicator === undefined && usage.oldImportsNeededByNewFile.size() === 0) {
165877
166368
  deleteMovedStatements(oldFile, toMove.ranges, changes);
165878
166369
  return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
165879
166370
  }
@@ -166114,7 +166605,12 @@ var ts;
166114
166605
  switch (name.kind) {
166115
166606
  case 79 /* SyntaxKind.Identifier */:
166116
166607
  if (isUnused(name)) {
166117
- changes.delete(sourceFile, name);
166608
+ if (varDecl.initializer && ts.isRequireCall(varDecl.initializer, /*requireStringLiteralLikeArgument*/ true)) {
166609
+ changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && ts.length(varDecl.parent.declarations) === 1 ? varDecl.parent.parent : varDecl);
166610
+ }
166611
+ else {
166612
+ changes.delete(sourceFile, name);
166613
+ }
166118
166614
  }
166119
166615
  break;
166120
166616
  case 204 /* SyntaxKind.ArrayBindingPattern */:
@@ -166346,6 +166842,9 @@ var ts;
166346
166842
  ts.copyEntries(this.map, clone.map);
166347
166843
  return clone;
166348
166844
  };
166845
+ SymbolSet.prototype.size = function () {
166846
+ return this.map.size;
166847
+ };
166349
166848
  return SymbolSet;
166350
166849
  }());
166351
166850
  function isTopLevelDeclaration(node) {
@@ -166434,7 +166933,8 @@ var ts;
166434
166933
  if (useEs6Exports) {
166435
166934
  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)));
166436
166935
  }
166437
- return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
166936
+ return !!sourceFile.symbol && !!sourceFile.symbol.exports &&
166937
+ getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
166438
166938
  }
166439
166939
  function addExport(decl, useEs6Exports) {
166440
166940
  return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
@@ -168194,8 +168694,8 @@ var ts;
168194
168694
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
168195
168695
  }
168196
168696
  };
168197
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168198
- var declaration = declarations_7[_i];
168697
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
168698
+ var declaration = declarations_6[_i];
168199
168699
  _loop_20(declaration);
168200
168700
  }
168201
168701
  }
@@ -168221,8 +168721,8 @@ var ts;
168221
168721
  if (inheritedDocs)
168222
168722
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
168223
168723
  };
168224
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
168225
- var declaration = declarations_8[_i];
168724
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168725
+ var declaration = declarations_7[_i];
168226
168726
  _loop_21(declaration);
168227
168727
  }
168228
168728
  }
@@ -169392,12 +169892,14 @@ var ts;
169392
169892
  return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
169393
169893
  }
169394
169894
  function organizeImports(args, formatOptions, preferences) {
169895
+ var _a;
169395
169896
  if (preferences === void 0) { preferences = ts.emptyOptions; }
169396
169897
  synchronizeHostData();
169397
169898
  ts.Debug.assert(args.type === "file");
169398
169899
  var sourceFile = getValidSourceFile(args.fileName);
169399
169900
  var formatContext = ts.formatting.getFormatContext(formatOptions, host);
169400
- return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions);
169901
+ var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
169902
+ return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
169401
169903
  }
169402
169904
  function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
169403
169905
  if (preferences === void 0) { preferences = ts.emptyOptions; }