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.
package/lib/tsserver.js CHANGED
@@ -105,11 +105,11 @@ var ts;
105
105
  (function (ts) {
106
106
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
107
107
  // If changing the text in this section, be sure to test `configurePrerelease` too.
108
- ts.versionMajorMinor = "4.9";
108
+ ts.versionMajorMinor = "5.0";
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = "".concat(ts.versionMajorMinor, ".1-beta");
112
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221101");
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -1901,8 +1901,8 @@ var ts;
1901
1901
  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);
1902
1902
  }
1903
1903
  ts.compareTextSpans = compareTextSpans;
1904
- function min(a, b, compare) {
1905
- return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b;
1904
+ function min(items, compare) {
1905
+ return reduceLeft(items, function (x, y) { return compare(x, y) === -1 /* Comparison.LessThan */ ? x : y; });
1906
1906
  }
1907
1907
  ts.min = min;
1908
1908
  /**
@@ -3215,11 +3215,13 @@ var ts;
3215
3215
  // > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
3216
3216
  // > MUST NOT include leading zeroes.
3217
3217
  var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
3218
+ var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
3218
3219
  // https://semver.org/#spec-item-10
3219
3220
  // > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
3220
3221
  // > identifiers immediately following the patch or pre-release version. Identifiers MUST
3221
3222
  // > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
3222
3223
  var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
3224
+ var buildPartRegExp = /^[a-z0-9-]+$/i;
3223
3225
  // https://semver.org/#spec-item-9
3224
3226
  // > Numeric identifiers MUST NOT include leading zeroes.
3225
3227
  var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
@@ -3239,13 +3241,15 @@ var ts;
3239
3241
  ts.Debug.assert(major >= 0, "Invalid argument: major");
3240
3242
  ts.Debug.assert(minor >= 0, "Invalid argument: minor");
3241
3243
  ts.Debug.assert(patch >= 0, "Invalid argument: patch");
3242
- ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
3243
- ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
3244
+ var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
3245
+ var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
3246
+ ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
3247
+ ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
3244
3248
  this.major = major;
3245
3249
  this.minor = minor;
3246
3250
  this.patch = patch;
3247
- this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
3248
- this.build = build ? build.split(".") : ts.emptyArray;
3251
+ this.prerelease = prereleaseArray;
3252
+ this.build = buildArray;
3249
3253
  }
3250
3254
  Version.tryParse = function (text) {
3251
3255
  var result = tryParseComponents(text);
@@ -3284,6 +3288,10 @@ var ts;
3284
3288
  default: return ts.Debug.assertNever(field);
3285
3289
  }
3286
3290
  };
3291
+ Version.prototype.with = function (fields) {
3292
+ 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;
3293
+ return new Version(major, minor, patch, prerelease, build);
3294
+ };
3287
3295
  Version.prototype.toString = function () {
3288
3296
  var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
3289
3297
  if (ts.some(this.prerelease))
@@ -3292,7 +3300,7 @@ var ts;
3292
3300
  result += "+".concat(this.build.join("."));
3293
3301
  return result;
3294
3302
  };
3295
- Version.zero = new Version(0, 0, 0);
3303
+ Version.zero = new Version(0, 0, 0, ["0"]);
3296
3304
  return Version;
3297
3305
  }());
3298
3306
  ts.Version = Version;
@@ -3375,6 +3383,10 @@ var ts;
3375
3383
  }
3376
3384
  return undefined;
3377
3385
  };
3386
+ /**
3387
+ * Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
3388
+ * in `node-semver`.
3389
+ */
3378
3390
  VersionRange.prototype.test = function (version) {
3379
3391
  if (typeof version === "string")
3380
3392
  version = new Version(version);
@@ -3485,19 +3497,20 @@ var ts;
3485
3497
  break;
3486
3498
  case "<":
3487
3499
  case ">=":
3488
- comparators.push(createComparator(operator, version));
3500
+ comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
3501
+ createComparator(operator, version));
3489
3502
  break;
3490
3503
  case "<=":
3491
3504
  case ">":
3492
- comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
3493
- isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
3505
+ comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
3506
+ isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
3494
3507
  createComparator(operator, version));
3495
3508
  break;
3496
3509
  case "=":
3497
3510
  case undefined:
3498
3511
  if (isWildcard(minor) || isWildcard(patch)) {
3499
- comparators.push(createComparator(">=", version));
3500
- comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
3512
+ comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
3513
+ comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
3501
3514
  }
3502
3515
  else {
3503
3516
  comparators.push(createComparator("=", version));
@@ -5106,8 +5119,8 @@ var ts;
5106
5119
  NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
5107
5120
  NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
5108
5121
  NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
5109
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper";
5110
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding";
5122
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAccessInAsync"] = 2048] = "MethodWithSuperPropertyAccessInAsync";
5123
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAssignmentInAsync"] = 4096] = "MethodWithSuperPropertyAssignmentInAsync";
5111
5124
  NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
5112
5125
  NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
5113
5126
  NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
@@ -6742,7 +6755,7 @@ var ts;
6742
6755
  }
6743
6756
  /*@internal*/
6744
6757
  function createSystemWatchFunctions(_a) {
6745
- 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;
6758
+ 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;
6746
6759
  var pollingWatches = new ts.Map();
6747
6760
  var fsWatches = new ts.Map();
6748
6761
  var fsWatchesRecursive = new ts.Map();
@@ -6808,8 +6821,8 @@ var ts;
6808
6821
  return useNonPollingWatchers ?
6809
6822
  // Use notifications from FS to watch with falling back to fs.watchFile
6810
6823
  generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
6811
- // Default to do not use fixed polling interval
6812
- { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.UseFsEvents };
6824
+ // Default to using fs events
6825
+ { watchFile: ts.WatchFileKind.UseFsEvents };
6813
6826
  }
6814
6827
  }
6815
6828
  function generateWatchFileOptions(watchFile, fallbackPolling, options) {
@@ -7081,7 +7094,6 @@ var ts;
7081
7094
  tscWatchFile: process.env.TSC_WATCHFILE,
7082
7095
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
7083
7096
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
7084
- defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7085
7097
  inodeWatching: isLinuxOrMacOs,
7086
7098
  sysLog: sysLog,
7087
7099
  }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
@@ -9592,6 +9604,10 @@ var ts;
9592
9604
  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"),
9593
9605
  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"),
9594
9606
  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}'"),
9607
+ 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}."),
9608
+ Matched_0_condition_1: diag(6403, ts.DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."),
9609
+ 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}'."),
9610
+ Saw_non_matching_condition_0: diag(6405, ts.DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
9595
9611
  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}'"),
9596
9612
  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."),
9597
9613
  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."),
@@ -9908,6 +9924,8 @@ var ts;
9908
9924
  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}\""),
9909
9925
  Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
9910
9926
  Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
9927
+ Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
9928
+ Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
9911
9929
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9912
9930
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9913
9931
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -11365,7 +11383,7 @@ var ts;
11365
11383
  return -1;
11366
11384
  }
11367
11385
  function peekExtendedUnicodeEscape() {
11368
- if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11386
+ if (codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11369
11387
  var start_2 = pos;
11370
11388
  pos += 3;
11371
11389
  var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
@@ -21668,6 +21686,32 @@ var ts;
21668
21686
  return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21669
21687
  }
21670
21688
  ts.getParameterTypeNode = getParameterTypeNode;
21689
+ function isTypeDeclaration(node) {
21690
+ switch (node.kind) {
21691
+ case 165 /* SyntaxKind.TypeParameter */:
21692
+ case 260 /* SyntaxKind.ClassDeclaration */:
21693
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
21694
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
21695
+ case 263 /* SyntaxKind.EnumDeclaration */:
21696
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
21697
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
21698
+ case 342 /* SyntaxKind.JSDocEnumTag */:
21699
+ return true;
21700
+ case 270 /* SyntaxKind.ImportClause */:
21701
+ return node.isTypeOnly;
21702
+ case 273 /* SyntaxKind.ImportSpecifier */:
21703
+ case 278 /* SyntaxKind.ExportSpecifier */:
21704
+ return node.parent.parent.isTypeOnly;
21705
+ default:
21706
+ return false;
21707
+ }
21708
+ }
21709
+ ts.isTypeDeclaration = isTypeDeclaration;
21710
+ function canHaveExportModifier(node) {
21711
+ return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
21712
+ || ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
21713
+ }
21714
+ ts.canHaveExportModifier = canHaveExportModifier;
21671
21715
  })(ts || (ts = {}));
21672
21716
  /* @internal */
21673
21717
  var ts;
@@ -21676,13 +21720,11 @@ var ts;
21676
21720
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21677
21721
  */
21678
21722
  function createBaseNodeFactory() {
21679
- // tslint:disable variable-name
21680
21723
  var NodeConstructor;
21681
21724
  var TokenConstructor;
21682
21725
  var IdentifierConstructor;
21683
21726
  var PrivateIdentifierConstructor;
21684
21727
  var SourceFileConstructor;
21685
- // tslint:enable variable-name
21686
21728
  return {
21687
21729
  createBaseSourceFileNode: createBaseSourceFileNode,
21688
21730
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -23146,7 +23188,7 @@ var ts;
23146
23188
  return node;
23147
23189
  }
23148
23190
  // @api
23149
- function createIdentifier(text, typeArguments, originalKeywordKind) {
23191
+ function createIdentifier(text, typeArguments, originalKeywordKind, hasExtendedUnicodeEscape) {
23150
23192
  var node = createBaseIdentifier(text, originalKeywordKind);
23151
23193
  if (typeArguments) {
23152
23194
  // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
@@ -23155,6 +23197,10 @@ var ts;
23155
23197
  if (node.originalKeywordKind === 133 /* SyntaxKind.AwaitKeyword */) {
23156
23198
  node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */;
23157
23199
  }
23200
+ if (hasExtendedUnicodeEscape) {
23201
+ node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
23202
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
23203
+ }
23158
23204
  return node;
23159
23205
  }
23160
23206
  // @api
@@ -27610,11 +27656,9 @@ var ts;
27610
27656
  rawTextScanner.setText("`" + rawText + "`");
27611
27657
  break;
27612
27658
  case 15 /* SyntaxKind.TemplateHead */:
27613
- // tslint:disable-next-line no-invalid-template-strings
27614
27659
  rawTextScanner.setText("`" + rawText + "${");
27615
27660
  break;
27616
27661
  case 16 /* SyntaxKind.TemplateMiddle */:
27617
- // tslint:disable-next-line no-invalid-template-strings
27618
27662
  rawTextScanner.setText("}" + rawText + "${");
27619
27663
  break;
27620
27664
  case 17 /* SyntaxKind.TemplateTail */:
@@ -27973,7 +28017,6 @@ var ts;
27973
28017
  return node;
27974
28018
  }
27975
28019
  ts.createInputFiles = createInputFiles;
27976
- // tslint:disable-next-line variable-name
27977
28020
  var SourceMapSource;
27978
28021
  /**
27979
28022
  * Create an external source map source file reference
@@ -28765,6 +28808,8 @@ var ts;
28765
28808
  // - The verb (`next`, `throw`, or `return` method) to delegate to the expression
28766
28809
  // of a `yield*`.
28767
28810
  // - The result of evaluating the verb delegated to the expression of a `yield*`.
28811
+ // g A temporary variable that holds onto the generator object until the generator
28812
+ // is started, allowing it to also act as the `suspendedStart` state.
28768
28813
  //
28769
28814
  // functions:
28770
28815
  // verb(n) Creates a bound callback to the `step` function for opcode `n`.
@@ -28803,7 +28848,7 @@ var ts;
28803
28848
  importName: "__generator",
28804
28849
  scoped: false,
28805
28850
  priority: 6,
28806
- 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 };"
28851
+ 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 };"
28807
28852
  };
28808
28853
  // ES Module Helpers
28809
28854
  ts.createBindingHelper = {
@@ -32107,13 +32152,11 @@ var ts;
32107
32152
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32108
32153
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32109
32154
  // capture constructors in 'initializeState' to avoid null checks
32110
- // tslint:disable variable-name
32111
32155
  var NodeConstructor;
32112
32156
  var TokenConstructor;
32113
32157
  var IdentifierConstructor;
32114
32158
  var PrivateIdentifierConstructor;
32115
32159
  var SourceFileConstructor;
32116
- // tslint:enable variable-name
32117
32160
  function countNode(node) {
32118
32161
  nodeCount++;
32119
32162
  return node;
@@ -33089,8 +33132,9 @@ var ts;
33089
33132
  // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
33090
33133
  var originalKeywordKind = token();
33091
33134
  var text = internIdentifier(scanner.getTokenValue());
33135
+ var hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
33092
33136
  nextTokenWithoutCheck();
33093
- return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
33137
+ return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind, hasExtendedUnicodeEscape), pos);
33094
33138
  }
33095
33139
  if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
33096
33140
  parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
@@ -40339,9 +40383,6 @@ var ts;
40339
40383
  name: "listFilesOnly",
40340
40384
  type: "boolean",
40341
40385
  category: ts.Diagnostics.Command_line_Options,
40342
- affectsSemanticDiagnostics: true,
40343
- affectsEmit: true,
40344
- affectsMultiFileEmitBuildInfo: true,
40345
40386
  isCommandLineOnly: true,
40346
40387
  description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
40347
40388
  defaultValueDescription: false,
@@ -42069,12 +42110,14 @@ var ts;
42069
42110
  return config;
42070
42111
  }
42071
42112
  ts.convertToTSConfig = convertToTSConfig;
42113
+ /*@internal*/
42072
42114
  function optionMapToObject(optionMap) {
42073
42115
  return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
42074
42116
  var _a;
42075
42117
  return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
42076
42118
  }, {}));
42077
42119
  }
42120
+ ts.optionMapToObject = optionMapToObject;
42078
42121
  function filterSameAsDefaultInclude(specs) {
42079
42122
  if (!ts.length(specs))
42080
42123
  return undefined;
@@ -42123,9 +42166,11 @@ var ts;
42123
42166
  });
42124
42167
  }
42125
42168
  ts.getNameOfCompilerOptionValue = getNameOfCompilerOptionValue;
42169
+ /* @internal */
42126
42170
  function serializeCompilerOptions(options, pathOptions) {
42127
42171
  return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
42128
42172
  }
42173
+ ts.serializeCompilerOptions = serializeCompilerOptions;
42129
42174
  function serializeWatchOptions(options) {
42130
42175
  return serializeOptionBaseObject(options, getWatchOptionsNameMap());
42131
42176
  }
@@ -42229,12 +42274,23 @@ var ts;
42229
42274
  }
42230
42275
  function writeConfigurations() {
42231
42276
  // Filter applicable options to place in the file
42232
- var categorizedOptions = ts.createMultiMap();
42277
+ var categorizedOptions = new ts.Map();
42278
+ // Set allowed categories in order
42279
+ categorizedOptions.set(ts.Diagnostics.Projects, []);
42280
+ categorizedOptions.set(ts.Diagnostics.Language_and_Environment, []);
42281
+ categorizedOptions.set(ts.Diagnostics.Modules, []);
42282
+ categorizedOptions.set(ts.Diagnostics.JavaScript_Support, []);
42283
+ categorizedOptions.set(ts.Diagnostics.Emit, []);
42284
+ categorizedOptions.set(ts.Diagnostics.Interop_Constraints, []);
42285
+ categorizedOptions.set(ts.Diagnostics.Type_Checking, []);
42286
+ categorizedOptions.set(ts.Diagnostics.Completeness, []);
42233
42287
  for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
42234
42288
  var option = optionDeclarations_1[_i];
42235
- var category = option.category;
42236
42289
  if (isAllowedOptionForOutput(option)) {
42237
- categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
42290
+ var listForCategory = categorizedOptions.get(option.category);
42291
+ if (!listForCategory)
42292
+ categorizedOptions.set(option.category, listForCategory = []);
42293
+ listForCategory.push(option);
42238
42294
  }
42239
42295
  }
42240
42296
  // Serialize all options and their descriptions
@@ -42245,7 +42301,7 @@ var ts;
42245
42301
  if (entries.length !== 0) {
42246
42302
  entries.push({ value: "" });
42247
42303
  }
42248
- entries.push({ value: "/* ".concat(category, " */") });
42304
+ entries.push({ value: "/* ".concat(ts.getLocaleSpecificMessage(category), " */") });
42249
42305
  for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
42250
42306
  var option = options_1[_i];
42251
42307
  var optionName = void 0;
@@ -44287,6 +44343,9 @@ var ts;
44287
44343
  requestContainingDirectory: containingDirectory,
44288
44344
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44289
44345
  };
44346
+ if (traceEnabled && ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) <= ts.ModuleResolutionKind.NodeNext) {
44347
+ trace(host, ts.Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(function (c) { return "'".concat(c, "'"); }).join(", "));
44348
+ }
44290
44349
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
44291
44350
  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);
44292
44351
  function tryResolve(extensions) {
@@ -44876,7 +44935,7 @@ var ts;
44876
44935
  }
44877
44936
  if (mainExport) {
44878
44937
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
44879
- return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
44938
+ return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false, ".");
44880
44939
  }
44881
44940
  }
44882
44941
  else if (allKeysStartWithDot(scope.contents.packageJsonContent.exports)) {
@@ -44956,7 +45015,7 @@ var ts;
44956
45015
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44957
45016
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
44958
45017
  var target = lookupTable[moduleName];
44959
- return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
45018
+ return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
44960
45019
  }
44961
45020
  var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
44962
45021
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
@@ -44965,17 +45024,17 @@ var ts;
44965
45024
  var target = lookupTable[potentialTarget];
44966
45025
  var starPos = potentialTarget.indexOf("*");
44967
45026
  var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
44968
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
45027
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
44969
45028
  }
44970
45029
  else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
44971
45030
  var target = lookupTable[potentialTarget];
44972
45031
  var subpath = moduleName.substring(potentialTarget.length - 1);
44973
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
45032
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
44974
45033
  }
44975
45034
  else if (ts.startsWith(moduleName, potentialTarget)) {
44976
45035
  var target = lookupTable[potentialTarget];
44977
45036
  var subpath = moduleName.substring(potentialTarget.length);
44978
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
45037
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false, potentialTarget);
44979
45038
  }
44980
45039
  }
44981
45040
  function matchesPatternWithTrailer(target, name) {
@@ -44992,7 +45051,7 @@ var ts;
44992
45051
  */
44993
45052
  function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
44994
45053
  return loadModuleFromTargetImportOrExport;
44995
- function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
45054
+ function loadModuleFromTargetImportOrExport(target, subpath, pattern, key) {
44996
45055
  if (typeof target === "string") {
44997
45056
  if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
44998
45057
  if (state.traceEnabled) {
@@ -45003,6 +45062,8 @@ var ts;
45003
45062
  if (!ts.startsWith(target, "./")) {
45004
45063
  if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
45005
45064
  var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
45065
+ traceIfEnabled(state, ts.Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
45066
+ traceIfEnabled(state, ts.Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
45006
45067
  var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
45007
45068
  return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
45008
45069
  }
@@ -45029,6 +45090,9 @@ var ts;
45029
45090
  }
45030
45091
  return toSearchResult(/*value*/ undefined);
45031
45092
  }
45093
+ if (state.traceEnabled) {
45094
+ trace(state.host, ts.Diagnostics.Using_0_subpath_1_with_target_2, isImports ? "imports" : "exports", key, pattern ? target.replace(/\*/g, subpath) : target + subpath);
45095
+ }
45032
45096
  var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
45033
45097
  var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
45034
45098
  if (inputLink)
@@ -45038,14 +45102,18 @@ var ts;
45038
45102
  else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
45039
45103
  if (!Array.isArray(target)) {
45040
45104
  for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
45041
- var key = _a[_i];
45042
- if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
45043
- var subTarget = target[key];
45044
- var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
45105
+ var condition = _a[_i];
45106
+ if (condition === "default" || state.conditions.indexOf(condition) >= 0 || isApplicableVersionedTypesKey(state.conditions, condition)) {
45107
+ traceIfEnabled(state, ts.Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
45108
+ var subTarget = target[condition];
45109
+ var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern, key);
45045
45110
  if (result) {
45046
45111
  return result;
45047
45112
  }
45048
45113
  }
45114
+ else {
45115
+ traceIfEnabled(state, ts.Diagnostics.Saw_non_matching_condition_0, condition);
45116
+ }
45049
45117
  }
45050
45118
  return undefined;
45051
45119
  }
@@ -45058,7 +45126,7 @@ var ts;
45058
45126
  }
45059
45127
  for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
45060
45128
  var elem = target_2[_b];
45061
- var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
45129
+ var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern, key);
45062
45130
  if (result) {
45063
45131
  return result;
45064
45132
  }
@@ -45474,6 +45542,15 @@ var ts;
45474
45542
  function toSearchResult(value) {
45475
45543
  return value !== undefined ? { value: value } : undefined;
45476
45544
  }
45545
+ function traceIfEnabled(state, diagnostic) {
45546
+ var args = [];
45547
+ for (var _i = 2; _i < arguments.length; _i++) {
45548
+ args[_i - 2] = arguments[_i];
45549
+ }
45550
+ if (state.traceEnabled) {
45551
+ trace.apply(void 0, __spreadArray([state.host, diagnostic], args, false));
45552
+ }
45553
+ }
45477
45554
  })(ts || (ts = {}));
45478
45555
  /* @internal */
45479
45556
  var ts;
@@ -49065,8 +49142,6 @@ var ts;
49065
49142
  IntersectionState[IntersectionState["None"] = 0] = "None";
49066
49143
  IntersectionState[IntersectionState["Source"] = 1] = "Source";
49067
49144
  IntersectionState[IntersectionState["Target"] = 2] = "Target";
49068
- IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
49069
- IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
49070
49145
  })(IntersectionState || (IntersectionState = {}));
49071
49146
  var RecursionFlags;
49072
49147
  (function (RecursionFlags) {
@@ -49485,6 +49560,12 @@ var ts;
49485
49560
  getOptionalType: function () { return optionalType; },
49486
49561
  getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
49487
49562
  getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
49563
+ getAsyncIterableType: function () {
49564
+ var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
49565
+ if (type === emptyGenericType)
49566
+ return undefined;
49567
+ return type;
49568
+ },
49488
49569
  isSymbolAccessible: isSymbolAccessible,
49489
49570
  isArrayType: isArrayType,
49490
49571
  isTupleType: isTupleType,
@@ -50322,9 +50403,9 @@ var ts;
50322
50403
  return symbol;
50323
50404
  }
50324
50405
  if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
50325
- var target = resolveAlias(symbol);
50326
- // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors
50327
- if (target === unknownSymbol || target.flags & meaning) {
50406
+ var targetFlags = getAllSymbolFlags(symbol);
50407
+ // `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
50408
+ if (targetFlags & meaning) {
50328
50409
  return symbol;
50329
50410
  }
50330
50411
  }
@@ -50957,8 +51038,8 @@ var ts;
50957
51038
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50958
51039
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50959
51040
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
51041
+ !checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
50960
51042
  !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
50961
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50962
51043
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50963
51044
  var suggestion = void 0;
50964
51045
  var suggestedLib = void 0;
@@ -51045,7 +51126,7 @@ var ts;
51045
51126
  }
51046
51127
  }
51047
51128
  if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
51048
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
51129
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
51049
51130
  if (typeOnlyDeclaration) {
51050
51131
  var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
51051
51132
  ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
@@ -51208,7 +51289,7 @@ var ts;
51208
51289
  return false;
51209
51290
  }
51210
51291
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
51211
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) {
51292
+ if (meaning & 111551 /* SymbolFlags.Value */) {
51212
51293
  if (isPrimitiveTypeName(name)) {
51213
51294
  if (isExtendedByInterface(errorLocation)) {
51214
51295
  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));
@@ -51219,7 +51300,8 @@ var ts;
51219
51300
  return true;
51220
51301
  }
51221
51302
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51222
- if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) {
51303
+ var allFlags = symbol && getAllSymbolFlags(symbol);
51304
+ if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
51223
51305
  var rawName = ts.unescapeLeadingUnderscores(name);
51224
51306
  if (isES2015OrLaterConstructorName(name)) {
51225
51307
  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);
@@ -51267,16 +51349,16 @@ var ts;
51267
51349
  }
51268
51350
  return false;
51269
51351
  }
51270
- function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
51271
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) {
51272
- var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51352
+ function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
51353
+ if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
51354
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51273
51355
  if (symbol) {
51274
51356
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
51275
51357
  return true;
51276
51358
  }
51277
51359
  }
51278
- else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) {
51279
- var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51360
+ else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
51361
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51280
51362
  if (symbol) {
51281
51363
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
51282
51364
  return true;
@@ -51866,6 +51948,52 @@ var ts;
51866
51948
  }
51867
51949
  return undefined;
51868
51950
  }
51951
+ /**
51952
+ * Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
51953
+ * is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
51954
+ * with another exported symbol, e.g.
51955
+ * ```ts
51956
+ * // a.ts
51957
+ * export const a = 0;
51958
+ * // b.ts
51959
+ * export { a } from "./a";
51960
+ * export type a = number;
51961
+ * // c.ts
51962
+ * import { a } from "./b";
51963
+ * ```
51964
+ * Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
51965
+ * from b.ts, even though there is still more alias to resolve. Consequently, if we were
51966
+ * trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
51967
+ * the local symbol and on the symbol returned by `resolveAlias` is not enough.
51968
+ * @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
51969
+ * combined flags of all alias targets otherwise.
51970
+ */
51971
+ function getAllSymbolFlags(symbol) {
51972
+ var flags = symbol.flags;
51973
+ var seenSymbols;
51974
+ while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
51975
+ var target = resolveAlias(symbol);
51976
+ if (target === unknownSymbol) {
51977
+ return 67108863 /* SymbolFlags.All */;
51978
+ }
51979
+ // Optimizations - try to avoid creating or adding to
51980
+ // `seenSymbols` if possible
51981
+ if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
51982
+ break;
51983
+ }
51984
+ if (target.flags & 2097152 /* SymbolFlags.Alias */) {
51985
+ if (seenSymbols) {
51986
+ seenSymbols.add(target);
51987
+ }
51988
+ else {
51989
+ seenSymbols = new ts.Set([symbol, target]);
51990
+ }
51991
+ }
51992
+ flags |= target.flags;
51993
+ symbol = target;
51994
+ }
51995
+ return flags;
51996
+ }
51869
51997
  /**
51870
51998
  * Marks a symbol as type-only if its declaration is syntactically type-only.
51871
51999
  * If it is not itself marked type-only, but resolves to a type-only alias
@@ -51911,19 +52039,25 @@ var ts;
51911
52039
  return !!aliasDeclarationLinks.typeOnlyDeclaration;
51912
52040
  }
51913
52041
  /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
51914
- function getTypeOnlyAliasDeclaration(symbol) {
52042
+ function getTypeOnlyAliasDeclaration(symbol, include) {
51915
52043
  if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
51916
52044
  return undefined;
51917
52045
  }
51918
52046
  var links = getSymbolLinks(symbol);
51919
- return links.typeOnlyDeclaration || undefined;
52047
+ if (include === undefined) {
52048
+ return links.typeOnlyDeclaration || undefined;
52049
+ }
52050
+ if (links.typeOnlyDeclaration) {
52051
+ return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
52052
+ }
52053
+ return undefined;
51920
52054
  }
51921
52055
  function markExportAsReferenced(node) {
51922
52056
  var symbol = getSymbolOfNode(node);
51923
52057
  var target = resolveAlias(symbol);
51924
52058
  if (target) {
51925
52059
  var markAlias = target === unknownSymbol ||
51926
- ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
52060
+ ((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
51927
52061
  if (markAlias) {
51928
52062
  markAliasSymbolAsReferenced(symbol);
51929
52063
  }
@@ -51943,8 +52077,7 @@ var ts;
51943
52077
  // This way a chain of imports can be elided if ultimately the final input is only used in a type
51944
52078
  // position.
51945
52079
  if (ts.isInternalModuleImportEqualsDeclaration(node)) {
51946
- var target = resolveSymbol(symbol);
51947
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
52080
+ if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
51948
52081
  // import foo = <symbol>
51949
52082
  checkExpressionCached(node.moduleReference);
51950
52083
  }
@@ -52766,7 +52899,7 @@ var ts;
52766
52899
  }
52767
52900
  function symbolIsValue(symbol, includeTypeOnlyMembers) {
52768
52901
  return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
52769
- symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52902
+ symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52770
52903
  }
52771
52904
  function findConstructorDeclaration(node) {
52772
52905
  var members = node.members;
@@ -53035,8 +53168,10 @@ var ts;
53035
53168
  return true;
53036
53169
  }
53037
53170
  // Qualify if the symbol from symbol table has same meaning as expected
53038
- symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53039
- if (symbolFromSymbolTable.flags & meaning) {
53171
+ var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
53172
+ symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53173
+ var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
53174
+ if (flags & meaning) {
53040
53175
  qualify = true;
53041
53176
  return true;
53042
53177
  }
@@ -55348,7 +55483,7 @@ var ts;
55348
55483
  // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
55349
55484
  var indices = ts.indicesOf(statements);
55350
55485
  var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
55351
- if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
55486
+ if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
55352
55487
  for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
55353
55488
  var index_1 = associatedIndices_1[_i];
55354
55489
  statements[index_1] = addExportModifier(statements[index_1]);
@@ -55382,15 +55517,6 @@ var ts;
55382
55517
  }
55383
55518
  return statements;
55384
55519
  }
55385
- function canHaveExportModifier(node) {
55386
- return ts.isEnumDeclaration(node) ||
55387
- ts.isVariableStatement(node) ||
55388
- ts.isFunctionDeclaration(node) ||
55389
- ts.isClassDeclaration(node) ||
55390
- (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
55391
- ts.isInterfaceDeclaration(node) ||
55392
- isTypeDeclaration(node);
55393
- }
55394
55520
  function addExportModifier(node) {
55395
55521
  var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
55396
55522
  return ts.factory.updateModifiers(node, flags);
@@ -55637,7 +55763,7 @@ var ts;
55637
55763
  (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
55638
55764
  if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
55639
55765
  enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
55640
- canHaveExportModifier(node)) {
55766
+ ts.canHaveExportModifier(node)) {
55641
55767
  // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
55642
55768
  newModifierFlags |= 1 /* ModifierFlags.Export */;
55643
55769
  }
@@ -55693,7 +55819,7 @@ var ts;
55693
55819
  return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
55694
55820
  }
55695
55821
  function isTypeOnlyNamespace(symbol) {
55696
- return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); });
55822
+ return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
55697
55823
  }
55698
55824
  function serializeModule(symbol, symbolName, modifierFlags) {
55699
55825
  var members = getNamespaceMembersForSerialization(symbol);
@@ -57607,16 +57733,32 @@ var ts;
57607
57733
  return getTypeFromTypeNode(typeNode);
57608
57734
  }
57609
57735
  }
57736
+ function isParameterOfContextSensitiveSignature(symbol) {
57737
+ var decl = symbol.valueDeclaration;
57738
+ if (!decl) {
57739
+ return false;
57740
+ }
57741
+ if (ts.isBindingElement(decl)) {
57742
+ decl = ts.walkUpBindingElementsAndPatterns(decl);
57743
+ }
57744
+ if (ts.isParameter(decl)) {
57745
+ return isContextSensitiveFunctionOrObjectLiteralMethod(decl.parent);
57746
+ }
57747
+ return false;
57748
+ }
57610
57749
  function getTypeOfVariableOrParameterOrProperty(symbol) {
57611
57750
  var links = getSymbolLinks(symbol);
57612
57751
  if (!links.type) {
57613
57752
  var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
57614
57753
  // For a contextually typed parameter it is possible that a type has already
57615
57754
  // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
57616
- // to preserve this type.
57617
- if (!links.type) {
57755
+ // to preserve this type. In fact, we need to _prefer_ that type, but it won't
57756
+ // be assigned until contextual typing is complete, so we need to defer in
57757
+ // cases where contextual typing may take place.
57758
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
57618
57759
  links.type = type;
57619
57760
  }
57761
+ return type;
57620
57762
  }
57621
57763
  return links.type;
57622
57764
  }
@@ -57913,7 +58055,7 @@ var ts;
57913
58055
  links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
57914
58056
  : isDuplicatedCommonJSExport(symbol.declarations) ? autoType
57915
58057
  : declaredType ? declaredType
57916
- : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
58058
+ : getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
57917
58059
  : errorType;
57918
58060
  }
57919
58061
  return links.type;
@@ -59796,7 +59938,20 @@ var ts;
59796
59938
  return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
59797
59939
  }
59798
59940
  function isGenericMappedType(type) {
59799
- return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type));
59941
+ if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
59942
+ var constraint = getConstraintTypeFromMappedType(type);
59943
+ if (isGenericIndexType(constraint)) {
59944
+ return true;
59945
+ }
59946
+ // A mapped type is generic if the 'as' clause references generic types other than the iteration type.
59947
+ // To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
59948
+ // type and check whether the resulting type is generic.
59949
+ var nameType = getNameTypeFromMappedType(type);
59950
+ if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
59951
+ return true;
59952
+ }
59953
+ }
59954
+ return false;
59800
59955
  }
59801
59956
  function resolveStructuredTypeMembers(type) {
59802
59957
  if (!type.members) {
@@ -60266,7 +60421,7 @@ var ts;
60266
60421
  var indexTypes;
60267
60422
  var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
60268
60423
  // Flags we want to propagate to the result if they exist in all source symbols
60269
- var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */;
60424
+ var optionalFlag;
60270
60425
  var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
60271
60426
  var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
60272
60427
  var mergedInstantiations = false;
@@ -60277,11 +60432,14 @@ var ts;
60277
60432
  var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
60278
60433
  var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
60279
60434
  if (prop) {
60280
- if (isUnion) {
60281
- optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60282
- }
60283
- else {
60284
- optionalFlag &= prop.flags;
60435
+ if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
60436
+ optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
60437
+ if (isUnion) {
60438
+ optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60439
+ }
60440
+ else {
60441
+ optionalFlag &= prop.flags;
60442
+ }
60285
60443
  }
60286
60444
  if (!singleProp) {
60287
60445
  singleProp = prop;
@@ -60400,7 +60558,7 @@ var ts;
60400
60558
  propTypes.push(type);
60401
60559
  }
60402
60560
  ts.addRange(propTypes, indexTypes);
60403
- var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
60561
+ var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
60404
60562
  result.containingType = containingType;
60405
60563
  if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
60406
60564
  result.valueDeclaration = firstValueDeclaration;
@@ -63113,8 +63271,14 @@ var ts;
63113
63271
  return getStringLiteralType(text);
63114
63272
  }
63115
63273
  newTexts.push(text);
63116
- if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63117
- return stringType;
63274
+ if (ts.every(newTexts, function (t) { return t === ""; })) {
63275
+ if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63276
+ return stringType;
63277
+ }
63278
+ // Normalize `${Mapping<xxx>}` into Mapping<xxx>
63279
+ if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
63280
+ return newTypes[0];
63281
+ }
63118
63282
  }
63119
63283
  var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
63120
63284
  var type = templateLiteralTypes.get(id);
@@ -63173,12 +63337,14 @@ var ts;
63173
63337
  }
63174
63338
  function getStringMappingType(symbol, type) {
63175
63339
  return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
63176
- // Mapping<Mapping<T>> === Mapping<T>
63177
- type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63178
- isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
63179
- type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63180
- type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63181
- type;
63340
+ type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63341
+ type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63342
+ // Mapping<Mapping<T>> === Mapping<T>
63343
+ type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63344
+ type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
63345
+ // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
63346
+ isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
63347
+ type;
63182
63348
  }
63183
63349
  function applyStringMapping(symbol, str) {
63184
63350
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -63343,7 +63509,18 @@ var ts;
63343
63509
  return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63344
63510
  }
63345
63511
  errorIfWritingToReadonlyIndex(indexInfo);
63346
- return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63512
+ // When accessing an enum object with its own type,
63513
+ // e.g. E[E.A] for enum E { A }, undefined shouldn't
63514
+ // be included in the result type
63515
+ if ((accessFlags & 1 /* AccessFlags.IncludeUndefined */) &&
63516
+ !(objectType.symbol &&
63517
+ objectType.symbol.flags & (256 /* SymbolFlags.RegularEnum */ | 128 /* SymbolFlags.ConstEnum */) &&
63518
+ (indexType.symbol &&
63519
+ indexType.flags & 1024 /* TypeFlags.EnumLiteral */ &&
63520
+ getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
63521
+ return getUnionType([indexInfo.type, undefinedType]);
63522
+ }
63523
+ return indexInfo.type;
63347
63524
  }
63348
63525
  if (indexType.flags & 131072 /* TypeFlags.Never */) {
63349
63526
  return neverType;
@@ -63446,10 +63623,11 @@ var ts;
63446
63623
  accessNode;
63447
63624
  }
63448
63625
  function isPatternLiteralPlaceholderType(type) {
63449
- return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type));
63626
+ return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
63450
63627
  }
63451
63628
  function isPatternLiteralType(type) {
63452
- return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
63629
+ return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
63630
+ !!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
63453
63631
  }
63454
63632
  function isGenericType(type) {
63455
63633
  return !!getGenericObjectFlags(type);
@@ -63728,18 +63906,23 @@ var ts;
63728
63906
  var result;
63729
63907
  var extraTypes;
63730
63908
  var tailCount = 0;
63731
- var _loop_20 = function () {
63909
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
63910
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
63911
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
63912
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63913
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
63914
+ while (true) {
63732
63915
  if (tailCount === 1000) {
63733
63916
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
63734
63917
  result = errorType;
63735
- return "break";
63918
+ break;
63736
63919
  }
63737
63920
  var isUnwrapped = isTypicalNondistributiveConditional(root);
63738
63921
  var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
63739
63922
  var checkTypeInstantiable = isGenericType(checkType);
63740
63923
  var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
63741
63924
  if (checkType === wildcardType || extendsType === wildcardType) {
63742
- return { value: wildcardType };
63925
+ return wildcardType;
63743
63926
  }
63744
63927
  var combinedMapper = void 0;
63745
63928
  if (root.inferTypeParameters) {
@@ -63772,11 +63955,7 @@ var ts;
63772
63955
  }
63773
63956
  }
63774
63957
  }
63775
- // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
63776
- // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
63777
- // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
63778
- // so in those cases we refain from performing inference and retain the uninfered type parameter
63779
- if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
63958
+ if (!checkTypeInstantiable) {
63780
63959
  // We don't want inferences from constraints as they may cause us to eagerly resolve the
63781
63960
  // conditional type instead of deferring resolution. Also, we always want strict function
63782
63961
  // types rules (i.e. proper contravariance) for inferences.
@@ -63808,14 +63987,14 @@ var ts;
63808
63987
  var newRoot = falseType_1.root;
63809
63988
  if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
63810
63989
  root = newRoot;
63811
- return "continue";
63990
+ continue;
63812
63991
  }
63813
63992
  if (canTailRecurse(falseType_1, mapper)) {
63814
- return "continue";
63993
+ continue;
63815
63994
  }
63816
63995
  }
63817
63996
  result = instantiateType(falseType_1, mapper);
63818
- return "break";
63997
+ break;
63819
63998
  }
63820
63999
  // Return trueType for a definitely true extends check. We check instantiations of the two
63821
64000
  // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
@@ -63826,10 +64005,10 @@ var ts;
63826
64005
  var trueType_1 = getTypeFromTypeNode(root.node.trueType);
63827
64006
  var trueMapper = combinedMapper || mapper;
63828
64007
  if (canTailRecurse(trueType_1, trueMapper)) {
63829
- return "continue";
64008
+ continue;
63830
64009
  }
63831
64010
  result = instantiateType(trueType_1, trueMapper);
63832
- return "break";
64011
+ break;
63833
64012
  }
63834
64013
  }
63835
64014
  // Return a deferred type for a check that is neither definitely true nor definitely false
@@ -63841,19 +64020,7 @@ var ts;
63841
64020
  result.combinedMapper = combinedMapper;
63842
64021
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
63843
64022
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
63844
- return "break";
63845
- };
63846
- // We loop here for an immediately nested conditional type in the false position, effectively treating
63847
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
63848
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
63849
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63850
- // cases we increment the tail recursion counter and stop after 1000 iterations.
63851
- while (true) {
63852
- var state_6 = _loop_20();
63853
- if (typeof state_6 === "object")
63854
- return state_6.value;
63855
- if (state_6 === "break")
63856
- break;
64023
+ break;
63857
64024
  }
63858
64025
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
63859
64026
  // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -66307,7 +66474,7 @@ var ts;
66307
66474
  return 0 /* Ternary.False */;
66308
66475
  }
66309
66476
  }
66310
- var isPerformingCommonPropertyChecks = (relation !== comparableRelation || !(source.flags & 1048576 /* TypeFlags.Union */) && isLiteralType(source)) &&
66477
+ var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
66311
66478
  !(intersectionState & 2 /* IntersectionState.Target */) &&
66312
66479
  source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
66313
66480
  target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
@@ -66335,27 +66502,6 @@ var ts;
66335
66502
  var result_7 = skipCaching ?
66336
66503
  unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
66337
66504
  recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
66338
- // For certain combinations involving intersections and optional, excess, or mismatched properties we need
66339
- // an extra property check where the intersection is viewed as a single object. The following are motivating
66340
- // examples that all should be errors, but aren't without this extra property check:
66341
- //
66342
- // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
66343
- //
66344
- // declare let wrong: { a: { y: string } };
66345
- // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
66346
- //
66347
- // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
66348
- // x = y; // Mismatched property in source intersection
66349
- // }
66350
- //
66351
- // We suppress recursive intersection property checks because they can generate lots of work when relating
66352
- // recursive intersections that are structurally similar but not exactly identical. See #37854.
66353
- if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
66354
- 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 */); }))) {
66355
- inPropertyCheck = true;
66356
- result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
66357
- inPropertyCheck = false;
66358
- }
66359
66505
  if (result_7) {
66360
66506
  return result_7;
66361
66507
  }
@@ -66467,7 +66613,7 @@ var ts;
66467
66613
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
66468
66614
  checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
66469
66615
  }
66470
- var _loop_21 = function (prop) {
66616
+ var _loop_20 = function (prop) {
66471
66617
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
66472
66618
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
66473
66619
  if (reportErrors) {
@@ -66530,9 +66676,9 @@ var ts;
66530
66676
  };
66531
66677
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
66532
66678
  var prop = _b[_i];
66533
- var state_7 = _loop_21(prop);
66534
- if (typeof state_7 === "object")
66535
- return state_7.value;
66679
+ var state_6 = _loop_20(prop);
66680
+ if (typeof state_6 === "object")
66681
+ return state_6.value;
66536
66682
  }
66537
66683
  return false;
66538
66684
  }
@@ -66753,8 +66899,7 @@ var ts;
66753
66899
  if (overflow) {
66754
66900
  return 0 /* Ternary.False */;
66755
66901
  }
66756
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0);
66757
- var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
66902
+ var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
66758
66903
  var entry = relation.get(id);
66759
66904
  if (entry !== undefined) {
66760
66905
  if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
@@ -66784,7 +66929,7 @@ var ts;
66784
66929
  // A key that starts with "*" is an indication that we have type references that reference constrained
66785
66930
  // type parameters. For such keys we also check against the key we would have gotten if all type parameters
66786
66931
  // were unconstrained.
66787
- var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
66932
+ var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
66788
66933
  for (var i = 0; i < maybeCount; i++) {
66789
66934
  // If source and target are already being compared, consider them related with assumptions
66790
66935
  if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
@@ -66871,7 +67016,7 @@ var ts;
66871
67016
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
66872
67017
  var saveErrorInfo = captureErrorCalculationState();
66873
67018
  var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
66874
- if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
67019
+ if (relation !== identityRelation) {
66875
67020
  // The combined constraint of an intersection type is the intersection of the constraints of
66876
67021
  // the constituents. When an intersection type contains instantiable types with union type
66877
67022
  // constraints, there are situations where we need to examine the combined constraint. One is
@@ -66885,10 +67030,33 @@ var ts;
66885
67030
  // needs to have its constraint hoisted into an intersection with said type parameter, this way
66886
67031
  // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
66887
67032
  // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
66888
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
66889
- if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66890
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66891
- result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
67033
+ if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
67034
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
67035
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
67036
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
67037
+ result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
67038
+ }
67039
+ }
67040
+ // For certain combinations involving intersections and optional, excess, or mismatched properties we need
67041
+ // an extra property check where the intersection is viewed as a single object. The following are motivating
67042
+ // examples that all should be errors, but aren't without this extra property check:
67043
+ //
67044
+ // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
67045
+ //
67046
+ // declare let wrong: { a: { y: string } };
67047
+ // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
67048
+ //
67049
+ // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
67050
+ // x = y; // Mismatched property in source intersection
67051
+ // }
67052
+ //
67053
+ // We suppress recursive intersection property checks because they can generate lots of work when relating
67054
+ // recursive intersections that are structurally similar but not exactly identical. See #37854.
67055
+ if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
67056
+ 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 */); }))) {
67057
+ inPropertyCheck = true;
67058
+ result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
67059
+ inPropertyCheck = false;
66892
67060
  }
66893
67061
  }
66894
67062
  if (result) {
@@ -66897,9 +67065,6 @@ var ts;
66897
67065
  return result;
66898
67066
  }
66899
67067
  function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
66900
- if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
66901
- return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
66902
- }
66903
67068
  var result;
66904
67069
  var originalErrorInfo;
66905
67070
  var varianceCheckFailed = false;
@@ -67000,7 +67165,7 @@ var ts;
67000
67165
  // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
67001
67166
  var constraint = getConstraintOfTypeParameter(source);
67002
67167
  if (constraint && hasNonCircularBaseConstraint(source)) {
67003
- while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
67168
+ while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
67004
67169
  if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
67005
67170
  return result;
67006
67171
  }
@@ -67523,11 +67688,11 @@ var ts;
67523
67688
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
67524
67689
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
67525
67690
  var matchingTypes = [];
67526
- var _loop_22 = function (combination) {
67691
+ var _loop_21 = function (combination) {
67527
67692
  var hasMatch = false;
67528
67693
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
67529
67694
  var type = _d[_c];
67530
- var _loop_23 = function (i) {
67695
+ var _loop_22 = function (i) {
67531
67696
  var sourceProperty = sourcePropertiesFiltered[i];
67532
67697
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
67533
67698
  if (!targetProperty)
@@ -67543,8 +67708,8 @@ var ts;
67543
67708
  }
67544
67709
  };
67545
67710
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
67546
- var state_9 = _loop_23(i);
67547
- switch (state_9) {
67711
+ var state_8 = _loop_22(i);
67712
+ switch (state_8) {
67548
67713
  case "continue-outer": continue outer;
67549
67714
  }
67550
67715
  }
@@ -67557,9 +67722,9 @@ var ts;
67557
67722
  };
67558
67723
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
67559
67724
  var combination = discriminantCombinations_1[_a];
67560
- var state_8 = _loop_22(combination);
67561
- if (typeof state_8 === "object")
67562
- return state_8.value;
67725
+ var state_7 = _loop_21(combination);
67726
+ if (typeof state_7 === "object")
67727
+ return state_7.value;
67563
67728
  }
67564
67729
  // Compare the remaining non-discriminant properties of each match.
67565
67730
  var result = -1 /* Ternary.True */;
@@ -67656,7 +67821,7 @@ var ts;
67656
67821
  return 0 /* Ternary.False */;
67657
67822
  }
67658
67823
  // When checking for comparability, be more lenient with optional properties.
67659
- if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67824
+ if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67660
67825
  // TypeScript 1.0 spec (April 2014): 3.8.3
67661
67826
  // S is a subtype of a type T, and T is a supertype of S if ...
67662
67827
  // S' and T are object types and, for each member M in T..
@@ -68264,7 +68429,7 @@ var ts;
68264
68429
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
68265
68430
  links.variances = ts.emptyArray;
68266
68431
  var variances = [];
68267
- var _loop_24 = function (tp) {
68432
+ var _loop_23 = function (tp) {
68268
68433
  var modifiers = getVarianceModifiers(tp);
68269
68434
  var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
68270
68435
  modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
@@ -68302,7 +68467,7 @@ var ts;
68302
68467
  };
68303
68468
  for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
68304
68469
  var tp = typeParameters_2[_i];
68305
- _loop_24(tp);
68470
+ _loop_23(tp);
68306
68471
  }
68307
68472
  links.variances = variances;
68308
68473
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
@@ -68756,8 +68921,7 @@ var ts;
68756
68921
  return !!(type.flags & 109440 /* TypeFlags.Unit */);
68757
68922
  }
68758
68923
  function isUnitLikeType(type) {
68759
- return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) :
68760
- !!(type.flags & 109440 /* TypeFlags.Unit */);
68924
+ return isUnitType(getBaseConstraintOrType(type));
68761
68925
  }
68762
68926
  function extractUnitType(type) {
68763
68927
  return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type;
@@ -69636,7 +69800,7 @@ var ts;
69636
69800
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
69637
69801
  }
69638
69802
  function isMemberOfStringMapping(source, target) {
69639
- if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) {
69803
+ if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
69640
69804
  return true;
69641
69805
  }
69642
69806
  if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
@@ -70260,7 +70424,7 @@ var ts;
70260
70424
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
70261
70425
  // succeed. That would be a pointless and confusing outcome.
70262
70426
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
70263
- var _loop_25 = function (i) {
70427
+ var _loop_24 = function (i) {
70264
70428
  var source_1 = matches ? matches[i] : neverType;
70265
70429
  var target_3 = types[i];
70266
70430
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -70310,7 +70474,7 @@ var ts;
70310
70474
  inferFromTypes(source_1, target_3);
70311
70475
  };
70312
70476
  for (var i = 0; i < types.length; i++) {
70313
- _loop_25(i);
70477
+ _loop_24(i);
70314
70478
  }
70315
70479
  }
70316
70480
  }
@@ -70762,7 +70926,7 @@ var ts;
70762
70926
  }
70763
70927
  if (ts.isEntityNameExpression(node.argumentExpression)) {
70764
70928
  var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
70765
- if (!symbol || !isConstVariable(symbol))
70929
+ if (!symbol || !(isConstVariable(symbol) || (symbol.flags & 8 /* SymbolFlags.EnumMember */)))
70766
70930
  return undefined;
70767
70931
  var declaration = symbol.valueDeclaration;
70768
70932
  if (declaration === undefined)
@@ -70776,7 +70940,12 @@ var ts;
70776
70940
  }
70777
70941
  if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70778
70942
  var initializer = ts.getEffectiveInitializer(declaration);
70779
- return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70943
+ if (initializer) {
70944
+ return tryGetNameFromType(getTypeOfExpression(initializer));
70945
+ }
70946
+ if (ts.isEnumMember(declaration)) {
70947
+ return ts.getTextOfPropertyName(declaration.name);
70948
+ }
70780
70949
  }
70781
70950
  }
70782
70951
  return undefined;
@@ -70834,7 +71003,7 @@ var ts;
70834
71003
  function mapTypesByKeyProperty(types, name) {
70835
71004
  var map = new ts.Map();
70836
71005
  var count = 0;
70837
- var _loop_26 = function (type) {
71006
+ var _loop_25 = function (type) {
70838
71007
  if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
70839
71008
  var discriminant = getTypeOfPropertyOfType(type, name);
70840
71009
  if (discriminant) {
@@ -70860,9 +71029,9 @@ var ts;
70860
71029
  };
70861
71030
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70862
71031
  var type = types_15[_i];
70863
- var state_10 = _loop_26(type);
70864
- if (typeof state_10 === "object")
70865
- return state_10.value;
71032
+ var state_9 = _loop_25(type);
71033
+ if (typeof state_9 === "object")
71034
+ return state_9.value;
70866
71035
  }
70867
71036
  return count >= 10 && count * 2 >= types.length ? map : undefined;
70868
71037
  }
@@ -71459,6 +71628,7 @@ var ts;
71459
71628
  ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
71460
71629
  }
71461
71630
  function getExplicitTypeOfSymbol(symbol, diagnostic) {
71631
+ symbol = resolveSymbol(symbol);
71462
71632
  if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) {
71463
71633
  return getTypeOfSymbol(symbol);
71464
71634
  }
@@ -71497,7 +71667,7 @@ var ts;
71497
71667
  switch (node.kind) {
71498
71668
  case 79 /* SyntaxKind.Identifier */:
71499
71669
  var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
71500
- return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic);
71670
+ return getExplicitTypeOfSymbol(symbol, diagnostic);
71501
71671
  case 108 /* SyntaxKind.ThisKeyword */:
71502
71672
  return getExplicitThisType(node);
71503
71673
  case 106 /* SyntaxKind.SuperKeyword */:
@@ -71984,7 +72154,7 @@ var ts;
71984
72154
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71985
72155
  }
71986
72156
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
71987
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72157
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71988
72158
  }
71989
72159
  else {
71990
72160
  if (strictNullChecks) {
@@ -72265,7 +72435,7 @@ var ts;
72265
72435
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72266
72436
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72267
72437
  }
72268
- function narrowByInKeyword(type, nameType, assumeTrue) {
72438
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72269
72439
  var name = getPropertyNameFromType(nameType);
72270
72440
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72271
72441
  if (isKnownProperty) {
@@ -72346,7 +72516,7 @@ var ts;
72346
72516
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72347
72517
  }
72348
72518
  if (isMatchingReference(reference, target)) {
72349
- return narrowByInKeyword(type, leftType, assumeTrue);
72519
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72350
72520
  }
72351
72521
  }
72352
72522
  break;
@@ -72535,7 +72705,7 @@ var ts;
72535
72705
  neverType;
72536
72706
  });
72537
72707
  }
72538
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72708
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72539
72709
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72540
72710
  if (!witnesses) {
72541
72711
  return type;
@@ -72923,15 +73093,15 @@ var ts;
72923
73093
  });
72924
73094
  }
72925
73095
  function markAliasReferenced(symbol, location) {
72926
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
73096
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
72927
73097
  var target = resolveAlias(symbol);
72928
- if (target.flags & 111551 /* SymbolFlags.Value */) {
73098
+ if (getAllSymbolFlags(target) & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */)) {
72929
73099
  // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
72930
73100
  // (because the const enum value will not be inlined), or if (2) the alias is an export
72931
73101
  // of a const enum declaration that will be preserved.
72932
73102
  if (compilerOptions.isolatedModules ||
72933
73103
  ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) ||
72934
- !isConstEnumOrConstEnumOnlyModule(target)) {
73104
+ !isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
72935
73105
  markAliasSymbolAsReferenced(symbol);
72936
73106
  }
72937
73107
  else {
@@ -73159,7 +73329,7 @@ var ts;
73159
73329
  // We only look for uninitialized variables in strict null checking mode, and only when we can analyze
73160
73330
  // the entire control flow graph from the variable's declaration (i.e. when the flow container and
73161
73331
  // declaration container are the same).
73162
- var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
73332
+ var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
73163
73333
  type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 ||
73164
73334
  isInTypeQuery(node) || node.parent.kind === 278 /* SyntaxKind.ExportSpecifier */) ||
73165
73335
  node.parent.kind === 232 /* SyntaxKind.NonNullExpression */ ||
@@ -73188,6 +73358,12 @@ var ts;
73188
73358
  }
73189
73359
  return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
73190
73360
  }
73361
+ function isSameScopedBindingElement(node, declaration) {
73362
+ if (ts.isBindingElement(declaration)) {
73363
+ var bindingElement = ts.findAncestor(node, ts.isBindingElement);
73364
+ return bindingElement && ts.getRootDeclaration(bindingElement) === ts.getRootDeclaration(declaration);
73365
+ }
73366
+ }
73191
73367
  function shouldMarkIdentifierAliasReferenced(node) {
73192
73368
  var _a;
73193
73369
  var parent = node.parent;
@@ -73529,12 +73705,17 @@ var ts;
73529
73705
  var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
73530
73706
  var container = immediateContainer;
73531
73707
  var needToCaptureLexicalThis = false;
73708
+ var inAsyncFunction = false;
73532
73709
  // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
73533
73710
  if (!isCallExpression) {
73534
73711
  while (container && container.kind === 216 /* SyntaxKind.ArrowFunction */) {
73712
+ if (ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73713
+ inAsyncFunction = true;
73535
73714
  container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
73536
73715
  needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
73537
73716
  }
73717
+ if (container && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73718
+ inAsyncFunction = true;
73538
73719
  }
73539
73720
  var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
73540
73721
  var nodeCheckFlag = 0;
@@ -73640,12 +73821,12 @@ var ts;
73640
73821
  // as a call expression cannot be used as the target of a destructuring assignment while a property access can.
73641
73822
  //
73642
73823
  // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
73643
- if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */)) {
73824
+ if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && inAsyncFunction) {
73644
73825
  if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
73645
- getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */;
73826
+ getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */;
73646
73827
  }
73647
73828
  else {
73648
- getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */;
73829
+ getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */;
73649
73830
  }
73650
73831
  }
73651
73832
  if (needToCaptureLexicalThis) {
@@ -74341,9 +74522,10 @@ var ts;
74341
74522
  function instantiateContextualType(contextualType, node, contextFlags) {
74342
74523
  if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
74343
74524
  var inferenceContext = getInferenceContext(node);
74344
- // If no inferences have been made, nothing is gained from instantiating as type parameters
74345
- // would just be replaced with their defaults similar to the apparent type.
74346
- if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
74525
+ // If no inferences have been made, and none of the type parameters for which we are inferring
74526
+ // specify default types, nothing is gained from instantiating as type parameters would just be
74527
+ // replaced with their constraints similar to the apparent type.
74528
+ if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
74347
74529
  // For contextual signatures we incorporate all inferences made so far, e.g. from return
74348
74530
  // types as well as arguments to the left in a function call.
74349
74531
  return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
@@ -77317,7 +77499,7 @@ var ts;
77317
77499
  if (spreadIndex >= 0) {
77318
77500
  // Create synthetic arguments from spreads of tuple types.
77319
77501
  var effectiveArgs_1 = args.slice(0, spreadIndex);
77320
- var _loop_27 = function (i) {
77502
+ var _loop_26 = function (i) {
77321
77503
  var arg = args[i];
77322
77504
  // We can call checkExpressionCached because spread expressions never have a contextual type.
77323
77505
  var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -77334,7 +77516,7 @@ var ts;
77334
77516
  }
77335
77517
  };
77336
77518
  for (var i = spreadIndex; i < args.length; i++) {
77337
- _loop_27(i);
77519
+ _loop_26(i);
77338
77520
  }
77339
77521
  return effectiveArgs_1;
77340
77522
  }
@@ -77663,7 +77845,7 @@ var ts;
77663
77845
  var min_3 = Number.MAX_VALUE;
77664
77846
  var minIndex = 0;
77665
77847
  var i_1 = 0;
77666
- var _loop_28 = function (c) {
77848
+ var _loop_27 = function (c) {
77667
77849
  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)); };
77668
77850
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
77669
77851
  if (diags_2) {
@@ -77681,7 +77863,7 @@ var ts;
77681
77863
  };
77682
77864
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
77683
77865
  var c = candidatesForArgumentError_1[_a];
77684
- _loop_28(c);
77866
+ _loop_27(c);
77685
77867
  }
77686
77868
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
77687
77869
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -77839,7 +78021,7 @@ var ts;
77839
78021
  }
77840
78022
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
77841
78023
  var parameters = [];
77842
- var _loop_29 = function (i) {
78024
+ var _loop_28 = function (i) {
77843
78025
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
77844
78026
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
77845
78027
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -77847,7 +78029,7 @@ var ts;
77847
78029
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
77848
78030
  };
77849
78031
  for (var i = 0; i < maxNonRestParam; i++) {
77850
- _loop_29(i);
78032
+ _loop_28(i);
77851
78033
  }
77852
78034
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
77853
78035
  var flags = 0 /* SignatureFlags.None */;
@@ -78817,7 +78999,7 @@ var ts;
78817
78999
  if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
78818
79000
  symbol = resolveAlias(symbol);
78819
79001
  }
78820
- return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
79002
+ return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78821
79003
  }
78822
79004
  return false;
78823
79005
  }
@@ -79479,7 +79661,17 @@ var ts;
79479
79661
  }
79480
79662
  function isExhaustiveSwitchStatement(node) {
79481
79663
  var links = getNodeLinks(node);
79482
- return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
79664
+ if (links.isExhaustive === undefined) {
79665
+ links.isExhaustive = 0; // Indicate resolution is in process
79666
+ var exhaustive = computeExhaustiveSwitchStatement(node);
79667
+ if (links.isExhaustive === 0) {
79668
+ links.isExhaustive = exhaustive;
79669
+ }
79670
+ }
79671
+ else if (links.isExhaustive === 0) {
79672
+ links.isExhaustive = false; // Resolve circularity to false
79673
+ }
79674
+ return links.isExhaustive;
79483
79675
  }
79484
79676
  function computeExhaustiveSwitchStatement(node) {
79485
79677
  if (node.expression.kind === 218 /* SyntaxKind.TypeOfExpression */) {
@@ -79487,7 +79679,7 @@ var ts;
79487
79679
  if (!witnesses) {
79488
79680
  return false;
79489
79681
  }
79490
- var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression));
79682
+ var operandConstraint = getBaseConstraintOrType(checkExpressionCached(node.expression.expression));
79491
79683
  // Get the not-equal flags for all handled cases.
79492
79684
  var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
79493
79685
  if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) {
@@ -79497,7 +79689,7 @@ var ts;
79497
79689
  // A missing not-equal flag indicates that the type wasn't handled by some case.
79498
79690
  return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
79499
79691
  }
79500
- var type = getTypeOfExpression(node.expression);
79692
+ var type = checkExpressionCached(node.expression);
79501
79693
  if (!isLiteralType(type)) {
79502
79694
  return false;
79503
79695
  }
@@ -81191,6 +81383,9 @@ var ts;
81191
81383
  function hasInferenceCandidates(info) {
81192
81384
  return !!(info.candidates || info.contraCandidates);
81193
81385
  }
81386
+ function hasInferenceCandidatesOrDefault(info) {
81387
+ return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
81388
+ }
81194
81389
  function hasOverlappingInferences(a, b) {
81195
81390
  for (var i = 0; i < a.length; i++) {
81196
81391
  if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
@@ -81892,7 +82087,7 @@ var ts;
81892
82087
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
81893
82088
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
81894
82089
  var indexSignatureMap_1 = new ts.Map();
81895
- var _loop_30 = function (declaration) {
82090
+ var _loop_29 = function (declaration) {
81896
82091
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
81897
82092
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
81898
82093
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -81907,7 +82102,7 @@ var ts;
81907
82102
  };
81908
82103
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
81909
82104
  var declaration = _a[_i];
81910
- _loop_30(declaration);
82105
+ _loop_29(declaration);
81911
82106
  }
81912
82107
  indexSignatureMap_1.forEach(function (entry) {
81913
82108
  if (entry.declarations.length > 1) {
@@ -82184,7 +82379,7 @@ var ts;
82184
82379
  }
82185
82380
  var symbol = getNodeLinks(node).resolvedSymbol;
82186
82381
  if (symbol) {
82187
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
82382
+ if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
82188
82383
  addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
82189
82384
  }
82190
82385
  if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
@@ -82787,7 +82982,7 @@ var ts;
82787
82982
  return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
82788
82983
  }
82789
82984
  // primitives with a `{ then() }` won't be unwrapped/adopted.
82790
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82985
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82791
82986
  return undefined;
82792
82987
  }
82793
82988
  var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
@@ -82854,7 +83049,7 @@ var ts;
82854
83049
  * Determines whether a type is an object with a callable `then` member.
82855
83050
  */
82856
83051
  function isThenableType(type) {
82857
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
83052
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82858
83053
  // primitive types cannot be considered "thenable" since they are not objects.
82859
83054
  return false;
82860
83055
  }
@@ -82888,7 +83083,7 @@ var ts;
82888
83083
  // 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`,
82889
83084
  // or is promise-like.
82890
83085
  if (baseConstraint ?
82891
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83086
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
82892
83087
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
82893
83088
  return true;
82894
83089
  }
@@ -83562,7 +83757,7 @@ var ts;
83562
83757
  }
83563
83758
  function errorUnusedLocal(declaration, name, addDiagnostic) {
83564
83759
  var node = ts.getNameOfDeclaration(declaration) || declaration;
83565
- var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
83760
+ var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
83566
83761
  addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
83567
83762
  }
83568
83763
  function isIdentifierThatStartsWithUnderscore(node) {
@@ -84992,7 +85187,16 @@ var ts;
84992
85187
  var message = allowAsyncIterables
84993
85188
  ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
84994
85189
  : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
84995
- return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
85190
+ var suggestAwait =
85191
+ // for (const x of Promise<...>) or [...Promise<...>]
85192
+ !!getAwaitedTypeOfPromise(type)
85193
+ // for (const x of AsyncIterable<...>)
85194
+ || (!allowAsyncIterables &&
85195
+ ts.isForOfStatement(errorNode.parent) &&
85196
+ errorNode.parent.expression === errorNode &&
85197
+ getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
85198
+ isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
85199
+ return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
84996
85200
  }
84997
85201
  /**
84998
85202
  * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
@@ -85507,7 +85711,7 @@ var ts;
85507
85711
  var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
85508
85712
  name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
85509
85713
  var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
85510
- var _loop_31 = function (info) {
85714
+ var _loop_30 = function (info) {
85511
85715
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
85512
85716
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
85513
85717
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -85524,7 +85728,7 @@ var ts;
85524
85728
  };
85525
85729
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
85526
85730
  var info = indexInfos_9[_i];
85527
- _loop_31(info);
85731
+ _loop_30(info);
85528
85732
  }
85529
85733
  }
85530
85734
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -85532,7 +85736,7 @@ var ts;
85532
85736
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
85533
85737
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
85534
85738
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
85535
- var _loop_32 = function (info) {
85739
+ var _loop_31 = function (info) {
85536
85740
  if (info === checkInfo)
85537
85741
  return "continue";
85538
85742
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -85547,7 +85751,7 @@ var ts;
85547
85751
  };
85548
85752
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
85549
85753
  var info = indexInfos_10[_i];
85550
- _loop_32(info);
85754
+ _loop_31(info);
85551
85755
  }
85552
85756
  }
85553
85757
  function checkTypeNameIsReserved(name, message) {
@@ -85602,7 +85806,7 @@ var ts;
85602
85806
  }
85603
85807
  else {
85604
85808
  ts.forEach(jsdocParameters, function (_a, index) {
85605
- var name = _a.name;
85809
+ var name = _a.name, isNameFirst = _a.isNameFirst;
85606
85810
  if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
85607
85811
  return;
85608
85812
  }
@@ -85612,7 +85816,9 @@ var ts;
85612
85816
  }
85613
85817
  }
85614
85818
  else {
85615
- errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
85819
+ if (!isNameFirst) {
85820
+ errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
85821
+ }
85616
85822
  }
85617
85823
  });
85618
85824
  }
@@ -85867,7 +86073,7 @@ var ts;
85867
86073
  var baseTypes = baseTypeNode && getBaseTypes(type);
85868
86074
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
85869
86075
  var baseStaticType = getBaseConstructorTypeOfClass(type);
85870
- var _loop_33 = function (member) {
86076
+ var _loop_32 = function (member) {
85871
86077
  if (ts.hasAmbientModifier(member)) {
85872
86078
  return "continue";
85873
86079
  }
@@ -85884,7 +86090,7 @@ var ts;
85884
86090
  };
85885
86091
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85886
86092
  var member = _a[_i];
85887
- _loop_33(member);
86093
+ _loop_32(member);
85888
86094
  }
85889
86095
  }
85890
86096
  /**
@@ -85972,7 +86178,7 @@ var ts;
85972
86178
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
85973
86179
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
85974
86180
  var issuedMemberError = false;
85975
- var _loop_34 = function (member) {
86181
+ var _loop_33 = function (member) {
85976
86182
  if (ts.isStatic(member)) {
85977
86183
  return "continue";
85978
86184
  }
@@ -85991,7 +86197,7 @@ var ts;
85991
86197
  };
85992
86198
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85993
86199
  var member = _a[_i];
85994
- _loop_34(member);
86200
+ _loop_33(member);
85995
86201
  }
85996
86202
  if (!issuedMemberError) {
85997
86203
  // check again with diagnostics to generate a less-specific error
@@ -86062,7 +86268,7 @@ var ts;
86062
86268
  var _a, _b, _c, _d;
86063
86269
  // NOTE: assignability is checked in checkClassDeclaration
86064
86270
  var baseProperties = getPropertiesOfType(baseType);
86065
- var _loop_35 = function (baseProperty) {
86271
+ var _loop_34 = function (baseProperty) {
86066
86272
  var base = getTargetSymbol(baseProperty);
86067
86273
  if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
86068
86274
  return "continue";
@@ -86172,8 +86378,8 @@ var ts;
86172
86378
  };
86173
86379
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
86174
86380
  var baseProperty = baseProperties_1[_i];
86175
- var state_11 = _loop_35(baseProperty);
86176
- switch (state_11) {
86381
+ var state_10 = _loop_34(baseProperty);
86382
+ switch (state_10) {
86177
86383
  case "continue-basePropertyCheck": continue basePropertyCheck;
86178
86384
  }
86179
86385
  }
@@ -86692,12 +86898,11 @@ var ts;
86692
86898
  }
86693
86899
  }
86694
86900
  function checkModuleAugmentationElement(node, isGlobalAugmentation) {
86695
- var _a;
86696
86901
  switch (node.kind) {
86697
86902
  case 240 /* SyntaxKind.VariableStatement */:
86698
86903
  // error each individual name in variable statement instead of marking the entire variable statement
86699
- for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) {
86700
- var decl = _b[_i];
86904
+ for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
86905
+ var decl = _a[_i];
86701
86906
  checkModuleAugmentationElement(decl, isGlobalAugmentation);
86702
86907
  }
86703
86908
  break;
@@ -86713,8 +86918,8 @@ var ts;
86713
86918
  case 257 /* SyntaxKind.VariableDeclaration */:
86714
86919
  var name = node.name;
86715
86920
  if (ts.isBindingPattern(name)) {
86716
- for (var _c = 0, _d = name.elements; _c < _d.length; _c++) {
86717
- var el = _d[_c];
86921
+ for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
86922
+ var el = _c[_b];
86718
86923
  // mark individual names in binding pattern
86719
86924
  checkModuleAugmentationElement(el, isGlobalAugmentation);
86720
86925
  }
@@ -86730,18 +86935,6 @@ var ts;
86730
86935
  if (isGlobalAugmentation) {
86731
86936
  return;
86732
86937
  }
86733
- var symbol = getSymbolOfNode(node);
86734
- if (symbol) {
86735
- // module augmentations cannot introduce new names on the top level scope of the module
86736
- // this is done it two steps
86737
- // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error
86738
- // 2. main check - report error if value declaration of the parent symbol is module augmentation)
86739
- var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */);
86740
- if (!reportError) {
86741
- // symbol should not originate in augmentation
86742
- reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
86743
- }
86744
- }
86745
86938
  break;
86746
86939
  }
86747
86940
  }
@@ -86843,10 +87036,11 @@ var ts;
86843
87036
  }
86844
87037
  return;
86845
87038
  }
87039
+ var targetFlags = getAllSymbolFlags(target);
86846
87040
  var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
86847
87041
  (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
86848
87042
  (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
86849
- if (target.flags & excludedMeanings) {
87043
+ if (targetFlags & excludedMeanings) {
86850
87044
  var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
86851
87045
  ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
86852
87046
  ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
@@ -86856,7 +87050,7 @@ var ts;
86856
87050
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
86857
87051
  && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
86858
87052
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
86859
- var isType = !(target.flags & 111551 /* SymbolFlags.Value */);
87053
+ var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
86860
87054
  if (isType || typeOnlyAlias) {
86861
87055
  switch (node.kind) {
86862
87056
  case 270 /* SyntaxKind.ImportClause */:
@@ -87016,14 +87210,15 @@ var ts;
87016
87210
  if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
87017
87211
  var target = resolveAlias(getSymbolOfNode(node));
87018
87212
  if (target !== unknownSymbol) {
87019
- if (target.flags & 111551 /* SymbolFlags.Value */) {
87213
+ var targetFlags = getAllSymbolFlags(target);
87214
+ if (targetFlags & 111551 /* SymbolFlags.Value */) {
87020
87215
  // Target is a value symbol, check that it is not hidden by a local declaration with the same name
87021
87216
  var moduleName = ts.getFirstIdentifier(node.moduleReference);
87022
87217
  if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
87023
87218
  error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
87024
87219
  }
87025
87220
  }
87026
- if (target.flags & 788968 /* SymbolFlags.Type */) {
87221
+ if (targetFlags & 788968 /* SymbolFlags.Type */) {
87027
87222
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
87028
87223
  }
87029
87224
  }
@@ -87162,7 +87357,7 @@ var ts;
87162
87357
  markExportAsReferenced(node);
87163
87358
  }
87164
87359
  var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
87165
- if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87360
+ if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87166
87361
  checkExpressionCached(node.propertyName || node.name);
87167
87362
  }
87168
87363
  }
@@ -87209,7 +87404,7 @@ var ts;
87209
87404
  markAliasReferenced(sym, id);
87210
87405
  // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
87211
87406
  var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
87212
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87407
+ if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87213
87408
  // However if it is a value, we need to check it's being used correctly
87214
87409
  checkExpressionCached(node.expression);
87215
87410
  }
@@ -87881,29 +88076,9 @@ var ts;
87881
88076
  }
87882
88077
  function isTypeDeclarationName(name) {
87883
88078
  return name.kind === 79 /* SyntaxKind.Identifier */ &&
87884
- isTypeDeclaration(name.parent) &&
88079
+ ts.isTypeDeclaration(name.parent) &&
87885
88080
  ts.getNameOfDeclaration(name.parent) === name;
87886
88081
  }
87887
- function isTypeDeclaration(node) {
87888
- switch (node.kind) {
87889
- case 165 /* SyntaxKind.TypeParameter */:
87890
- case 260 /* SyntaxKind.ClassDeclaration */:
87891
- case 261 /* SyntaxKind.InterfaceDeclaration */:
87892
- case 262 /* SyntaxKind.TypeAliasDeclaration */:
87893
- case 263 /* SyntaxKind.EnumDeclaration */:
87894
- case 348 /* SyntaxKind.JSDocTypedefTag */:
87895
- case 341 /* SyntaxKind.JSDocCallbackTag */:
87896
- case 342 /* SyntaxKind.JSDocEnumTag */:
87897
- return true;
87898
- case 270 /* SyntaxKind.ImportClause */:
87899
- return node.isTypeOnly;
87900
- case 273 /* SyntaxKind.ImportSpecifier */:
87901
- case 278 /* SyntaxKind.ExportSpecifier */:
87902
- return node.parent.parent.isTypeOnly;
87903
- default:
87904
- return false;
87905
- }
87906
- }
87907
88082
  // True if the given identifier is part of a type reference
87908
88083
  function isTypeReferenceIdentifier(node) {
87909
88084
  while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
@@ -88336,7 +88511,7 @@ var ts;
88336
88511
  var baseType = ts.firstOrUndefined(getBaseTypes(classType));
88337
88512
  return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
88338
88513
  }
88339
- if (isTypeDeclaration(node)) {
88514
+ if (ts.isTypeDeclaration(node)) {
88340
88515
  // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
88341
88516
  var symbol = getSymbolOfNode(node);
88342
88517
  return getDeclaredTypeOfSymbol(symbol);
@@ -88531,7 +88706,7 @@ var ts;
88531
88706
  return symbolLinks.exportsSomeValue;
88532
88707
  function isValue(s) {
88533
88708
  s = resolveSymbol(s);
88534
- return s && !!(s.flags & 111551 /* SymbolFlags.Value */);
88709
+ return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
88535
88710
  }
88536
88711
  }
88537
88712
  function isNameOfModuleOrEnumDeclaration(node) {
@@ -88584,7 +88759,7 @@ var ts;
88584
88759
  var symbol = getReferencedValueOrAliasSymbol(node);
88585
88760
  // We should only get the declaration of an alias if there isn't a local value
88586
88761
  // declaration for the symbol
88587
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
88762
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
88588
88763
  return getDeclarationOfAliasSymbol(symbol);
88589
88764
  }
88590
88765
  }
@@ -88672,7 +88847,7 @@ var ts;
88672
88847
  case 273 /* SyntaxKind.ImportSpecifier */:
88673
88848
  case 278 /* SyntaxKind.ExportSpecifier */:
88674
88849
  var symbol = getSymbolOfNode(node);
88675
- return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
88850
+ return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
88676
88851
  case 275 /* SyntaxKind.ExportDeclaration */:
88677
88852
  var exportClause = node.exportClause;
88678
88853
  return !!exportClause && (ts.isNamespaceExport(exportClause) ||
@@ -88694,6 +88869,7 @@ var ts;
88694
88869
  return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
88695
88870
  }
88696
88871
  function isAliasResolvedToValue(symbol) {
88872
+ var _a;
88697
88873
  if (!symbol) {
88698
88874
  return false;
88699
88875
  }
@@ -88703,7 +88879,7 @@ var ts;
88703
88879
  }
88704
88880
  // const enums and modules that contain only const enums are not considered values from the emit perspective
88705
88881
  // unless 'preserveConstEnums' option is set to true
88706
- return !!(target.flags & 111551 /* SymbolFlags.Value */) &&
88882
+ return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
88707
88883
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
88708
88884
  }
88709
88885
  function isConstEnumOrConstEnumOnlyModule(s) {
@@ -88718,7 +88894,7 @@ var ts;
88718
88894
  }
88719
88895
  var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
88720
88896
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
88721
- target.flags & 111551 /* SymbolFlags.Value */ &&
88897
+ getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
88722
88898
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
88723
88899
  // An `export import ... =` of a value symbol is always considered referenced
88724
88900
  return true;
@@ -98372,8 +98548,11 @@ var ts;
98372
98548
  }
98373
98549
  return ts.visitEachChild(node, visitor, context);
98374
98550
  case 174 /* SyntaxKind.GetAccessor */:
98551
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitGetAccessorDeclaration, node);
98375
98552
  case 175 /* SyntaxKind.SetAccessor */:
98553
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitSetAccessorDeclaration, node);
98376
98554
  case 173 /* SyntaxKind.Constructor */:
98555
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitConstructorDeclaration, node);
98377
98556
  case 260 /* SyntaxKind.ClassDeclaration */:
98378
98557
  case 228 /* SyntaxKind.ClassExpression */:
98379
98558
  return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
@@ -98474,6 +98653,9 @@ var ts;
98474
98653
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
98475
98654
  /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
98476
98655
  }
98656
+ function visitConstructorDeclaration(node) {
98657
+ return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98658
+ }
98477
98659
  /**
98478
98660
  * Visits a MethodDeclaration node.
98479
98661
  *
@@ -98488,7 +98670,14 @@ var ts;
98488
98670
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
98489
98671
  /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
98490
98672
  ? transformAsyncFunctionBody(node)
98491
- : ts.visitFunctionBody(node.body, visitor, context));
98673
+ : transformMethodBody(node));
98674
+ }
98675
+ function visitGetAccessorDeclaration(node) {
98676
+ return factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context),
98677
+ /*type*/ undefined, transformMethodBody(node));
98678
+ }
98679
+ function visitSetAccessorDeclaration(node) {
98680
+ return factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98492
98681
  }
98493
98682
  /**
98494
98683
  * Visits a FunctionDeclaration node.
@@ -98602,6 +98791,42 @@ var ts;
98602
98791
  }
98603
98792
  return false;
98604
98793
  }
98794
+ function transformMethodBody(node) {
98795
+ ts.Debug.assertIsDefined(node.body);
98796
+ var savedCapturedSuperProperties = capturedSuperProperties;
98797
+ var savedHasSuperElementAccess = hasSuperElementAccess;
98798
+ capturedSuperProperties = new ts.Set();
98799
+ hasSuperElementAccess = false;
98800
+ var updated = ts.visitFunctionBody(node.body, visitor, context);
98801
+ // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98802
+ // This step isn't needed if we eventually transform this to ES5.
98803
+ var originalMethod = ts.getOriginalNode(node, ts.isFunctionLikeDeclaration);
98804
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ &&
98805
+ resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) &&
98806
+ (ts.getFunctionFlags(originalMethod) & 3 /* FunctionFlags.AsyncGenerator */) !== 3 /* FunctionFlags.AsyncGenerator */;
98807
+ if (emitSuperHelpers) {
98808
+ enableSubstitutionForAsyncMethodsWithSuper();
98809
+ if (capturedSuperProperties.size) {
98810
+ var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
98811
+ substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
98812
+ var statements = updated.statements.slice();
98813
+ ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
98814
+ updated = factory.updateBlock(updated, statements);
98815
+ }
98816
+ if (hasSuperElementAccess) {
98817
+ // Emit helpers for super element access expressions (`super[x]`).
98818
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98819
+ ts.addEmitHelper(updated, ts.advancedAsyncSuperHelper);
98820
+ }
98821
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98822
+ ts.addEmitHelper(updated, ts.asyncSuperHelper);
98823
+ }
98824
+ }
98825
+ }
98826
+ capturedSuperProperties = savedCapturedSuperProperties;
98827
+ hasSuperElementAccess = savedHasSuperElementAccess;
98828
+ return updated;
98829
+ }
98605
98830
  function transformAsyncFunctionBody(node) {
98606
98831
  resumeLexicalEnvironment();
98607
98832
  var original = ts.getOriginalNode(node, ts.isFunctionLike);
@@ -98634,7 +98859,7 @@ var ts;
98634
98859
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
98635
98860
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98636
98861
  // This step isn't needed if we eventually transform this to ES5.
98637
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
98862
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
98638
98863
  if (emitSuperHelpers) {
98639
98864
  enableSubstitutionForAsyncMethodsWithSuper();
98640
98865
  if (capturedSuperProperties.size) {
@@ -98647,10 +98872,10 @@ var ts;
98647
98872
  ts.setTextRange(block, node.body);
98648
98873
  if (emitSuperHelpers && hasSuperElementAccess) {
98649
98874
  // Emit helpers for super element access expressions (`super[x]`).
98650
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
98875
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98651
98876
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
98652
98877
  }
98653
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
98878
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98654
98879
  ts.addEmitHelper(block, ts.asyncSuperHelper);
98655
98880
  }
98656
98881
  }
@@ -98722,7 +98947,7 @@ var ts;
98722
98947
  // If we need to support substitutions for `super` in an async method,
98723
98948
  // we should track it here.
98724
98949
  if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
98725
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
98950
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
98726
98951
  if (superContainerFlags !== enclosingSuperContainerFlags) {
98727
98952
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
98728
98953
  enclosingSuperContainerFlags = superContainerFlags;
@@ -98799,7 +99024,7 @@ var ts;
98799
99024
  || kind === 175 /* SyntaxKind.SetAccessor */;
98800
99025
  }
98801
99026
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
98802
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99027
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98803
99028
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
98804
99029
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
98805
99030
  }
@@ -98814,7 +99039,7 @@ var ts;
98814
99039
  function createSuperAccessVariableStatement(factory, resolver, node, names) {
98815
99040
  // Create a variable declaration with a getter/setter (if binding) definition for each name:
98816
99041
  // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
98817
- var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0;
99042
+ var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) !== 0;
98818
99043
  var accessors = [];
98819
99044
  names.forEach(function (_, key) {
98820
99045
  var name = ts.unescapeLeadingUnderscores(key);
@@ -99307,11 +99532,22 @@ var ts;
99307
99532
  }
99308
99533
  return node;
99309
99534
  }
99310
- function convertForOfStatementHead(node, boundValue) {
99311
- var binding = ts.createForOfBindingStatement(factory, node.initializer, boundValue);
99535
+ function convertForOfStatementHead(node, boundValue, nonUserCode) {
99536
+ var value = factory.createTempVariable(hoistVariableDeclaration);
99537
+ var iteratorValueExpression = factory.createAssignment(value, boundValue);
99538
+ var iteratorValueStatement = factory.createExpressionStatement(iteratorValueExpression);
99539
+ ts.setSourceMapRange(iteratorValueStatement, node.expression);
99540
+ var exitNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createFalse());
99541
+ var exitNonUserCodeStatement = factory.createExpressionStatement(exitNonUserCodeExpression);
99542
+ ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
99543
+ var enterNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createTrue());
99544
+ var enterNonUserCodeStatement = factory.createExpressionStatement(enterNonUserCodeExpression);
99545
+ ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
99546
+ var statements = [];
99547
+ var binding = ts.createForOfBindingStatement(factory, node.initializer, value);
99548
+ statements.push(ts.visitNode(binding, visitor, ts.isStatement));
99312
99549
  var bodyLocation;
99313
99550
  var statementsLocation;
99314
- var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
99315
99551
  var statement = ts.visitIterationBody(node.statement, visitor, context);
99316
99552
  if (ts.isBlock(statement)) {
99317
99553
  ts.addRange(statements, statement.statements);
@@ -99321,8 +99557,16 @@ var ts;
99321
99557
  else {
99322
99558
  statements.push(statement);
99323
99559
  }
99324
- return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
99560
+ var body = ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
99325
99561
  /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */);
99562
+ return factory.createBlock([
99563
+ iteratorValueStatement,
99564
+ exitNonUserCodeStatement,
99565
+ factory.createTryStatement(body,
99566
+ /*catchClause*/ undefined, factory.createBlock([
99567
+ enterNonUserCodeStatement
99568
+ ]))
99569
+ ]);
99326
99570
  }
99327
99571
  function createDownlevelAwait(expression) {
99328
99572
  return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
@@ -99333,6 +99577,8 @@ var ts;
99333
99577
  var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
99334
99578
  var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined);
99335
99579
  var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(/*recordTempVariable*/ undefined);
99580
+ var nonUserCode = factory.createTempVariable(/*recordTempVariable*/ undefined);
99581
+ var done = factory.createTempVariable(hoistVariableDeclaration);
99336
99582
  var errorRecord = factory.createUniqueName("e");
99337
99583
  var catchVariable = factory.getGeneratedNameForNode(errorRecord);
99338
99584
  var returnMethod = factory.createTempVariable(/*recordTempVariable*/ undefined);
@@ -99349,12 +99595,17 @@ var ts;
99349
99595
  callValues;
99350
99596
  var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(
99351
99597
  /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
99598
+ factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
99352
99599
  ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
99353
99600
  factory.createVariableDeclaration(result)
99354
99601
  ]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
99355
- /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)),
99602
+ /*condition*/ factory.inlineExpressions([
99603
+ factory.createAssignment(result, createDownlevelAwait(callNext)),
99604
+ factory.createAssignment(done, getDone),
99605
+ factory.createLogicalNot(done)
99606
+ ]),
99356
99607
  /*incrementor*/ undefined,
99357
- /*statement*/ convertForOfStatementHead(node, getValue)),
99608
+ /*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)),
99358
99609
  /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
99359
99610
  ts.setOriginalNode(forStatement, node);
99360
99611
  return factory.createTryStatement(factory.createBlock([
@@ -99366,7 +99617,7 @@ var ts;
99366
99617
  ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([
99367
99618
  factory.createTryStatement(
99368
99619
  /*tryBlock*/ factory.createBlock([
99369
- 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 */)
99620
+ 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 */)
99370
99621
  ]),
99371
99622
  /*catchClause*/ undefined,
99372
99623
  /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([
@@ -99522,7 +99773,7 @@ var ts;
99522
99773
  /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
99523
99774
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
99524
99775
  // This step isn't needed if we eventually transform this to ES5.
99525
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
99776
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
99526
99777
  if (emitSuperHelpers) {
99527
99778
  enableSubstitutionForAsyncMethodsWithSuper();
99528
99779
  var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
@@ -99533,10 +99784,10 @@ var ts;
99533
99784
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
99534
99785
  var block = factory.updateBlock(node.body, statements);
99535
99786
  if (emitSuperHelpers && hasSuperElementAccess) {
99536
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99787
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99537
99788
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
99538
99789
  }
99539
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
99790
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
99540
99791
  ts.addEmitHelper(block, ts.asyncSuperHelper);
99541
99792
  }
99542
99793
  }
@@ -99665,7 +99916,7 @@ var ts;
99665
99916
  // If we need to support substitutions for `super` in an async method,
99666
99917
  // we should track it here.
99667
99918
  if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
99668
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
99919
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
99669
99920
  if (superContainerFlags !== enclosingSuperContainerFlags) {
99670
99921
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
99671
99922
  enclosingSuperContainerFlags = superContainerFlags;
@@ -99742,7 +99993,7 @@ var ts;
99742
99993
  || kind === 175 /* SyntaxKind.SetAccessor */;
99743
99994
  }
99744
99995
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
99745
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99996
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99746
99997
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
99747
99998
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
99748
99999
  }
@@ -101211,11 +101462,13 @@ var ts;
101211
101462
  return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
101212
101463
  }
101213
101464
  function visitIdentifier(node) {
101214
- if (!convertedLoopState) {
101215
- return node;
101465
+ if (convertedLoopState) {
101466
+ if (resolver.isArgumentsLocalBinding(node)) {
101467
+ return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101468
+ }
101216
101469
  }
101217
- if (resolver.isArgumentsLocalBinding(node)) {
101218
- return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101470
+ if (node.hasExtendedUnicodeEscape) {
101471
+ return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
101219
101472
  }
101220
101473
  return node;
101221
101474
  }
@@ -105362,7 +105615,6 @@ var ts;
105362
105615
  return node;
105363
105616
  }
105364
105617
  function transformAndEmitForInStatement(node) {
105365
- // TODO(rbuckton): Source map locations
105366
105618
  if (containsYield(node)) {
105367
105619
  // [source]
105368
105620
  // for (var p in o) {
@@ -105370,34 +105622,41 @@ var ts;
105370
105622
  // }
105371
105623
  //
105372
105624
  // [intermediate]
105373
- // .local _a, _b, _i
105374
- // _a = [];
105375
- // for (_b in o) _a.push(_b);
105625
+ // .local _b, _a, _c, _i
105626
+ // _b = [];
105627
+ // _a = o;
105628
+ // for (_c in _a) _b.push(_c);
105376
105629
  // _i = 0;
105377
105630
  // .loop incrementLabel, endLoopLabel
105378
105631
  // .mark conditionLabel
105379
- // .brfalse endLoopLabel, (_i < _a.length)
105380
- // p = _a[_i];
105632
+ // .brfalse endLoopLabel, (_i < _b.length)
105633
+ // _c = _b[_i];
105634
+ // .brfalse incrementLabel, (_c in _a)
105635
+ // p = _c;
105381
105636
  // /*body*/
105382
105637
  // .mark incrementLabel
105383
- // _b++;
105638
+ // _c++;
105384
105639
  // .br conditionLabel
105385
105640
  // .endloop
105386
105641
  // .mark endLoopLabel
105387
- var keysArray = declareLocal(); // _a
105388
- var key = declareLocal(); // _b
105642
+ var obj = declareLocal(); // _a
105643
+ var keysArray = declareLocal(); // _b
105644
+ var key = declareLocal(); // _c
105389
105645
  var keysIndex = factory.createLoopVariable(); // _i
105390
105646
  var initializer = node.initializer;
105391
105647
  hoistVariableDeclaration(keysIndex);
105648
+ emitAssignment(obj, ts.visitNode(node.expression, visitor, ts.isExpression));
105392
105649
  emitAssignment(keysArray, factory.createArrayLiteralExpression());
105393
- emitStatement(factory.createForInStatement(key, ts.visitNode(node.expression, visitor, ts.isExpression), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
105650
+ emitStatement(factory.createForInStatement(key, obj, factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
105394
105651
  /*typeArguments*/ undefined, [key]))));
105395
105652
  emitAssignment(keysIndex, factory.createNumericLiteral(0));
105396
105653
  var conditionLabel = defineLabel();
105397
105654
  var incrementLabel = defineLabel();
105398
- var endLabel = beginLoopBlock(incrementLabel);
105655
+ var endLoopLabel = beginLoopBlock(incrementLabel);
105399
105656
  markLabel(conditionLabel);
105400
- emitBreakWhenFalse(endLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
105657
+ emitBreakWhenFalse(endLoopLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
105658
+ emitAssignment(key, factory.createElementAccessExpression(keysArray, keysIndex));
105659
+ emitBreakWhenFalse(incrementLabel, factory.createBinaryExpression(key, 101 /* SyntaxKind.InKeyword */, obj));
105401
105660
  var variable = void 0;
105402
105661
  if (ts.isVariableDeclarationList(initializer)) {
105403
105662
  for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
@@ -105410,7 +105669,7 @@ var ts;
105410
105669
  variable = ts.visitNode(initializer, visitor, ts.isExpression);
105411
105670
  ts.Debug.assert(ts.isLeftHandSideExpression(variable));
105412
105671
  }
105413
- emitAssignment(variable, factory.createElementAccessExpression(keysArray, keysIndex));
105672
+ emitAssignment(variable, key);
105414
105673
  transformAndEmitEmbeddedStatement(node.statement);
105415
105674
  markLabel(incrementLabel);
105416
105675
  emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
@@ -107251,7 +107510,7 @@ var ts;
107251
107510
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107252
107511
  case ts.ModuleKind.CommonJS:
107253
107512
  default:
107254
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107513
+ return createImportCallExpressionCommonJS(argument);
107255
107514
  }
107256
107515
  }
107257
107516
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107274,7 +107533,7 @@ var ts;
107274
107533
  return factory.createConditionalExpression(
107275
107534
  /*condition*/ factory.createIdentifier("__syncRequire"),
107276
107535
  /*questionToken*/ undefined,
107277
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107536
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107278
107537
  /*colonToken*/ undefined,
107279
107538
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107280
107539
  }
@@ -107283,7 +107542,7 @@ var ts;
107283
107542
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107284
107543
  /*condition*/ factory.createIdentifier("__syncRequire"),
107285
107544
  /*questionToken*/ undefined,
107286
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107545
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107287
107546
  /*colonToken*/ undefined,
107288
107547
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107289
107548
  }
@@ -107333,14 +107592,20 @@ var ts;
107333
107592
  }
107334
107593
  return promise;
107335
107594
  }
107336
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107337
- // import("./blah")
107595
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107596
+ // import(x)
107338
107597
  // emit as
107339
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107598
+ // var _a;
107599
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107340
107600
  // We have to wrap require in then callback so that require is done in asynchronously
107341
107601
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107342
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107343
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107602
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107603
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107604
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107605
+ /*typeArguments*/ undefined,
107606
+ /*argumentsArray*/ []);
107607
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107608
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107344
107609
  if (ts.getESModuleInterop(compilerOptions)) {
107345
107610
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107346
107611
  }
@@ -107361,14 +107626,9 @@ var ts;
107361
107626
  /*typeParameters*/ undefined,
107362
107627
  /*parameters*/ [],
107363
107628
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107364
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107365
- // that this new function expression indicates it captures 'this' so that the
107366
- // es2015 transformer will properly substitute 'this' with '_this'.
107367
- if (containsLexicalThis) {
107368
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107369
- }
107370
107629
  }
107371
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107630
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107631
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107372
107632
  }
107373
107633
  function getHelperExpressionForExport(node, innerExpr) {
107374
107634
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
@@ -118361,14 +118621,16 @@ var ts;
118361
118621
  }
118362
118622
  return setReadFileCache(key, fileName);
118363
118623
  };
118364
- var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
118624
+ var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
118365
118625
  var key = toPath(fileName);
118366
- var value = sourceFileCache.get(key);
118626
+ var impliedNodeFormat = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.impliedNodeFormat : undefined;
118627
+ var forImpliedNodeFormat = sourceFileCache.get(impliedNodeFormat);
118628
+ var value = forImpliedNodeFormat === null || forImpliedNodeFormat === void 0 ? void 0 : forImpliedNodeFormat.get(key);
118367
118629
  if (value)
118368
118630
  return value;
118369
- var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
118631
+ var sourceFile = getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
118370
118632
  if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) {
118371
- sourceFileCache.set(key, sourceFile);
118633
+ sourceFileCache.set(impliedNodeFormat, (forImpliedNodeFormat || new ts.Map()).set(key, sourceFile));
118372
118634
  }
118373
118635
  return sourceFile;
118374
118636
  } : undefined;
@@ -118393,13 +118655,15 @@ var ts;
118393
118655
  var value = readFileCache.get(key);
118394
118656
  if (value !== undefined && value !== data) {
118395
118657
  readFileCache.delete(key);
118396
- sourceFileCache.delete(key);
118658
+ sourceFileCache.forEach(function (map) { return map.delete(key); });
118397
118659
  }
118398
118660
  else if (getSourceFileWithCache) {
118399
- var sourceFile = sourceFileCache.get(key);
118400
- if (sourceFile && sourceFile.text !== data) {
118401
- sourceFileCache.delete(key);
118402
- }
118661
+ sourceFileCache.forEach(function (map) {
118662
+ var sourceFile = map.get(key);
118663
+ if (sourceFile && sourceFile.text !== data) {
118664
+ map.delete(key);
118665
+ }
118666
+ });
118403
118667
  }
118404
118668
  originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
118405
118669
  };
@@ -122541,10 +122805,16 @@ var ts;
122541
122805
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
122542
122806
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
122543
122807
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122808
+ // We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged,
122809
+ // which will eg be depedent on change in options like declarationDir and outDir options are unchanged.
122810
+ // We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because
122811
+ // oldCompilerOptions can be undefined if there was change in say module from None to some other option
122812
+ // 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
122813
+ // but that option change does not affect d.ts file name so emitSignatures should still be reused.
122544
122814
  var canCopyEmitSignatures = compilerOptions.composite &&
122545
122815
  (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
122546
122816
  !outFilePath &&
122547
- !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
122817
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122548
122818
  if (useOldState) {
122549
122819
  // Copy old state's changed files set
122550
122820
  (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
@@ -123090,7 +123360,8 @@ var ts;
123090
123360
  for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
123091
123361
  var path = _c[_b];
123092
123362
  if (ts.tryAddToSet(seenFiles, path)) {
123093
- (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]);
123363
+ var fileId = toFileId(path), emitKind = state.affectedFilesPendingEmitKind.get(path);
123364
+ (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push(emitKind === 1 /* BuilderFileEmit.Full */ ? fileId : [fileId]);
123094
123365
  }
123095
123366
  }
123096
123367
  }
@@ -123569,6 +123840,10 @@ var ts;
123569
123840
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
123570
123841
  }
123571
123842
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
123843
+ function toBuilderFileEmit(value) {
123844
+ return ts.isNumber(value) ? 1 /* BuilderFileEmit.Full */ : 0 /* BuilderFileEmit.DtsOnly */;
123845
+ }
123846
+ ts.toBuilderFileEmit = toBuilderFileEmit;
123572
123847
  function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
123573
123848
  var _a, _b, _c, _d;
123574
123849
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
@@ -123610,8 +123885,8 @@ var ts;
123610
123885
  exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
123611
123886
  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]; }),
123612
123887
  hasReusableDiagnostic: true,
123613
- affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }),
123614
- affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }),
123888
+ affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }),
123889
+ affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, toBuilderFileEmit),
123615
123890
  affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
123616
123891
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
123617
123892
  latestChangedDtsFile: latestChangedDtsFile,
@@ -123759,7 +124034,7 @@ var ts;
123759
124034
  var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
123760
124035
  if (isNonDirectorySeparatorRoot &&
123761
124036
  dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
123762
- pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart
124037
+ pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) { // Dos style nextPart
123763
124038
  nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
123764
124039
  if (nextDirectorySeparator === -1) {
123765
124040
  // ignore "//vda1cs4850/c$/folderAtRoot"
@@ -125013,7 +125288,7 @@ var ts;
125013
125288
  });
125014
125289
  // Sort by paths closest to importing file Name directory
125015
125290
  var sortedPaths = [];
125016
- var _loop_36 = function (directory) {
125291
+ var _loop_35 = function (directory) {
125017
125292
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
125018
125293
  var pathsInDirectory;
125019
125294
  allFileNames.forEach(function (_a, fileName) {
@@ -125037,9 +125312,9 @@ var ts;
125037
125312
  };
125038
125313
  var out_directory_1;
125039
125314
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
125040
- var state_12 = _loop_36(directory);
125315
+ var state_11 = _loop_35(directory);
125041
125316
  directory = out_directory_1;
125042
- if (state_12 === "break")
125317
+ if (state_11 === "break")
125043
125318
  break;
125044
125319
  }
125045
125320
  if (allFileNames.size) {
@@ -125108,7 +125383,7 @@ var ts;
125108
125383
  }
125109
125384
  function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
125110
125385
  for (var key in paths) {
125111
- var _loop_37 = function (patternText_1) {
125386
+ var _loop_36 = function (patternText_1) {
125112
125387
  var pattern = ts.normalizePath(patternText_1);
125113
125388
  var indexOfStar = pattern.indexOf("*");
125114
125389
  // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
@@ -125175,9 +125450,9 @@ var ts;
125175
125450
  };
125176
125451
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
125177
125452
  var patternText_1 = _a[_i];
125178
- var state_13 = _loop_37(patternText_1);
125179
- if (typeof state_13 === "object")
125180
- return state_13.value;
125453
+ var state_12 = _loop_36(patternText_1);
125454
+ if (typeof state_12 === "object")
125455
+ return state_12.value;
125181
125456
  }
125182
125457
  }
125183
125458
  function validateEnding(_a) {
@@ -125265,15 +125540,21 @@ var ts;
125265
125540
  return undefined;
125266
125541
  }
125267
125542
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
125268
- var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125269
- if (normalizedTargetPath === undefined) {
125543
+ var normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125544
+ if (normalizedTargetPaths === undefined) {
125545
+ return undefined;
125546
+ }
125547
+ var normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125548
+ var relativePaths = ts.flatMap(normalizedSourcePaths, function (sourcePath) {
125549
+ return ts.map(normalizedTargetPaths, function (targetPath) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName)); });
125550
+ });
125551
+ var shortest = ts.min(relativePaths, ts.compareNumberOfDirectorySeparators);
125552
+ if (!shortest) {
125270
125553
  return undefined;
125271
125554
  }
125272
- var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125273
- var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
125274
125555
  return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
125275
- ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
125276
- : ts.removeFileExtension(relativePath);
125556
+ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions)
125557
+ : ts.removeFileExtension(shortest);
125277
125558
  }
125278
125559
  function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
125279
125560
  var path = _a.path, isRedirect = _a.isRedirect;
@@ -125410,8 +125691,8 @@ var ts;
125410
125691
  }
125411
125692
  }
125412
125693
  }
125413
- function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125414
- return ts.firstDefined(rootDirs, function (rootDir) {
125694
+ function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125695
+ return ts.mapDefined(rootDirs, function (rootDir) {
125415
125696
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
125416
125697
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
125417
125698
  });
@@ -127979,8 +128260,15 @@ var ts;
127979
128260
  }
127980
128261
  if (buildInfo.program) {
127981
128262
  // If there are pending changes that are not emitted, project is out of date
128263
+ // When there are syntax errors, changeFileSet will have list of files changed (irrespective of noEmit)
128264
+ // But in case of semantic error we need special treatment.
128265
+ // Checking presence of affectedFilesPendingEmit list is fast and good way to tell if there were semantic errors and file emit was blocked
128266
+ // 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
128267
+ // 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
127982
128268
  if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
127983
- (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
128269
+ (!project.options.noEmit ?
128270
+ (_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length :
128271
+ ts.some(buildInfo.program.semanticDiagnosticsPerFile, ts.isArray))) {
127984
128272
  return {
127985
128273
  type: ts.UpToDateStatusType.OutOfDateBuildInfo,
127986
128274
  buildInfoFile: buildInfoPath
@@ -128742,6 +129030,12 @@ var ts;
128742
129030
  SemanticClassificationFormat["Original"] = "original";
128743
129031
  SemanticClassificationFormat["TwentyTwenty"] = "2020";
128744
129032
  })(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
129033
+ var OrganizeImportsMode;
129034
+ (function (OrganizeImportsMode) {
129035
+ OrganizeImportsMode["All"] = "All";
129036
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
129037
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
129038
+ })(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
128745
129039
  var CompletionTriggerKind;
128746
129040
  (function (CompletionTriggerKind) {
128747
129041
  /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
@@ -129787,6 +130081,8 @@ var ts;
129787
130081
  return lastTypeNode;
129788
130082
  }
129789
130083
  function getContextualTypeFromParentOrAncestorTypeNode(node, checker) {
130084
+ if (node.flags & (8388608 /* NodeFlags.JSDoc */ & ~262144 /* NodeFlags.JavaScriptFile */))
130085
+ return undefined;
129790
130086
  var contextualType = getContextualTypeFromParent(node, checker);
129791
130087
  if (contextualType)
129792
130088
  return contextualType;
@@ -132273,6 +132569,10 @@ var ts;
132273
132569
  return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
132274
132570
  }
132275
132571
  ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
132572
+ function isSourceFileFromLibrary(program, node) {
132573
+ return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
132574
+ }
132575
+ ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
132276
132576
  // #endregion
132277
132577
  })(ts || (ts = {}));
132278
132578
  /*@internal*/
@@ -135299,7 +135599,7 @@ var ts;
135299
135599
  if (preferences.includeCompletionsWithClassMemberSnippets &&
135300
135600
  preferences.includeCompletionsWithInsertText &&
135301
135601
  completionKind === 3 /* CompletionKind.MemberLike */ &&
135302
- isClassLikeMemberCompletion(symbol, location)) {
135602
+ isClassLikeMemberCompletion(symbol, location, sourceFile)) {
135303
135603
  var importAdder = void 0;
135304
135604
  (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
135305
135605
  sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
@@ -135371,7 +135671,7 @@ var ts;
135371
135671
  data: data,
135372
135672
  };
135373
135673
  }
135374
- function isClassLikeMemberCompletion(symbol, location) {
135674
+ function isClassLikeMemberCompletion(symbol, location, sourceFile) {
135375
135675
  // TODO: support JS files.
135376
135676
  if (ts.isInJSFile(location)) {
135377
135677
  return false;
@@ -135405,6 +135705,7 @@ var ts;
135405
135705
  location.parent.parent &&
135406
135706
  ts.isClassElement(location.parent) &&
135407
135707
  location === location.parent.name &&
135708
+ location.parent.getLastToken(sourceFile) === location.parent.name &&
135408
135709
  ts.isClassLike(location.parent.parent)) ||
135409
135710
  (location.parent &&
135410
135711
  ts.isSyntaxList(location) &&
@@ -142566,6 +142867,12 @@ var ts;
142566
142867
  var label = ts.getTargetLabel(node.parent, node.text);
142567
142868
  return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
142568
142869
  }
142870
+ if (node.kind === 105 /* SyntaxKind.ReturnKeyword */) {
142871
+ var functionDeclaration = ts.findAncestor(node.parent, function (n) {
142872
+ return ts.isClassStaticBlockDeclaration(n) ? "quit" : ts.isFunctionLikeDeclaration(n);
142873
+ });
142874
+ return functionDeclaration ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] : undefined;
142875
+ }
142569
142876
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
142570
142877
  var classDecl = node.parent.parent;
142571
142878
  var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
@@ -142701,13 +143008,16 @@ var ts;
142701
143008
  if (!baseDeclaration)
142702
143009
  return;
142703
143010
  var baseTypeNode = ts.getEffectiveBaseTypeNode(baseDeclaration);
142704
- var baseType = baseTypeNode ? typeChecker.getTypeAtLocation(baseTypeNode) : undefined;
142705
- if (!baseType)
143011
+ if (!baseTypeNode)
143012
+ return;
143013
+ var expression = ts.skipParentheses(baseTypeNode.expression);
143014
+ var base = ts.isClassExpression(expression) ? expression.symbol : typeChecker.getSymbolAtLocation(expression);
143015
+ if (!base)
142706
143016
  return;
142707
143017
  var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(classElement.name));
142708
143018
  var symbol = ts.hasStaticModifier(classElement)
142709
- ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbolAtLocation(baseType.symbol, baseDeclaration), name)
142710
- : typeChecker.getPropertyOfType(baseType, name);
143019
+ ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbol(base), name)
143020
+ : typeChecker.getPropertyOfType(typeChecker.getDeclaredTypeOfSymbol(base), name);
142711
143021
  if (!symbol)
142712
143022
  return;
142713
143023
  return getDefinitionFromSymbol(typeChecker, symbol, node);
@@ -143414,19 +143724,24 @@ var ts;
143414
143724
  return getCommentOwnerInfoWorker(commentOwner.initializer, options);
143415
143725
  case 260 /* SyntaxKind.ClassDeclaration */:
143416
143726
  case 261 /* SyntaxKind.InterfaceDeclaration */:
143417
- case 168 /* SyntaxKind.PropertySignature */:
143418
143727
  case 263 /* SyntaxKind.EnumDeclaration */:
143419
143728
  case 302 /* SyntaxKind.EnumMember */:
143420
143729
  case 262 /* SyntaxKind.TypeAliasDeclaration */:
143421
143730
  return { commentOwner: commentOwner };
143731
+ case 168 /* SyntaxKind.PropertySignature */: {
143732
+ var host_1 = commentOwner;
143733
+ return host_1.type && ts.isFunctionTypeNode(host_1.type)
143734
+ ? { commentOwner: commentOwner, parameters: host_1.type.parameters, hasReturn: hasReturn(host_1.type, options) }
143735
+ : { commentOwner: commentOwner };
143736
+ }
143422
143737
  case 240 /* SyntaxKind.VariableStatement */: {
143423
143738
  var varStatement = commentOwner;
143424
143739
  var varDeclarations = varStatement.declarationList.declarations;
143425
- var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer
143740
+ var host_2 = varDeclarations.length === 1 && varDeclarations[0].initializer
143426
143741
  ? getRightHandSideOfAssignment(varDeclarations[0].initializer)
143427
143742
  : undefined;
143428
- return host_1
143429
- ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) }
143743
+ return host_2
143744
+ ? { commentOwner: commentOwner, parameters: host_2.parameters, hasReturn: hasReturn(host_2, options) }
143430
143745
  : { commentOwner: commentOwner };
143431
143746
  }
143432
143747
  case 308 /* SyntaxKind.SourceFile */:
@@ -143456,7 +143771,7 @@ var ts;
143456
143771
  }
143457
143772
  function hasReturn(node, options) {
143458
143773
  return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) &&
143459
- (ts.isArrowFunction(node) && ts.isExpression(node.body)
143774
+ (ts.isFunctionTypeNode(node) || ts.isArrowFunction(node) && ts.isExpression(node.body)
143460
143775
  || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }));
143461
143776
  }
143462
143777
  function getRightHandSideOfAssignment(rightHandSide) {
@@ -144497,23 +144812,39 @@ var ts;
144497
144812
  * 2) Coalescing imports from the same module
144498
144813
  * 3) Sorting imports
144499
144814
  */
144500
- function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) {
144815
+ function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
144501
144816
  var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
144502
- var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
144817
+ var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
144818
+ var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
144819
+ var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
144820
+ var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
144821
+ var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
144822
+ var processImportsOfSameModuleSpecifier = function (importGroup) {
144823
+ var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
144824
+ return shouldSort
144825
+ ? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
144826
+ : processedDeclarations;
144827
+ };
144503
144828
  // All of the old ImportDeclarations in the file, in syntactic order.
144504
144829
  var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
144505
- topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144506
- // All of the old ExportDeclarations in the file, in syntactic order.
144507
- var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
144508
- organizeImportsWorker(topLevelExportDecls, coalesceExports);
144830
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
144831
+ // Exports are always used
144832
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
144833
+ // All of the old ExportDeclarations in the file, in syntactic order.
144834
+ var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
144835
+ organizeImportsWorker(topLevelExportDecls, coalesceExports);
144836
+ }
144509
144837
  for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
144510
144838
  var ambientModule = _a[_i];
144511
144839
  if (!ambientModule.body)
144512
144840
  continue;
144513
144841
  var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
144514
- ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144515
- var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
144516
- organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
144842
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
144843
+ // Exports are always used
144844
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
144845
+ var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
144846
+ organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
144847
+ }
144517
144848
  }
144518
144849
  return changeTracker.getChanges();
144519
144850
  function organizeImportsWorker(oldImportDecls, coalesce) {
@@ -144526,8 +144857,12 @@ var ts;
144526
144857
  // Consider: we could do a more careful check that this trivia is actually a header,
144527
144858
  // but the consequences of being wrong are very minor.
144528
144859
  ts.suppressLeadingTrivia(oldImportDecls[0]);
144529
- var oldImportGroups = ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); });
144530
- var sortedImportGroups = ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); });
144860
+ var oldImportGroups = shouldCombine
144861
+ ? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
144862
+ : [oldImportDecls];
144863
+ var sortedImportGroups = shouldSort
144864
+ ? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
144865
+ : oldImportGroups;
144531
144866
  var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
144532
144867
  return getExternalModuleName(importGroup[0].moduleSpecifier)
144533
144868
  ? coalesce(importGroup)
@@ -144591,11 +144926,7 @@ var ts;
144591
144926
  }
144592
144927
  return false;
144593
144928
  }
144594
- function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
144595
- // As a precaution, consider unused import detection to be destructive (GH #43051)
144596
- if (skipDestructiveCodeActions) {
144597
- return oldImports;
144598
- }
144929
+ function removeUnusedImports(oldImports, sourceFile, program) {
144599
144930
  var typeChecker = program.getTypeChecker();
144600
144931
  var compilerOptions = program.getCompilerOptions();
144601
144932
  var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
@@ -145451,7 +145782,7 @@ var ts;
145451
145782
  return bestMatch;
145452
145783
  }
145453
145784
  function betterMatch(a, b) {
145454
- return ts.min(a, b, compareMatches);
145785
+ return ts.min([a, b], compareMatches);
145455
145786
  }
145456
145787
  function compareMatches(a, b) {
145457
145788
  return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
@@ -146060,8 +146391,8 @@ var ts;
146060
146391
  }
146061
146392
  if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
146062
146393
  var stack = [ts.scanner.getToken()];
146063
- var token = ts.scanner.scan();
146064
146394
  loop: while (ts.length(stack)) {
146395
+ var token = ts.scanner.scan();
146065
146396
  switch (token) {
146066
146397
  case 1 /* SyntaxKind.EndOfFileToken */:
146067
146398
  break loop;
@@ -146089,7 +146420,6 @@ var ts;
146089
146420
  }
146090
146421
  break;
146091
146422
  }
146092
- token = ts.scanner.scan();
146093
146423
  }
146094
146424
  nextToken();
146095
146425
  }
@@ -148568,7 +148898,7 @@ var ts;
148568
148898
  tags = signature.getJsDocTags();
148569
148899
  if (allSignatures.length > 1 && documentation.length === 0 && tags.length === 0) {
148570
148900
  documentation = allSignatures[0].getDocumentationComment(typeChecker);
148571
- tags = allSignatures[0].getJsDocTags();
148901
+ tags = allSignatures[0].getJsDocTags().filter(function (tag) { return tag.name !== "deprecated"; }); // should only include @deprecated JSDoc tag on the first overload (#49368)
148572
148902
  }
148573
148903
  }
148574
148904
  function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
@@ -148911,7 +149241,7 @@ var ts;
148911
149241
  return false;
148912
149242
  }
148913
149243
  function shouldRescanJsxText(node) {
148914
- return ts.isJsxText(node);
149244
+ return ts.isJsxText(node) || ts.isJsxElement(node) && (lastTokenInfo === null || lastTokenInfo === void 0 ? void 0 : lastTokenInfo.token.kind) === 11 /* SyntaxKind.JsxText */;
148915
149245
  }
148916
149246
  function shouldRescanSlashToken(container) {
148917
149247
  return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
@@ -149680,10 +150010,10 @@ var ts;
149680
150010
  !nodeIsInDecoratorContext(context.nextTokenParent);
149681
150011
  }
149682
150012
  function nodeIsInDecoratorContext(node) {
149683
- while (ts.isExpressionNode(node)) {
150013
+ while (node && ts.isExpression(node)) {
149684
150014
  node = node.parent;
149685
150015
  }
149686
- return node.kind === 167 /* SyntaxKind.Decorator */;
150016
+ return node && node.kind === 167 /* SyntaxKind.Decorator */;
149687
150017
  }
149688
150018
  function isStartOfVariableDeclarationList(context) {
149689
150019
  return context.currentTokenParent.kind === 258 /* SyntaxKind.VariableDeclarationList */ &&
@@ -152601,6 +152931,26 @@ var ts;
152601
152931
  function startPositionToDeleteNodeInList(sourceFile, node) {
152602
152932
  return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
152603
152933
  }
152934
+ function endPositionToDeleteNodeInList(sourceFile, node, prevNode, nextNode) {
152935
+ var end = startPositionToDeleteNodeInList(sourceFile, nextNode);
152936
+ if (prevNode === undefined || ts.positionsAreOnSameLine(getAdjustedEndPosition(sourceFile, node, {}), end, sourceFile)) {
152937
+ return end;
152938
+ }
152939
+ var token = ts.findPrecedingToken(nextNode.getStart(sourceFile), sourceFile);
152940
+ if (isSeparator(node, token)) {
152941
+ var prevToken = ts.findPrecedingToken(node.getStart(sourceFile), sourceFile);
152942
+ if (isSeparator(prevNode, prevToken)) {
152943
+ var pos = ts.skipTrivia(sourceFile.text, token.getEnd(), /*stopAfterLineBreak*/ true, /*stopAtComments*/ true);
152944
+ if (ts.positionsAreOnSameLine(prevToken.getStart(sourceFile), token.getStart(sourceFile), sourceFile)) {
152945
+ return ts.isLineBreak(sourceFile.text.charCodeAt(pos - 1)) ? pos - 1 : pos;
152946
+ }
152947
+ if (ts.isLineBreak(sourceFile.text.charCodeAt(pos))) {
152948
+ return pos;
152949
+ }
152950
+ }
152951
+ }
152952
+ return end;
152953
+ }
152604
152954
  function getClassOrObjectBraceEnds(cls, sourceFile) {
152605
152955
  var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
152606
152956
  var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
@@ -153158,7 +153508,7 @@ var ts;
153158
153508
  deletedNodesInLists.add(node);
153159
153509
  changes.deleteRange(sourceFile, {
153160
153510
  pos: startPositionToDeleteNodeInList(sourceFile, node),
153161
- end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
153511
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : endPositionToDeleteNodeInList(sourceFile, node, containingList[index - 1], containingList[index + 1]),
153162
153512
  });
153163
153513
  }
153164
153514
  })(textChanges = ts.textChanges || (ts.textChanges = {}));
@@ -153628,6 +153978,15 @@ var ts;
153628
153978
  });
153629
153979
  }
153630
153980
  function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
153981
+ if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
153982
+ var exprType = checker.getTypeAtLocation(insertionSite);
153983
+ var asyncIter = checker.getAsyncIterableType();
153984
+ if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
153985
+ var forOf = insertionSite.parent;
153986
+ changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
153987
+ return;
153988
+ }
153989
+ }
153631
153990
  if (ts.isBinaryExpression(insertionSite)) {
153632
153991
  for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
153633
153992
  var side = _a[_i];
@@ -157353,6 +157712,143 @@ var ts;
157353
157712
  })(ts || (ts = {}));
157354
157713
  /* @internal */
157355
157714
  var ts;
157715
+ (function (ts) {
157716
+ var codefix;
157717
+ (function (codefix) {
157718
+ var fixId = "fixImportNonExportedMember";
157719
+ var errorCodes = [
157720
+ ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
157721
+ ];
157722
+ codefix.registerCodeFix({
157723
+ errorCodes: errorCodes,
157724
+ fixIds: [fixId],
157725
+ getCodeActions: function (context) {
157726
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
157727
+ var info = getInfo(sourceFile, span.start, program);
157728
+ if (info === undefined)
157729
+ return undefined;
157730
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
157731
+ 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)];
157732
+ },
157733
+ getAllCodeActions: function (context) {
157734
+ var program = context.program;
157735
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
157736
+ var exports = new ts.Map();
157737
+ codefix.eachDiagnostic(context, errorCodes, function (diag) {
157738
+ var info = getInfo(diag.file, diag.start, program);
157739
+ if (info === undefined)
157740
+ return undefined;
157741
+ var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
157742
+ if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
157743
+ changes.insertExportModifier(moduleSourceFile, node);
157744
+ }
157745
+ else {
157746
+ var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
157747
+ if (exportName.isTypeOnly) {
157748
+ moduleExports.typeOnlyExports.push(exportName);
157749
+ }
157750
+ else {
157751
+ moduleExports.exports.push(exportName);
157752
+ }
157753
+ exports.set(moduleSourceFile, moduleExports);
157754
+ }
157755
+ });
157756
+ exports.forEach(function (moduleExports, moduleSourceFile) {
157757
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
157758
+ if (exportDeclaration && exportDeclaration.isTypeOnly) {
157759
+ doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
157760
+ doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
157761
+ }
157762
+ else {
157763
+ doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
157764
+ }
157765
+ });
157766
+ }));
157767
+ }
157768
+ });
157769
+ function getInfo(sourceFile, pos, program) {
157770
+ var _a;
157771
+ var token = ts.getTokenAtPosition(sourceFile, pos);
157772
+ if (ts.isIdentifier(token)) {
157773
+ var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
157774
+ if (importDeclaration === undefined)
157775
+ return undefined;
157776
+ var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
157777
+ if (moduleSpecifier === undefined)
157778
+ return undefined;
157779
+ var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
157780
+ if (resolvedModule === undefined)
157781
+ return undefined;
157782
+ var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
157783
+ if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
157784
+ return undefined;
157785
+ var moduleSymbol = moduleSourceFile.symbol;
157786
+ var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
157787
+ if (locals === undefined)
157788
+ return undefined;
157789
+ var localSymbol = locals.get(token.escapedText);
157790
+ if (localSymbol === undefined)
157791
+ return undefined;
157792
+ var node = getNodeOfSymbol(localSymbol);
157793
+ if (node === undefined)
157794
+ return undefined;
157795
+ var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
157796
+ return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
157797
+ }
157798
+ return undefined;
157799
+ }
157800
+ function doChange(changes, program, _a) {
157801
+ var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
157802
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
157803
+ if (exportDeclaration) {
157804
+ updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
157805
+ }
157806
+ else if (ts.canHaveExportModifier(node)) {
157807
+ changes.insertExportModifier(moduleSourceFile, node);
157808
+ }
157809
+ else {
157810
+ createExport(changes, program, moduleSourceFile, [exportName]);
157811
+ }
157812
+ }
157813
+ function doChanges(changes, program, sourceFile, moduleExports, node) {
157814
+ if (ts.length(moduleExports)) {
157815
+ if (node) {
157816
+ updateExport(changes, program, sourceFile, node, moduleExports);
157817
+ }
157818
+ else {
157819
+ createExport(changes, program, sourceFile, moduleExports);
157820
+ }
157821
+ }
157822
+ }
157823
+ function tryGetExportDeclaration(sourceFile, isTypeOnly) {
157824
+ var predicate = function (node) {
157825
+ return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
157826
+ };
157827
+ return ts.findLast(sourceFile.statements, predicate);
157828
+ }
157829
+ function updateExport(changes, program, sourceFile, node, names) {
157830
+ var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
157831
+ var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
157832
+ 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));
157833
+ }
157834
+ function createExport(changes, program, sourceFile, names) {
157835
+ changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
157836
+ }
157837
+ function createExportSpecifiers(names, allowTypeModifier) {
157838
+ return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
157839
+ }
157840
+ function getNodeOfSymbol(symbol) {
157841
+ if (symbol.valueDeclaration === undefined) {
157842
+ return ts.firstOrUndefined(symbol.declarations);
157843
+ }
157844
+ var declaration = symbol.valueDeclaration;
157845
+ var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
157846
+ return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
157847
+ }
157848
+ })(codefix = ts.codefix || (ts.codefix = {}));
157849
+ })(ts || (ts = {}));
157850
+ /* @internal */
157851
+ var ts;
157356
157852
  (function (ts) {
157357
157853
  var codefix;
157358
157854
  (function (codefix) {
@@ -157883,7 +158379,7 @@ var ts;
157883
158379
  var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
157884
158380
  if (argIndex < 0)
157885
158381
  return undefined;
157886
- var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */));
158382
+ var signature = checker.getResolvedSignature(parent.parent);
157887
158383
  if (!(signature && signature.declaration && signature.parameters[argIndex]))
157888
158384
  return undefined;
157889
158385
  var param = signature.parameters[argIndex].valueDeclaration;
@@ -157930,13 +158426,13 @@ var ts;
157930
158426
  if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
157931
158427
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
157932
158428
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
157933
- if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
158429
+ if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
157934
158430
  return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
157935
158431
  }
157936
158432
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
157937
158433
  if (sourceFile.commonJsModuleIndicator)
157938
158434
  return undefined;
157939
- if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
158435
+ if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
157940
158436
  return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
157941
158437
  }
157942
158438
  }
@@ -157946,7 +158442,7 @@ var ts;
157946
158442
  return undefined;
157947
158443
  // Prefer to change the class instead of the interface if they are merged
157948
158444
  var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
157949
- if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
158445
+ if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
157950
158446
  var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
157951
158447
  if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
157952
158448
  return undefined;
@@ -157958,14 +158454,11 @@ var ts;
157958
158454
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
157959
158455
  }
157960
158456
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
157961
- if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158457
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
157962
158458
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
157963
158459
  }
157964
158460
  return undefined;
157965
158461
  }
157966
- function isSourceFileFromLibrary(program, node) {
157967
- return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
157968
- }
157969
158462
  function getActionsForMissingMemberDeclaration(context, info) {
157970
158463
  return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
157971
158464
  createActionsForAddMissingMemberInTypeScriptFile(context, info);
@@ -163391,8 +163884,8 @@ var ts;
163391
163884
  var i = 0;
163392
163885
  for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
163393
163886
  var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
163394
- var description = functionExtraction.description;
163395
163887
  if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
163888
+ var description = functionExtraction.description;
163396
163889
  if (functionExtraction.errors.length === 0) {
163397
163890
  // Don't issue refactorings with duplicated names.
163398
163891
  // Scopes come back in "innermost first" order, so extractions will
@@ -163416,15 +163909,15 @@ var ts;
163416
163909
  }
163417
163910
  }
163418
163911
  if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
163912
+ var description = constantExtraction.description;
163419
163913
  if (constantExtraction.errors.length === 0) {
163420
163914
  // Don't issue refactorings with duplicated names.
163421
163915
  // Scopes come back in "innermost first" order, so extractions will
163422
163916
  // preferentially go into nearer scopes
163423
- var description_1 = constantExtraction.description;
163424
- if (!usedConstantNames.has(description_1)) {
163425
- usedConstantNames.set(description_1, true);
163917
+ if (!usedConstantNames.has(description)) {
163918
+ usedConstantNames.set(description, true);
163426
163919
  constantActions.push({
163427
- description: description_1,
163920
+ description: description,
163428
163921
  name: "constant_scope_".concat(i),
163429
163922
  kind: extractConstantAction.kind
163430
163923
  });
@@ -163569,7 +164062,6 @@ var ts;
163569
164062
  var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
163570
164063
  // Do the same for the ending position
163571
164064
  var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
163572
- var declarations = [];
163573
164065
  // We'll modify these flags as we walk the tree to collect data
163574
164066
  // about what things need to be done as part of the extraction.
163575
164067
  var rangeFacts = RangeFacts.None;
@@ -163612,7 +164104,7 @@ var ts;
163612
164104
  // the expression.
163613
164105
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
163614
164106
  }
163615
- return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
164107
+ return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
163616
164108
  }
163617
164109
  if (ts.isReturnStatement(start) && !start.expression) {
163618
164110
  // Makes no sense to extract an expression-less return statement.
@@ -163624,7 +164116,7 @@ var ts;
163624
164116
  if (errors) {
163625
164117
  return { errors: errors };
163626
164118
  }
163627
- return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
164119
+ return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
163628
164120
  /**
163629
164121
  * Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
163630
164122
  * @param node The unrefined extraction node.
@@ -163636,10 +164128,10 @@ var ts;
163636
164128
  }
163637
164129
  }
163638
164130
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
163639
- var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164131
+ var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
163640
164132
  var numInitializers = 0;
163641
164133
  var lastInitializer = void 0;
163642
- for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
164134
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
163643
164135
  var declaration = declarations_5[_i];
163644
164136
  if (declaration.initializer) {
163645
164137
  numInitializers++;
@@ -163739,7 +164231,6 @@ var ts;
163739
164231
  (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
163740
164232
  return true;
163741
164233
  }
163742
- declarations.push(node.symbol);
163743
164234
  }
163744
164235
  // Some things can't be extracted in certain situations
163745
164236
  switch (node.kind) {
@@ -165464,7 +165955,7 @@ var ts;
165464
165955
  function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
165465
165956
  var checker = program.getTypeChecker();
165466
165957
  var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective);
165467
- if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
165958
+ if (oldFile.externalModuleIndicator === undefined && oldFile.commonJsModuleIndicator === undefined && usage.oldImportsNeededByNewFile.size() === 0) {
165468
165959
  deleteMovedStatements(oldFile, toMove.ranges, changes);
165469
165960
  return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
165470
165961
  }
@@ -165705,7 +166196,12 @@ var ts;
165705
166196
  switch (name.kind) {
165706
166197
  case 79 /* SyntaxKind.Identifier */:
165707
166198
  if (isUnused(name)) {
165708
- changes.delete(sourceFile, name);
166199
+ if (varDecl.initializer && ts.isRequireCall(varDecl.initializer, /*requireStringLiteralLikeArgument*/ true)) {
166200
+ changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && ts.length(varDecl.parent.declarations) === 1 ? varDecl.parent.parent : varDecl);
166201
+ }
166202
+ else {
166203
+ changes.delete(sourceFile, name);
166204
+ }
165709
166205
  }
165710
166206
  break;
165711
166207
  case 204 /* SyntaxKind.ArrayBindingPattern */:
@@ -165937,6 +166433,9 @@ var ts;
165937
166433
  ts.copyEntries(this.map, clone.map);
165938
166434
  return clone;
165939
166435
  };
166436
+ SymbolSet.prototype.size = function () {
166437
+ return this.map.size;
166438
+ };
165940
166439
  return SymbolSet;
165941
166440
  }());
165942
166441
  function isTopLevelDeclaration(node) {
@@ -166025,7 +166524,8 @@ var ts;
166025
166524
  if (useEs6Exports) {
166026
166525
  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)));
166027
166526
  }
166028
- return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
166527
+ return !!sourceFile.symbol && !!sourceFile.symbol.exports &&
166528
+ getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
166029
166529
  }
166030
166530
  function addExport(decl, useEs6Exports) {
166031
166531
  return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
@@ -167785,8 +168285,8 @@ var ts;
167785
168285
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
167786
168286
  }
167787
168287
  };
167788
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
167789
- var declaration = declarations_7[_i];
168288
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
168289
+ var declaration = declarations_6[_i];
167790
168290
  _loop_20(declaration);
167791
168291
  }
167792
168292
  }
@@ -167812,8 +168312,8 @@ var ts;
167812
168312
  if (inheritedDocs)
167813
168313
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
167814
168314
  };
167815
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
167816
- var declaration = declarations_8[_i];
168315
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168316
+ var declaration = declarations_7[_i];
167817
168317
  _loop_21(declaration);
167818
168318
  }
167819
168319
  }
@@ -168983,12 +169483,14 @@ var ts;
168983
169483
  return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
168984
169484
  }
168985
169485
  function organizeImports(args, formatOptions, preferences) {
169486
+ var _a;
168986
169487
  if (preferences === void 0) { preferences = ts.emptyOptions; }
168987
169488
  synchronizeHostData();
168988
169489
  ts.Debug.assert(args.type === "file");
168989
169490
  var sourceFile = getValidSourceFile(args.fileName);
168990
169491
  var formatContext = ts.formatting.getFormatContext(formatOptions, host);
168991
- return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions);
169492
+ var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
169493
+ return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
168992
169494
  }
168993
169495
  function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
168994
169496
  if (preferences === void 0) { preferences = ts.emptyOptions; }
@@ -171987,6 +172489,12 @@ var ts;
171987
172489
  CommandTypes["ProvideInlayHints"] = "provideInlayHints";
171988
172490
  // NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
171989
172491
  })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {}));
172492
+ var OrganizeImportsMode;
172493
+ (function (OrganizeImportsMode) {
172494
+ OrganizeImportsMode["All"] = "All";
172495
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
172496
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
172497
+ })(OrganizeImportsMode = protocol.OrganizeImportsMode || (protocol.OrganizeImportsMode = {}));
171990
172498
  var WatchFileKind;
171991
172499
  (function (WatchFileKind) {
171992
172500
  WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
@@ -172873,6 +173381,7 @@ var ts;
172873
173381
  this.watchOptions = watchOptions;
172874
173382
  this.rootFiles = [];
172875
173383
  this.rootFilesMap = new ts.Map();
173384
+ /*@internal*/
172876
173385
  this.plugins = [];
172877
173386
  /*@internal*/
172878
173387
  /**
@@ -173401,6 +173910,7 @@ var ts;
173401
173910
  this.directoryStructureHost = undefined;
173402
173911
  this.exportMapCache = undefined;
173403
173912
  this.projectErrors = undefined;
173913
+ this.plugins.length = 0;
173404
173914
  // Clean up file watchers waiting for missing files
173405
173915
  if (this.missingFilesMap) {
173406
173916
  ts.clearMap(this.missingFilesMap, ts.closeFileWatcher);
@@ -174074,35 +174584,39 @@ var ts;
174074
174584
  Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) {
174075
174585
  return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
174076
174586
  };
174587
+ /*@internal*/
174588
+ Project.prototype.getGlobalPluginSearchPaths = function () {
174589
+ // Search any globally-specified probe paths, then our peer node_modules
174590
+ return __spreadArray(__spreadArray([], this.projectService.pluginProbeLocations, true), [
174591
+ // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174592
+ ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
174593
+ ], false);
174594
+ };
174077
174595
  Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
174596
+ if (!this.projectService.globalPlugins.length)
174597
+ return;
174078
174598
  var host = this.projectService.host;
174079
174599
  if (!host.require && !host.importPlugin) {
174080
174600
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
174081
174601
  return;
174082
174602
  }
174083
- // Search any globally-specified probe paths, then our peer node_modules
174084
- var searchPaths = __spreadArray(__spreadArray([], this.projectService.pluginProbeLocations, true), [
174085
- // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174086
- ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
174087
- ], false);
174088
- if (this.projectService.globalPlugins) {
174089
- var _loop_1 = function (globalPluginName) {
174090
- // Skip empty names from odd commandline parses
174091
- if (!globalPluginName)
174092
- return "continue";
174093
- // Skip already-locally-loaded plugins
174094
- if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; }))
174095
- return "continue";
174096
- // Provide global: true so plugins can detect why they can't find their config
174097
- this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName));
174098
- this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides);
174099
- };
174100
- var this_1 = this;
174101
- // Enable global plugins with synthetic configuration entries
174102
- for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
174103
- var globalPluginName = _a[_i];
174104
- _loop_1(globalPluginName);
174105
- }
174603
+ // Enable global plugins with synthetic configuration entries
174604
+ var searchPaths = this.getGlobalPluginSearchPaths();
174605
+ var _loop_1 = function (globalPluginName) {
174606
+ // Skip empty names from odd commandline parses
174607
+ if (!globalPluginName)
174608
+ return "continue";
174609
+ // Skip already-locally-loaded plugins
174610
+ if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; }))
174611
+ return "continue";
174612
+ // Provide global: true so plugins can detect why they can't find their config
174613
+ this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName));
174614
+ this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides);
174615
+ };
174616
+ var this_1 = this;
174617
+ for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
174618
+ var globalPluginName = _a[_i];
174619
+ _loop_1(globalPluginName);
174106
174620
  }
174107
174621
  };
174108
174622
  /**
@@ -174833,14 +175347,16 @@ var ts;
174833
175347
  };
174834
175348
  /*@internal*/
174835
175349
  ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
175350
+ var _a;
175351
+ this.plugins.length = 0;
175352
+ if (!((_a = options.plugins) === null || _a === void 0 ? void 0 : _a.length) && !this.projectService.globalPlugins.length)
175353
+ return;
174836
175354
  var host = this.projectService.host;
174837
175355
  if (!host.require && !host.importPlugin) {
174838
175356
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
174839
175357
  return;
174840
175358
  }
174841
- // Search our peer node_modules, then any globally-specified probe paths
174842
- // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174843
- var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true);
175359
+ var searchPaths = this.getGlobalPluginSearchPaths();
174844
175360
  if (this.projectService.allowLocalPluginLoads) {
174845
175361
  var local = ts.getDirectoryPath(this.canonicalConfigFilePath);
174846
175362
  this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths"));
@@ -174848,8 +175364,8 @@ var ts;
174848
175364
  }
174849
175365
  // Enable tsconfig-specified plugins
174850
175366
  if (options.plugins) {
174851
- for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) {
174852
- var pluginConfigEntry = _a[_i];
175367
+ for (var _i = 0, _b = options.plugins; _i < _b.length; _i++) {
175368
+ var pluginConfigEntry = _b[_i];
174853
175369
  this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
174854
175370
  }
174855
175371
  }
@@ -175694,18 +176210,20 @@ var ts;
175694
176210
  return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName);
175695
176211
  };
175696
176212
  /* @internal */
175697
- ProjectService.prototype.tryGetDefaultProjectForFile = function (fileName) {
175698
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
176213
+ ProjectService.prototype.tryGetDefaultProjectForFile = function (fileNameOrScriptInfo) {
176214
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
175699
176215
  return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined;
175700
176216
  };
175701
176217
  /* @internal */
175702
- ProjectService.prototype.ensureDefaultProjectForFile = function (fileName) {
175703
- return this.tryGetDefaultProjectForFile(fileName) || this.doEnsureDefaultProjectForFile(fileName);
176218
+ ProjectService.prototype.ensureDefaultProjectForFile = function (fileNameOrScriptInfo) {
176219
+ return this.tryGetDefaultProjectForFile(fileNameOrScriptInfo) || this.doEnsureDefaultProjectForFile(fileNameOrScriptInfo);
175704
176220
  };
175705
- ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) {
176221
+ ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileNameOrScriptInfo) {
175706
176222
  this.ensureProjectStructuresUptoDate();
175707
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
175708
- return scriptInfo ? scriptInfo.getDefaultProject() : (this.logErrorForScriptInfoNotFound(fileName), server.Errors.ThrowNoProject());
176223
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
176224
+ return scriptInfo ?
176225
+ scriptInfo.getDefaultProject() :
176226
+ (this.logErrorForScriptInfoNotFound(ts.isString(fileNameOrScriptInfo) ? fileNameOrScriptInfo : fileNameOrScriptInfo.fileName), server.Errors.ThrowNoProject());
175709
176227
  };
175710
176228
  ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) {
175711
176229
  this.ensureProjectStructuresUptoDate();
@@ -177877,7 +178395,7 @@ var ts;
177877
178395
  if (this.serverMode !== ts.LanguageServiceMode.Semantic || !this.eventHandler || !scriptInfo.isJavaScript() || !ts.addToSeen(this.allJsFilesForOpenFileTelemetry, scriptInfo.path)) {
177878
178396
  return;
177879
178397
  }
177880
- var project = scriptInfo.getDefaultProject();
178398
+ var project = this.ensureDefaultProjectForFile(scriptInfo);
177881
178399
  if (!project.languageServiceEnabled) {
177882
178400
  return;
177883
178401
  }
@@ -180477,6 +180995,10 @@ var ts;
180477
180995
  this.projectService.logErrorForScriptInfoNotFound(args.file);
180478
180996
  return server.Errors.ThrowNoProject();
180479
180997
  }
180998
+ else if (!getScriptInfoEnsuringProjectsUptoDate) {
180999
+ // Ensure there are containing projects are present
181000
+ this.projectService.ensureDefaultProjectForFile(scriptInfo);
181001
+ }
180480
181002
  projects = scriptInfo.containingProjects;
180481
181003
  symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo);
180482
181004
  }
@@ -180545,6 +181067,7 @@ var ts;
180545
181067
  var references = getReferencesWorker(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
180546
181068
  if (!simplifiedResult)
180547
181069
  return references;
181070
+ var preferences = this.getPreferences(file);
180548
181071
  var defaultProject = this.getDefaultProject(args);
180549
181072
  var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file);
180550
181073
  var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position);
@@ -180553,7 +181076,7 @@ var ts;
180553
181076
  var symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0;
180554
181077
  var symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)) : "";
180555
181078
  var refs = ts.flatMap(references, function (referencedSymbol) {
180556
- return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
181079
+ return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
180557
181080
  });
180558
181081
  return { refs: refs, symbolName: symbolName, symbolStartOffset: symbolStartOffset, symbolDisplayString: symbolDisplayString };
180559
181082
  };
@@ -180561,6 +181084,7 @@ var ts;
180561
181084
  var _this = this;
180562
181085
  var projects = this.getProjects(args);
180563
181086
  var fileName = args.file;
181087
+ var preferences = this.getPreferences(server.toNormalizedPath(fileName));
180564
181088
  var references = [];
180565
181089
  var seen = createDocumentSpanSet();
180566
181090
  forEachProjectInProjects(projects, /*path*/ undefined, function (project) {
@@ -180579,7 +181103,7 @@ var ts;
180579
181103
  });
180580
181104
  if (!simplifiedResult)
180581
181105
  return references;
180582
- var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
181106
+ var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
180583
181107
  return {
180584
181108
  refs: refs,
180585
181109
  symbolName: "\"".concat(args.file, "\"")
@@ -180603,13 +181127,7 @@ var ts;
180603
181127
  return this.getFileAndProjectWorker(args.file, args.projectFileName);
180604
181128
  };
180605
181129
  Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) {
180606
- // Since this is syntactic operation, there should always be project for the file
180607
- // throw if we dont get project
180608
- var file = server.toNormalizedPath(args.file);
180609
- var project = this.getProject(args.projectFileName) || this.projectService.ensureDefaultProjectForFile(file);
180610
- if (!project) {
180611
- return server.Errors.ThrowNoProject();
180612
- }
181130
+ var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
180613
181131
  return {
180614
181132
  file: file,
180615
181133
  languageService: project.getLanguageService(/*ensureSynchronized*/ false)
@@ -181150,11 +181668,12 @@ var ts;
181150
181668
  }
181151
181669
  };
181152
181670
  Session.prototype.organizeImports = function (args, simplifiedResult) {
181671
+ var _a;
181153
181672
  ts.Debug.assert(args.scope.type === "file");
181154
- var _a = this.getFileAndProject(args.scope.args), file = _a.file, project = _a.project;
181673
+ var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
181155
181674
  var changes = project.getLanguageService().organizeImports({
181156
181675
  fileName: file,
181157
- skipDestructiveCodeActions: args.skipDestructiveCodeActions,
181676
+ mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
181158
181677
  type: "file",
181159
181678
  }, this.getFormatOptions(file), this.getPreferences(file));
181160
181679
  if (simplifiedResult) {
@@ -181648,14 +182167,18 @@ var ts;
181648
182167
  }
181649
182168
  return text;
181650
182169
  }
181651
- function referenceEntryToReferencesResponseItem(projectService, _a) {
182170
+ function referenceEntryToReferencesResponseItem(projectService, _a, _b) {
181652
182171
  var fileName = _a.fileName, textSpan = _a.textSpan, contextSpan = _a.contextSpan, isWriteAccess = _a.isWriteAccess, isDefinition = _a.isDefinition;
182172
+ var disableLineTextInReferences = _b.disableLineTextInReferences;
181653
182173
  var scriptInfo = ts.Debug.checkDefined(projectService.getScriptInfo(fileName));
181654
182174
  var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo);
181655
- var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1);
181656
- var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
182175
+ var lineText = disableLineTextInReferences ? undefined : getLineText(scriptInfo, span);
181657
182176
  return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition });
181658
182177
  }
182178
+ function getLineText(scriptInfo, span) {
182179
+ var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1);
182180
+ return scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
182181
+ }
181659
182182
  function isCompletionEntryData(data) {
181660
182183
  return data === undefined || data && typeof data === "object"
181661
182184
  && typeof data.exportName === "string"
@@ -185695,6 +186218,9 @@ var ts;
185695
186218
  process.on("message", function (e) {
185696
186219
  _this.onMessage(e);
185697
186220
  });
186221
+ process.on("disconnect", function () {
186222
+ _this.exit();
186223
+ });
185698
186224
  };
185699
186225
  return IpcIOSession;
185700
186226
  }(IOSession));