typescript 4.9.1-beta → 4.9.3

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.
@@ -44,7 +44,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
44
44
  function verb(n) { return function (v) { return step([n, v]); }; }
45
45
  function step(op) {
46
46
  if (f) throw new TypeError("Generator is already executing.");
47
- while (_) try {
47
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
48
48
  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;
49
49
  if (y = 0, t) op = [op[0] & 2, t.value];
50
50
  switch (op[0]) {
@@ -108,7 +108,7 @@ var ts;
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = "".concat(ts.versionMajorMinor, ".1-beta");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".3");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -1900,8 +1900,8 @@ var ts;
1900
1900
  return compareValues(a === null || a === void 0 ? void 0 : a.start, b === null || b === void 0 ? void 0 : b.start) || compareValues(a === null || a === void 0 ? void 0 : a.length, b === null || b === void 0 ? void 0 : b.length);
1901
1901
  }
1902
1902
  ts.compareTextSpans = compareTextSpans;
1903
- function min(a, b, compare) {
1904
- return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b;
1903
+ function min(items, compare) {
1904
+ return reduceLeft(items, function (x, y) { return compare(x, y) === -1 /* Comparison.LessThan */ ? x : y; });
1905
1905
  }
1906
1906
  ts.min = min;
1907
1907
  /**
@@ -3214,11 +3214,13 @@ var ts;
3214
3214
  // > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
3215
3215
  // > MUST NOT include leading zeroes.
3216
3216
  var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
3217
+ var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
3217
3218
  // https://semver.org/#spec-item-10
3218
3219
  // > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
3219
3220
  // > identifiers immediately following the patch or pre-release version. Identifiers MUST
3220
3221
  // > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
3221
3222
  var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
3223
+ var buildPartRegExp = /^[a-z0-9-]+$/i;
3222
3224
  // https://semver.org/#spec-item-9
3223
3225
  // > Numeric identifiers MUST NOT include leading zeroes.
3224
3226
  var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
@@ -3238,13 +3240,15 @@ var ts;
3238
3240
  ts.Debug.assert(major >= 0, "Invalid argument: major");
3239
3241
  ts.Debug.assert(minor >= 0, "Invalid argument: minor");
3240
3242
  ts.Debug.assert(patch >= 0, "Invalid argument: patch");
3241
- ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
3242
- ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
3243
+ var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
3244
+ var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
3245
+ ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
3246
+ ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
3243
3247
  this.major = major;
3244
3248
  this.minor = minor;
3245
3249
  this.patch = patch;
3246
- this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
3247
- this.build = build ? build.split(".") : ts.emptyArray;
3250
+ this.prerelease = prereleaseArray;
3251
+ this.build = buildArray;
3248
3252
  }
3249
3253
  Version.tryParse = function (text) {
3250
3254
  var result = tryParseComponents(text);
@@ -3283,6 +3287,10 @@ var ts;
3283
3287
  default: return ts.Debug.assertNever(field);
3284
3288
  }
3285
3289
  };
3290
+ Version.prototype.with = function (fields) {
3291
+ var _a = fields.major, major = _a === void 0 ? this.major : _a, _b = fields.minor, minor = _b === void 0 ? this.minor : _b, _c = fields.patch, patch = _c === void 0 ? this.patch : _c, _d = fields.prerelease, prerelease = _d === void 0 ? this.prerelease : _d, _e = fields.build, build = _e === void 0 ? this.build : _e;
3292
+ return new Version(major, minor, patch, prerelease, build);
3293
+ };
3286
3294
  Version.prototype.toString = function () {
3287
3295
  var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
3288
3296
  if (ts.some(this.prerelease))
@@ -3291,7 +3299,7 @@ var ts;
3291
3299
  result += "+".concat(this.build.join("."));
3292
3300
  return result;
3293
3301
  };
3294
- Version.zero = new Version(0, 0, 0);
3302
+ Version.zero = new Version(0, 0, 0, ["0"]);
3295
3303
  return Version;
3296
3304
  }());
3297
3305
  ts.Version = Version;
@@ -3374,6 +3382,10 @@ var ts;
3374
3382
  }
3375
3383
  return undefined;
3376
3384
  };
3385
+ /**
3386
+ * Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
3387
+ * in `node-semver`.
3388
+ */
3377
3389
  VersionRange.prototype.test = function (version) {
3378
3390
  if (typeof version === "string")
3379
3391
  version = new Version(version);
@@ -3484,19 +3496,20 @@ var ts;
3484
3496
  break;
3485
3497
  case "<":
3486
3498
  case ">=":
3487
- comparators.push(createComparator(operator, version));
3499
+ comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
3500
+ createComparator(operator, version));
3488
3501
  break;
3489
3502
  case "<=":
3490
3503
  case ">":
3491
- comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
3492
- isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
3504
+ comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
3505
+ isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
3493
3506
  createComparator(operator, version));
3494
3507
  break;
3495
3508
  case "=":
3496
3509
  case undefined:
3497
3510
  if (isWildcard(minor) || isWildcard(patch)) {
3498
- comparators.push(createComparator(">=", version));
3499
- comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
3511
+ comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
3512
+ comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
3500
3513
  }
3501
3514
  else {
3502
3515
  comparators.push(createComparator("=", version));
@@ -5105,8 +5118,8 @@ var ts;
5105
5118
  NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
5106
5119
  NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
5107
5120
  NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
5108
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper";
5109
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding";
5121
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAccessInAsync"] = 2048] = "MethodWithSuperPropertyAccessInAsync";
5122
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAssignmentInAsync"] = 4096] = "MethodWithSuperPropertyAssignmentInAsync";
5110
5123
  NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
5111
5124
  NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
5112
5125
  NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
@@ -6741,7 +6754,7 @@ var ts;
6741
6754
  }
6742
6755
  /*@internal*/
6743
6756
  function createSystemWatchFunctions(_a) {
6744
- var pollingWatchFileWorker = _a.pollingWatchFileWorker, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
6757
+ var pollingWatchFileWorker = _a.pollingWatchFileWorker, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
6745
6758
  var pollingWatches = new ts.Map();
6746
6759
  var fsWatches = new ts.Map();
6747
6760
  var fsWatchesRecursive = new ts.Map();
@@ -6807,8 +6820,8 @@ var ts;
6807
6820
  return useNonPollingWatchers ?
6808
6821
  // Use notifications from FS to watch with falling back to fs.watchFile
6809
6822
  generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
6810
- // Default to do not use fixed polling interval
6811
- { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.UseFsEvents };
6823
+ // Default to using fs events
6824
+ { watchFile: ts.WatchFileKind.UseFsEvents };
6812
6825
  }
6813
6826
  }
6814
6827
  function generateWatchFileOptions(watchFile, fallbackPolling, options) {
@@ -7080,7 +7093,6 @@ var ts;
7080
7093
  tscWatchFile: process.env.TSC_WATCHFILE,
7081
7094
  useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
7082
7095
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
7083
- defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7084
7096
  inodeWatching: isLinuxOrMacOs,
7085
7097
  sysLog: sysLog,
7086
7098
  }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
@@ -9591,6 +9603,10 @@ var ts;
9591
9603
  Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"),
9592
9604
  Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"),
9593
9605
  Project_0_is_out_of_date_because_there_was_error_reading_file_1: diag(6401, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_there_was_error_reading_file_1_6401", "Project '{0}' is out of date because there was error reading file '{1}'"),
9606
+ Resolving_in_0_mode_with_conditions_1: diag(6402, ts.DiagnosticCategory.Message, "Resolving_in_0_mode_with_conditions_1_6402", "Resolving in {0} mode with conditions {1}."),
9607
+ Matched_0_condition_1: diag(6403, ts.DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."),
9608
+ Using_0_subpath_1_with_target_2: diag(6404, ts.DiagnosticCategory.Message, "Using_0_subpath_1_with_target_2_6404", "Using '{0}' subpath '{1}' with target '{2}'."),
9609
+ Saw_non_matching_condition_0: diag(6405, ts.DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
9594
9610
  The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
9595
9611
  The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
9596
9612
  The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
@@ -9907,6 +9923,8 @@ var ts;
9907
9923
  Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
9908
9924
  Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
9909
9925
  Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
9926
+ Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
9927
+ Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
9910
9928
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9911
9929
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9912
9930
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -11364,7 +11382,7 @@ var ts;
11364
11382
  return -1;
11365
11383
  }
11366
11384
  function peekExtendedUnicodeEscape() {
11367
- if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11385
+ if (codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11368
11386
  var start_2 = pos;
11369
11387
  pos += 3;
11370
11388
  var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
@@ -21667,6 +21685,32 @@ var ts;
21667
21685
  return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21668
21686
  }
21669
21687
  ts.getParameterTypeNode = getParameterTypeNode;
21688
+ function isTypeDeclaration(node) {
21689
+ switch (node.kind) {
21690
+ case 165 /* SyntaxKind.TypeParameter */:
21691
+ case 260 /* SyntaxKind.ClassDeclaration */:
21692
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
21693
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
21694
+ case 263 /* SyntaxKind.EnumDeclaration */:
21695
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
21696
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
21697
+ case 342 /* SyntaxKind.JSDocEnumTag */:
21698
+ return true;
21699
+ case 270 /* SyntaxKind.ImportClause */:
21700
+ return node.isTypeOnly;
21701
+ case 273 /* SyntaxKind.ImportSpecifier */:
21702
+ case 278 /* SyntaxKind.ExportSpecifier */:
21703
+ return node.parent.parent.isTypeOnly;
21704
+ default:
21705
+ return false;
21706
+ }
21707
+ }
21708
+ ts.isTypeDeclaration = isTypeDeclaration;
21709
+ function canHaveExportModifier(node) {
21710
+ return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
21711
+ || ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
21712
+ }
21713
+ ts.canHaveExportModifier = canHaveExportModifier;
21670
21714
  })(ts || (ts = {}));
21671
21715
  /* @internal */
21672
21716
  var ts;
@@ -21675,13 +21719,11 @@ var ts;
21675
21719
  * Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
21676
21720
  */
21677
21721
  function createBaseNodeFactory() {
21678
- // tslint:disable variable-name
21679
21722
  var NodeConstructor;
21680
21723
  var TokenConstructor;
21681
21724
  var IdentifierConstructor;
21682
21725
  var PrivateIdentifierConstructor;
21683
21726
  var SourceFileConstructor;
21684
- // tslint:enable variable-name
21685
21727
  return {
21686
21728
  createBaseSourceFileNode: createBaseSourceFileNode,
21687
21729
  createBaseIdentifierNode: createBaseIdentifierNode,
@@ -23145,7 +23187,7 @@ var ts;
23145
23187
  return node;
23146
23188
  }
23147
23189
  // @api
23148
- function createIdentifier(text, typeArguments, originalKeywordKind) {
23190
+ function createIdentifier(text, typeArguments, originalKeywordKind, hasExtendedUnicodeEscape) {
23149
23191
  var node = createBaseIdentifier(text, originalKeywordKind);
23150
23192
  if (typeArguments) {
23151
23193
  // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
@@ -23154,6 +23196,10 @@ var ts;
23154
23196
  if (node.originalKeywordKind === 133 /* SyntaxKind.AwaitKeyword */) {
23155
23197
  node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */;
23156
23198
  }
23199
+ if (hasExtendedUnicodeEscape) {
23200
+ node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
23201
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
23202
+ }
23157
23203
  return node;
23158
23204
  }
23159
23205
  // @api
@@ -27609,11 +27655,9 @@ var ts;
27609
27655
  rawTextScanner.setText("`" + rawText + "`");
27610
27656
  break;
27611
27657
  case 15 /* SyntaxKind.TemplateHead */:
27612
- // tslint:disable-next-line no-invalid-template-strings
27613
27658
  rawTextScanner.setText("`" + rawText + "${");
27614
27659
  break;
27615
27660
  case 16 /* SyntaxKind.TemplateMiddle */:
27616
- // tslint:disable-next-line no-invalid-template-strings
27617
27661
  rawTextScanner.setText("}" + rawText + "${");
27618
27662
  break;
27619
27663
  case 17 /* SyntaxKind.TemplateTail */:
@@ -27972,7 +28016,6 @@ var ts;
27972
28016
  return node;
27973
28017
  }
27974
28018
  ts.createInputFiles = createInputFiles;
27975
- // tslint:disable-next-line variable-name
27976
28019
  var SourceMapSource;
27977
28020
  /**
27978
28021
  * Create an external source map source file reference
@@ -28764,6 +28807,8 @@ var ts;
28764
28807
  // - The verb (`next`, `throw`, or `return` method) to delegate to the expression
28765
28808
  // of a `yield*`.
28766
28809
  // - The result of evaluating the verb delegated to the expression of a `yield*`.
28810
+ // g A temporary variable that holds onto the generator object until the generator
28811
+ // is started, allowing it to also act as the `suspendedStart` state.
28767
28812
  //
28768
28813
  // functions:
28769
28814
  // verb(n) Creates a bound callback to the `step` function for opcode `n`.
@@ -28802,7 +28847,7 @@ var ts;
28802
28847
  importName: "__generator",
28803
28848
  scoped: false,
28804
28849
  priority: 6,
28805
- text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };"
28850
+ text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };"
28806
28851
  };
28807
28852
  // ES Module Helpers
28808
28853
  ts.createBindingHelper = {
@@ -32106,13 +32151,11 @@ var ts;
32106
32151
  var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
32107
32152
  var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
32108
32153
  // capture constructors in 'initializeState' to avoid null checks
32109
- // tslint:disable variable-name
32110
32154
  var NodeConstructor;
32111
32155
  var TokenConstructor;
32112
32156
  var IdentifierConstructor;
32113
32157
  var PrivateIdentifierConstructor;
32114
32158
  var SourceFileConstructor;
32115
- // tslint:enable variable-name
32116
32159
  function countNode(node) {
32117
32160
  nodeCount++;
32118
32161
  return node;
@@ -33088,8 +33131,9 @@ var ts;
33088
33131
  // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
33089
33132
  var originalKeywordKind = token();
33090
33133
  var text = internIdentifier(scanner.getTokenValue());
33134
+ var hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
33091
33135
  nextTokenWithoutCheck();
33092
- return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
33136
+ return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind, hasExtendedUnicodeEscape), pos);
33093
33137
  }
33094
33138
  if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
33095
33139
  parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
@@ -42228,12 +42272,23 @@ var ts;
42228
42272
  }
42229
42273
  function writeConfigurations() {
42230
42274
  // Filter applicable options to place in the file
42231
- var categorizedOptions = ts.createMultiMap();
42275
+ var categorizedOptions = new ts.Map();
42276
+ // Set allowed categories in order
42277
+ categorizedOptions.set(ts.Diagnostics.Projects, []);
42278
+ categorizedOptions.set(ts.Diagnostics.Language_and_Environment, []);
42279
+ categorizedOptions.set(ts.Diagnostics.Modules, []);
42280
+ categorizedOptions.set(ts.Diagnostics.JavaScript_Support, []);
42281
+ categorizedOptions.set(ts.Diagnostics.Emit, []);
42282
+ categorizedOptions.set(ts.Diagnostics.Interop_Constraints, []);
42283
+ categorizedOptions.set(ts.Diagnostics.Type_Checking, []);
42284
+ categorizedOptions.set(ts.Diagnostics.Completeness, []);
42232
42285
  for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
42233
42286
  var option = optionDeclarations_1[_i];
42234
- var category = option.category;
42235
42287
  if (isAllowedOptionForOutput(option)) {
42236
- categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
42288
+ var listForCategory = categorizedOptions.get(option.category);
42289
+ if (!listForCategory)
42290
+ categorizedOptions.set(option.category, listForCategory = []);
42291
+ listForCategory.push(option);
42237
42292
  }
42238
42293
  }
42239
42294
  // Serialize all options and their descriptions
@@ -42244,7 +42299,7 @@ var ts;
42244
42299
  if (entries.length !== 0) {
42245
42300
  entries.push({ value: "" });
42246
42301
  }
42247
- entries.push({ value: "/* ".concat(category, " */") });
42302
+ entries.push({ value: "/* ".concat(ts.getLocaleSpecificMessage(category), " */") });
42248
42303
  for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
42249
42304
  var option = options_1[_i];
42250
42305
  var optionName = void 0;
@@ -44286,6 +44341,9 @@ var ts;
44286
44341
  requestContainingDirectory: containingDirectory,
44287
44342
  reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44288
44343
  };
44344
+ if (traceEnabled && ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) <= ts.ModuleResolutionKind.NodeNext) {
44345
+ trace(host, ts.Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(function (c) { return "'".concat(c, "'"); }).join(", "));
44346
+ }
44289
44347
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
44290
44348
  return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44291
44349
  function tryResolve(extensions) {
@@ -44875,7 +44933,7 @@ var ts;
44875
44933
  }
44876
44934
  if (mainExport) {
44877
44935
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
44878
- return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
44936
+ return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false, ".");
44879
44937
  }
44880
44938
  }
44881
44939
  else if (allKeysStartWithDot(scope.contents.packageJsonContent.exports)) {
@@ -44955,7 +45013,7 @@ var ts;
44955
45013
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44956
45014
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
44957
45015
  var target = lookupTable[moduleName];
44958
- return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
45016
+ return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
44959
45017
  }
44960
45018
  var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
44961
45019
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
@@ -44964,17 +45022,17 @@ var ts;
44964
45022
  var target = lookupTable[potentialTarget];
44965
45023
  var starPos = potentialTarget.indexOf("*");
44966
45024
  var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
44967
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
45025
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
44968
45026
  }
44969
45027
  else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
44970
45028
  var target = lookupTable[potentialTarget];
44971
45029
  var subpath = moduleName.substring(potentialTarget.length - 1);
44972
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
45030
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
44973
45031
  }
44974
45032
  else if (ts.startsWith(moduleName, potentialTarget)) {
44975
45033
  var target = lookupTable[potentialTarget];
44976
45034
  var subpath = moduleName.substring(potentialTarget.length);
44977
- return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
45035
+ return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false, potentialTarget);
44978
45036
  }
44979
45037
  }
44980
45038
  function matchesPatternWithTrailer(target, name) {
@@ -44991,7 +45049,7 @@ var ts;
44991
45049
  */
44992
45050
  function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
44993
45051
  return loadModuleFromTargetImportOrExport;
44994
- function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
45052
+ function loadModuleFromTargetImportOrExport(target, subpath, pattern, key) {
44995
45053
  if (typeof target === "string") {
44996
45054
  if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
44997
45055
  if (state.traceEnabled) {
@@ -45002,6 +45060,8 @@ var ts;
45002
45060
  if (!ts.startsWith(target, "./")) {
45003
45061
  if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
45004
45062
  var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
45063
+ traceIfEnabled(state, ts.Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
45064
+ traceIfEnabled(state, ts.Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
45005
45065
  var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
45006
45066
  return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
45007
45067
  }
@@ -45028,6 +45088,9 @@ var ts;
45028
45088
  }
45029
45089
  return toSearchResult(/*value*/ undefined);
45030
45090
  }
45091
+ if (state.traceEnabled) {
45092
+ trace(state.host, ts.Diagnostics.Using_0_subpath_1_with_target_2, isImports ? "imports" : "exports", key, pattern ? target.replace(/\*/g, subpath) : target + subpath);
45093
+ }
45031
45094
  var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
45032
45095
  var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
45033
45096
  if (inputLink)
@@ -45037,14 +45100,18 @@ var ts;
45037
45100
  else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
45038
45101
  if (!Array.isArray(target)) {
45039
45102
  for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
45040
- var key = _a[_i];
45041
- if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
45042
- var subTarget = target[key];
45043
- var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
45103
+ var condition = _a[_i];
45104
+ if (condition === "default" || state.conditions.indexOf(condition) >= 0 || isApplicableVersionedTypesKey(state.conditions, condition)) {
45105
+ traceIfEnabled(state, ts.Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
45106
+ var subTarget = target[condition];
45107
+ var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern, key);
45044
45108
  if (result) {
45045
45109
  return result;
45046
45110
  }
45047
45111
  }
45112
+ else {
45113
+ traceIfEnabled(state, ts.Diagnostics.Saw_non_matching_condition_0, condition);
45114
+ }
45048
45115
  }
45049
45116
  return undefined;
45050
45117
  }
@@ -45057,7 +45124,7 @@ var ts;
45057
45124
  }
45058
45125
  for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
45059
45126
  var elem = target_2[_b];
45060
- var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
45127
+ var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern, key);
45061
45128
  if (result) {
45062
45129
  return result;
45063
45130
  }
@@ -45473,6 +45540,15 @@ var ts;
45473
45540
  function toSearchResult(value) {
45474
45541
  return value !== undefined ? { value: value } : undefined;
45475
45542
  }
45543
+ function traceIfEnabled(state, diagnostic) {
45544
+ var args = [];
45545
+ for (var _i = 2; _i < arguments.length; _i++) {
45546
+ args[_i - 2] = arguments[_i];
45547
+ }
45548
+ if (state.traceEnabled) {
45549
+ trace.apply(void 0, __spreadArray([state.host, diagnostic], args, false));
45550
+ }
45551
+ }
45476
45552
  })(ts || (ts = {}));
45477
45553
  /* @internal */
45478
45554
  var ts;
@@ -49064,8 +49140,6 @@ var ts;
49064
49140
  IntersectionState[IntersectionState["None"] = 0] = "None";
49065
49141
  IntersectionState[IntersectionState["Source"] = 1] = "Source";
49066
49142
  IntersectionState[IntersectionState["Target"] = 2] = "Target";
49067
- IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
49068
- IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
49069
49143
  })(IntersectionState || (IntersectionState = {}));
49070
49144
  var RecursionFlags;
49071
49145
  (function (RecursionFlags) {
@@ -49484,6 +49558,12 @@ var ts;
49484
49558
  getOptionalType: function () { return optionalType; },
49485
49559
  getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
49486
49560
  getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
49561
+ getAsyncIterableType: function () {
49562
+ var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
49563
+ if (type === emptyGenericType)
49564
+ return undefined;
49565
+ return type;
49566
+ },
49487
49567
  isSymbolAccessible: isSymbolAccessible,
49488
49568
  isArrayType: isArrayType,
49489
49569
  isTupleType: isTupleType,
@@ -50321,9 +50401,9 @@ var ts;
50321
50401
  return symbol;
50322
50402
  }
50323
50403
  if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
50324
- var target = resolveAlias(symbol);
50325
- // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors
50326
- if (target === unknownSymbol || target.flags & meaning) {
50404
+ var targetFlags = getAllSymbolFlags(symbol);
50405
+ // `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
50406
+ if (targetFlags & meaning) {
50327
50407
  return symbol;
50328
50408
  }
50329
50409
  }
@@ -50956,8 +51036,8 @@ var ts;
50956
51036
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50957
51037
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50958
51038
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
51039
+ !checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
50959
51040
  !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
50960
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50961
51041
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50962
51042
  var suggestion = void 0;
50963
51043
  var suggestedLib = void 0;
@@ -51044,7 +51124,7 @@ var ts;
51044
51124
  }
51045
51125
  }
51046
51126
  if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
51047
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
51127
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
51048
51128
  if (typeOnlyDeclaration) {
51049
51129
  var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
51050
51130
  ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
@@ -51207,7 +51287,7 @@ var ts;
51207
51287
  return false;
51208
51288
  }
51209
51289
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
51210
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) {
51290
+ if (meaning & 111551 /* SymbolFlags.Value */) {
51211
51291
  if (isPrimitiveTypeName(name)) {
51212
51292
  if (isExtendedByInterface(errorLocation)) {
51213
51293
  error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name));
@@ -51218,7 +51298,8 @@ var ts;
51218
51298
  return true;
51219
51299
  }
51220
51300
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51221
- if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) {
51301
+ var allFlags = symbol && getAllSymbolFlags(symbol);
51302
+ if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
51222
51303
  var rawName = ts.unescapeLeadingUnderscores(name);
51223
51304
  if (isES2015OrLaterConstructorName(name)) {
51224
51305
  error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName);
@@ -51266,16 +51347,16 @@ var ts;
51266
51347
  }
51267
51348
  return false;
51268
51349
  }
51269
- function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
51270
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) {
51271
- var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51350
+ function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
51351
+ if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
51352
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51272
51353
  if (symbol) {
51273
51354
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
51274
51355
  return true;
51275
51356
  }
51276
51357
  }
51277
- else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) {
51278
- var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51358
+ else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
51359
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51279
51360
  if (symbol) {
51280
51361
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
51281
51362
  return true;
@@ -51865,6 +51946,52 @@ var ts;
51865
51946
  }
51866
51947
  return undefined;
51867
51948
  }
51949
+ /**
51950
+ * Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
51951
+ * is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
51952
+ * with another exported symbol, e.g.
51953
+ * ```ts
51954
+ * // a.ts
51955
+ * export const a = 0;
51956
+ * // b.ts
51957
+ * export { a } from "./a";
51958
+ * export type a = number;
51959
+ * // c.ts
51960
+ * import { a } from "./b";
51961
+ * ```
51962
+ * Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
51963
+ * from b.ts, even though there is still more alias to resolve. Consequently, if we were
51964
+ * trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
51965
+ * the local symbol and on the symbol returned by `resolveAlias` is not enough.
51966
+ * @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
51967
+ * combined flags of all alias targets otherwise.
51968
+ */
51969
+ function getAllSymbolFlags(symbol) {
51970
+ var flags = symbol.flags;
51971
+ var seenSymbols;
51972
+ while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
51973
+ var target = resolveAlias(symbol);
51974
+ if (target === unknownSymbol) {
51975
+ return 67108863 /* SymbolFlags.All */;
51976
+ }
51977
+ // Optimizations - try to avoid creating or adding to
51978
+ // `seenSymbols` if possible
51979
+ if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
51980
+ break;
51981
+ }
51982
+ if (target.flags & 2097152 /* SymbolFlags.Alias */) {
51983
+ if (seenSymbols) {
51984
+ seenSymbols.add(target);
51985
+ }
51986
+ else {
51987
+ seenSymbols = new ts.Set([symbol, target]);
51988
+ }
51989
+ }
51990
+ flags |= target.flags;
51991
+ symbol = target;
51992
+ }
51993
+ return flags;
51994
+ }
51868
51995
  /**
51869
51996
  * Marks a symbol as type-only if its declaration is syntactically type-only.
51870
51997
  * If it is not itself marked type-only, but resolves to a type-only alias
@@ -51910,19 +52037,25 @@ var ts;
51910
52037
  return !!aliasDeclarationLinks.typeOnlyDeclaration;
51911
52038
  }
51912
52039
  /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
51913
- function getTypeOnlyAliasDeclaration(symbol) {
52040
+ function getTypeOnlyAliasDeclaration(symbol, include) {
51914
52041
  if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
51915
52042
  return undefined;
51916
52043
  }
51917
52044
  var links = getSymbolLinks(symbol);
51918
- return links.typeOnlyDeclaration || undefined;
52045
+ if (include === undefined) {
52046
+ return links.typeOnlyDeclaration || undefined;
52047
+ }
52048
+ if (links.typeOnlyDeclaration) {
52049
+ return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
52050
+ }
52051
+ return undefined;
51919
52052
  }
51920
52053
  function markExportAsReferenced(node) {
51921
52054
  var symbol = getSymbolOfNode(node);
51922
52055
  var target = resolveAlias(symbol);
51923
52056
  if (target) {
51924
52057
  var markAlias = target === unknownSymbol ||
51925
- ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
52058
+ ((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
51926
52059
  if (markAlias) {
51927
52060
  markAliasSymbolAsReferenced(symbol);
51928
52061
  }
@@ -51942,8 +52075,7 @@ var ts;
51942
52075
  // This way a chain of imports can be elided if ultimately the final input is only used in a type
51943
52076
  // position.
51944
52077
  if (ts.isInternalModuleImportEqualsDeclaration(node)) {
51945
- var target = resolveSymbol(symbol);
51946
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
52078
+ if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
51947
52079
  // import foo = <symbol>
51948
52080
  checkExpressionCached(node.moduleReference);
51949
52081
  }
@@ -52765,7 +52897,7 @@ var ts;
52765
52897
  }
52766
52898
  function symbolIsValue(symbol, includeTypeOnlyMembers) {
52767
52899
  return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
52768
- symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52900
+ symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52769
52901
  }
52770
52902
  function findConstructorDeclaration(node) {
52771
52903
  var members = node.members;
@@ -53034,8 +53166,10 @@ var ts;
53034
53166
  return true;
53035
53167
  }
53036
53168
  // Qualify if the symbol from symbol table has same meaning as expected
53037
- symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53038
- if (symbolFromSymbolTable.flags & meaning) {
53169
+ var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
53170
+ symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53171
+ var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
53172
+ if (flags & meaning) {
53039
53173
  qualify = true;
53040
53174
  return true;
53041
53175
  }
@@ -55347,7 +55481,7 @@ var ts;
55347
55481
  // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
55348
55482
  var indices = ts.indicesOf(statements);
55349
55483
  var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
55350
- if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
55484
+ if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
55351
55485
  for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
55352
55486
  var index_1 = associatedIndices_1[_i];
55353
55487
  statements[index_1] = addExportModifier(statements[index_1]);
@@ -55381,15 +55515,6 @@ var ts;
55381
55515
  }
55382
55516
  return statements;
55383
55517
  }
55384
- function canHaveExportModifier(node) {
55385
- return ts.isEnumDeclaration(node) ||
55386
- ts.isVariableStatement(node) ||
55387
- ts.isFunctionDeclaration(node) ||
55388
- ts.isClassDeclaration(node) ||
55389
- (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
55390
- ts.isInterfaceDeclaration(node) ||
55391
- isTypeDeclaration(node);
55392
- }
55393
55518
  function addExportModifier(node) {
55394
55519
  var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
55395
55520
  return ts.factory.updateModifiers(node, flags);
@@ -55636,7 +55761,7 @@ var ts;
55636
55761
  (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
55637
55762
  if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
55638
55763
  enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
55639
- canHaveExportModifier(node)) {
55764
+ ts.canHaveExportModifier(node)) {
55640
55765
  // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
55641
55766
  newModifierFlags |= 1 /* ModifierFlags.Export */;
55642
55767
  }
@@ -55692,7 +55817,7 @@ var ts;
55692
55817
  return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
55693
55818
  }
55694
55819
  function isTypeOnlyNamespace(symbol) {
55695
- return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); });
55820
+ return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
55696
55821
  }
55697
55822
  function serializeModule(symbol, symbolName, modifierFlags) {
55698
55823
  var members = getNamespaceMembersForSerialization(symbol);
@@ -57912,7 +58037,7 @@ var ts;
57912
58037
  links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
57913
58038
  : isDuplicatedCommonJSExport(symbol.declarations) ? autoType
57914
58039
  : declaredType ? declaredType
57915
- : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
58040
+ : getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
57916
58041
  : errorType;
57917
58042
  }
57918
58043
  return links.type;
@@ -59795,7 +59920,20 @@ var ts;
59795
59920
  return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
59796
59921
  }
59797
59922
  function isGenericMappedType(type) {
59798
- return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type));
59923
+ if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
59924
+ var constraint = getConstraintTypeFromMappedType(type);
59925
+ if (isGenericIndexType(constraint)) {
59926
+ return true;
59927
+ }
59928
+ // A mapped type is generic if the 'as' clause references generic types other than the iteration type.
59929
+ // To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
59930
+ // type and check whether the resulting type is generic.
59931
+ var nameType = getNameTypeFromMappedType(type);
59932
+ if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
59933
+ return true;
59934
+ }
59935
+ }
59936
+ return false;
59799
59937
  }
59800
59938
  function resolveStructuredTypeMembers(type) {
59801
59939
  if (!type.members) {
@@ -60265,7 +60403,7 @@ var ts;
60265
60403
  var indexTypes;
60266
60404
  var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
60267
60405
  // Flags we want to propagate to the result if they exist in all source symbols
60268
- var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */;
60406
+ var optionalFlag;
60269
60407
  var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
60270
60408
  var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
60271
60409
  var mergedInstantiations = false;
@@ -60276,11 +60414,14 @@ var ts;
60276
60414
  var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
60277
60415
  var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
60278
60416
  if (prop) {
60279
- if (isUnion) {
60280
- optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60281
- }
60282
- else {
60283
- optionalFlag &= prop.flags;
60417
+ if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
60418
+ optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
60419
+ if (isUnion) {
60420
+ optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60421
+ }
60422
+ else {
60423
+ optionalFlag &= prop.flags;
60424
+ }
60284
60425
  }
60285
60426
  if (!singleProp) {
60286
60427
  singleProp = prop;
@@ -60399,7 +60540,7 @@ var ts;
60399
60540
  propTypes.push(type);
60400
60541
  }
60401
60542
  ts.addRange(propTypes, indexTypes);
60402
- var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
60543
+ var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
60403
60544
  result.containingType = containingType;
60404
60545
  if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
60405
60546
  result.valueDeclaration = firstValueDeclaration;
@@ -63112,8 +63253,14 @@ var ts;
63112
63253
  return getStringLiteralType(text);
63113
63254
  }
63114
63255
  newTexts.push(text);
63115
- if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63116
- return stringType;
63256
+ if (ts.every(newTexts, function (t) { return t === ""; })) {
63257
+ if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
63258
+ return stringType;
63259
+ }
63260
+ // Normalize `${Mapping<xxx>}` into Mapping<xxx>
63261
+ if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
63262
+ return newTypes[0];
63263
+ }
63117
63264
  }
63118
63265
  var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
63119
63266
  var type = templateLiteralTypes.get(id);
@@ -63172,12 +63319,14 @@ var ts;
63172
63319
  }
63173
63320
  function getStringMappingType(symbol, type) {
63174
63321
  return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
63175
- // Mapping<Mapping<T>> === Mapping<T>
63176
- type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63177
- isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
63178
- type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63179
- type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63180
- type;
63322
+ type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
63323
+ type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
63324
+ // Mapping<Mapping<T>> === Mapping<T>
63325
+ type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
63326
+ type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
63327
+ // This handles Mapping<`${number}`> and Mapping<`${bigint}`>
63328
+ isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
63329
+ type;
63181
63330
  }
63182
63331
  function applyStringMapping(symbol, str) {
63183
63332
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -63342,7 +63491,18 @@ var ts;
63342
63491
  return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63343
63492
  }
63344
63493
  errorIfWritingToReadonlyIndex(indexInfo);
63345
- return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63494
+ // When accessing an enum object with its own type,
63495
+ // e.g. E[E.A] for enum E { A }, undefined shouldn't
63496
+ // be included in the result type
63497
+ if ((accessFlags & 1 /* AccessFlags.IncludeUndefined */) &&
63498
+ !(objectType.symbol &&
63499
+ objectType.symbol.flags & (256 /* SymbolFlags.RegularEnum */ | 128 /* SymbolFlags.ConstEnum */) &&
63500
+ (indexType.symbol &&
63501
+ indexType.flags & 1024 /* TypeFlags.EnumLiteral */ &&
63502
+ getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
63503
+ return getUnionType([indexInfo.type, undefinedType]);
63504
+ }
63505
+ return indexInfo.type;
63346
63506
  }
63347
63507
  if (indexType.flags & 131072 /* TypeFlags.Never */) {
63348
63508
  return neverType;
@@ -63445,10 +63605,11 @@ var ts;
63445
63605
  accessNode;
63446
63606
  }
63447
63607
  function isPatternLiteralPlaceholderType(type) {
63448
- return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type));
63608
+ return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
63449
63609
  }
63450
63610
  function isPatternLiteralType(type) {
63451
- return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
63611
+ return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
63612
+ !!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
63452
63613
  }
63453
63614
  function isGenericType(type) {
63454
63615
  return !!getGenericObjectFlags(type);
@@ -63727,18 +63888,23 @@ var ts;
63727
63888
  var result;
63728
63889
  var extraTypes;
63729
63890
  var tailCount = 0;
63730
- var _loop_20 = function () {
63891
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
63892
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
63893
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
63894
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63895
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
63896
+ while (true) {
63731
63897
  if (tailCount === 1000) {
63732
63898
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
63733
63899
  result = errorType;
63734
- return "break";
63900
+ break;
63735
63901
  }
63736
63902
  var isUnwrapped = isTypicalNondistributiveConditional(root);
63737
63903
  var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
63738
63904
  var checkTypeInstantiable = isGenericType(checkType);
63739
63905
  var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
63740
63906
  if (checkType === wildcardType || extendsType === wildcardType) {
63741
- return { value: wildcardType };
63907
+ return wildcardType;
63742
63908
  }
63743
63909
  var combinedMapper = void 0;
63744
63910
  if (root.inferTypeParameters) {
@@ -63771,11 +63937,7 @@ var ts;
63771
63937
  }
63772
63938
  }
63773
63939
  }
63774
- // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
63775
- // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
63776
- // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
63777
- // so in those cases we refain from performing inference and retain the uninfered type parameter
63778
- if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
63940
+ if (!checkTypeInstantiable) {
63779
63941
  // We don't want inferences from constraints as they may cause us to eagerly resolve the
63780
63942
  // conditional type instead of deferring resolution. Also, we always want strict function
63781
63943
  // types rules (i.e. proper contravariance) for inferences.
@@ -63807,14 +63969,14 @@ var ts;
63807
63969
  var newRoot = falseType_1.root;
63808
63970
  if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
63809
63971
  root = newRoot;
63810
- return "continue";
63972
+ continue;
63811
63973
  }
63812
63974
  if (canTailRecurse(falseType_1, mapper)) {
63813
- return "continue";
63975
+ continue;
63814
63976
  }
63815
63977
  }
63816
63978
  result = instantiateType(falseType_1, mapper);
63817
- return "break";
63979
+ break;
63818
63980
  }
63819
63981
  // Return trueType for a definitely true extends check. We check instantiations of the two
63820
63982
  // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
@@ -63825,10 +63987,10 @@ var ts;
63825
63987
  var trueType_1 = getTypeFromTypeNode(root.node.trueType);
63826
63988
  var trueMapper = combinedMapper || mapper;
63827
63989
  if (canTailRecurse(trueType_1, trueMapper)) {
63828
- return "continue";
63990
+ continue;
63829
63991
  }
63830
63992
  result = instantiateType(trueType_1, trueMapper);
63831
- return "break";
63993
+ break;
63832
63994
  }
63833
63995
  }
63834
63996
  // Return a deferred type for a check that is neither definitely true nor definitely false
@@ -63840,19 +64002,7 @@ var ts;
63840
64002
  result.combinedMapper = combinedMapper;
63841
64003
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
63842
64004
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
63843
- return "break";
63844
- };
63845
- // We loop here for an immediately nested conditional type in the false position, effectively treating
63846
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
63847
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
63848
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63849
- // cases we increment the tail recursion counter and stop after 1000 iterations.
63850
- while (true) {
63851
- var state_6 = _loop_20();
63852
- if (typeof state_6 === "object")
63853
- return state_6.value;
63854
- if (state_6 === "break")
63855
- break;
64005
+ break;
63856
64006
  }
63857
64007
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
63858
64008
  // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -66306,7 +66456,7 @@ var ts;
66306
66456
  return 0 /* Ternary.False */;
66307
66457
  }
66308
66458
  }
66309
- var isPerformingCommonPropertyChecks = (relation !== comparableRelation || !(source.flags & 1048576 /* TypeFlags.Union */) && isLiteralType(source)) &&
66459
+ var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
66310
66460
  !(intersectionState & 2 /* IntersectionState.Target */) &&
66311
66461
  source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
66312
66462
  target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
@@ -66334,27 +66484,6 @@ var ts;
66334
66484
  var result_7 = skipCaching ?
66335
66485
  unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
66336
66486
  recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
66337
- // For certain combinations involving intersections and optional, excess, or mismatched properties we need
66338
- // an extra property check where the intersection is viewed as a single object. The following are motivating
66339
- // examples that all should be errors, but aren't without this extra property check:
66340
- //
66341
- // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
66342
- //
66343
- // declare let wrong: { a: { y: string } };
66344
- // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
66345
- //
66346
- // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
66347
- // x = y; // Mismatched property in source intersection
66348
- // }
66349
- //
66350
- // We suppress recursive intersection property checks because they can generate lots of work when relating
66351
- // recursive intersections that are structurally similar but not exactly identical. See #37854.
66352
- if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
66353
- isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
66354
- inPropertyCheck = true;
66355
- result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
66356
- inPropertyCheck = false;
66357
- }
66358
66487
  if (result_7) {
66359
66488
  return result_7;
66360
66489
  }
@@ -66466,7 +66595,7 @@ var ts;
66466
66595
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
66467
66596
  checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
66468
66597
  }
66469
- var _loop_21 = function (prop) {
66598
+ var _loop_20 = function (prop) {
66470
66599
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
66471
66600
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
66472
66601
  if (reportErrors) {
@@ -66529,9 +66658,9 @@ var ts;
66529
66658
  };
66530
66659
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
66531
66660
  var prop = _b[_i];
66532
- var state_7 = _loop_21(prop);
66533
- if (typeof state_7 === "object")
66534
- return state_7.value;
66661
+ var state_6 = _loop_20(prop);
66662
+ if (typeof state_6 === "object")
66663
+ return state_6.value;
66535
66664
  }
66536
66665
  return false;
66537
66666
  }
@@ -66752,8 +66881,7 @@ var ts;
66752
66881
  if (overflow) {
66753
66882
  return 0 /* Ternary.False */;
66754
66883
  }
66755
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0);
66756
- var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
66884
+ var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
66757
66885
  var entry = relation.get(id);
66758
66886
  if (entry !== undefined) {
66759
66887
  if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
@@ -66783,7 +66911,7 @@ var ts;
66783
66911
  // A key that starts with "*" is an indication that we have type references that reference constrained
66784
66912
  // type parameters. For such keys we also check against the key we would have gotten if all type parameters
66785
66913
  // were unconstrained.
66786
- var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
66914
+ var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
66787
66915
  for (var i = 0; i < maybeCount; i++) {
66788
66916
  // If source and target are already being compared, consider them related with assumptions
66789
66917
  if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
@@ -66870,7 +66998,7 @@ var ts;
66870
66998
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
66871
66999
  var saveErrorInfo = captureErrorCalculationState();
66872
67000
  var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
66873
- if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
67001
+ if (relation !== identityRelation) {
66874
67002
  // The combined constraint of an intersection type is the intersection of the constraints of
66875
67003
  // the constituents. When an intersection type contains instantiable types with union type
66876
67004
  // constraints, there are situations where we need to examine the combined constraint. One is
@@ -66884,10 +67012,33 @@ var ts;
66884
67012
  // needs to have its constraint hoisted into an intersection with said type parameter, this way
66885
67013
  // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
66886
67014
  // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
66887
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
66888
- if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66889
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66890
- result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
67015
+ if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
67016
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
67017
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
67018
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
67019
+ result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
67020
+ }
67021
+ }
67022
+ // For certain combinations involving intersections and optional, excess, or mismatched properties we need
67023
+ // an extra property check where the intersection is viewed as a single object. The following are motivating
67024
+ // examples that all should be errors, but aren't without this extra property check:
67025
+ //
67026
+ // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
67027
+ //
67028
+ // declare let wrong: { a: { y: string } };
67029
+ // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
67030
+ //
67031
+ // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
67032
+ // x = y; // Mismatched property in source intersection
67033
+ // }
67034
+ //
67035
+ // We suppress recursive intersection property checks because they can generate lots of work when relating
67036
+ // recursive intersections that are structurally similar but not exactly identical. See #37854.
67037
+ if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
67038
+ 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 */); }))) {
67039
+ inPropertyCheck = true;
67040
+ result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
67041
+ inPropertyCheck = false;
66891
67042
  }
66892
67043
  }
66893
67044
  if (result) {
@@ -66896,9 +67047,6 @@ var ts;
66896
67047
  return result;
66897
67048
  }
66898
67049
  function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
66899
- if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
66900
- return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
66901
- }
66902
67050
  var result;
66903
67051
  var originalErrorInfo;
66904
67052
  var varianceCheckFailed = false;
@@ -66999,7 +67147,7 @@ var ts;
66999
67147
  // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
67000
67148
  var constraint = getConstraintOfTypeParameter(source);
67001
67149
  if (constraint && hasNonCircularBaseConstraint(source)) {
67002
- while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
67150
+ while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
67003
67151
  if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
67004
67152
  return result;
67005
67153
  }
@@ -67522,11 +67670,11 @@ var ts;
67522
67670
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
67523
67671
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
67524
67672
  var matchingTypes = [];
67525
- var _loop_22 = function (combination) {
67673
+ var _loop_21 = function (combination) {
67526
67674
  var hasMatch = false;
67527
67675
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
67528
67676
  var type = _d[_c];
67529
- var _loop_23 = function (i) {
67677
+ var _loop_22 = function (i) {
67530
67678
  var sourceProperty = sourcePropertiesFiltered[i];
67531
67679
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
67532
67680
  if (!targetProperty)
@@ -67542,8 +67690,8 @@ var ts;
67542
67690
  }
67543
67691
  };
67544
67692
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
67545
- var state_9 = _loop_23(i);
67546
- switch (state_9) {
67693
+ var state_8 = _loop_22(i);
67694
+ switch (state_8) {
67547
67695
  case "continue-outer": continue outer;
67548
67696
  }
67549
67697
  }
@@ -67556,9 +67704,9 @@ var ts;
67556
67704
  };
67557
67705
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
67558
67706
  var combination = discriminantCombinations_1[_a];
67559
- var state_8 = _loop_22(combination);
67560
- if (typeof state_8 === "object")
67561
- return state_8.value;
67707
+ var state_7 = _loop_21(combination);
67708
+ if (typeof state_7 === "object")
67709
+ return state_7.value;
67562
67710
  }
67563
67711
  // Compare the remaining non-discriminant properties of each match.
67564
67712
  var result = -1 /* Ternary.True */;
@@ -67655,7 +67803,7 @@ var ts;
67655
67803
  return 0 /* Ternary.False */;
67656
67804
  }
67657
67805
  // When checking for comparability, be more lenient with optional properties.
67658
- if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67806
+ if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67659
67807
  // TypeScript 1.0 spec (April 2014): 3.8.3
67660
67808
  // S is a subtype of a type T, and T is a supertype of S if ...
67661
67809
  // S' and T are object types and, for each member M in T..
@@ -68263,7 +68411,7 @@ var ts;
68263
68411
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
68264
68412
  links.variances = ts.emptyArray;
68265
68413
  var variances = [];
68266
- var _loop_24 = function (tp) {
68414
+ var _loop_23 = function (tp) {
68267
68415
  var modifiers = getVarianceModifiers(tp);
68268
68416
  var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
68269
68417
  modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
@@ -68301,7 +68449,7 @@ var ts;
68301
68449
  };
68302
68450
  for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
68303
68451
  var tp = typeParameters_2[_i];
68304
- _loop_24(tp);
68452
+ _loop_23(tp);
68305
68453
  }
68306
68454
  links.variances = variances;
68307
68455
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
@@ -68755,8 +68903,7 @@ var ts;
68755
68903
  return !!(type.flags & 109440 /* TypeFlags.Unit */);
68756
68904
  }
68757
68905
  function isUnitLikeType(type) {
68758
- return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) :
68759
- !!(type.flags & 109440 /* TypeFlags.Unit */);
68906
+ return isUnitType(getBaseConstraintOrType(type));
68760
68907
  }
68761
68908
  function extractUnitType(type) {
68762
68909
  return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type;
@@ -69635,7 +69782,7 @@ var ts;
69635
69782
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
69636
69783
  }
69637
69784
  function isMemberOfStringMapping(source, target) {
69638
- if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) {
69785
+ if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
69639
69786
  return true;
69640
69787
  }
69641
69788
  if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
@@ -70259,7 +70406,7 @@ var ts;
70259
70406
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
70260
70407
  // succeed. That would be a pointless and confusing outcome.
70261
70408
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
70262
- var _loop_25 = function (i) {
70409
+ var _loop_24 = function (i) {
70263
70410
  var source_1 = matches ? matches[i] : neverType;
70264
70411
  var target_3 = types[i];
70265
70412
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -70309,7 +70456,7 @@ var ts;
70309
70456
  inferFromTypes(source_1, target_3);
70310
70457
  };
70311
70458
  for (var i = 0; i < types.length; i++) {
70312
- _loop_25(i);
70459
+ _loop_24(i);
70313
70460
  }
70314
70461
  }
70315
70462
  }
@@ -70761,7 +70908,7 @@ var ts;
70761
70908
  }
70762
70909
  if (ts.isEntityNameExpression(node.argumentExpression)) {
70763
70910
  var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
70764
- if (!symbol || !isConstVariable(symbol))
70911
+ if (!symbol || !(isConstVariable(symbol) || (symbol.flags & 8 /* SymbolFlags.EnumMember */)))
70765
70912
  return undefined;
70766
70913
  var declaration = symbol.valueDeclaration;
70767
70914
  if (declaration === undefined)
@@ -70775,7 +70922,12 @@ var ts;
70775
70922
  }
70776
70923
  if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70777
70924
  var initializer = ts.getEffectiveInitializer(declaration);
70778
- return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70925
+ if (initializer) {
70926
+ return tryGetNameFromType(getTypeOfExpression(initializer));
70927
+ }
70928
+ if (ts.isEnumMember(declaration)) {
70929
+ return ts.getTextOfPropertyName(declaration.name);
70930
+ }
70779
70931
  }
70780
70932
  }
70781
70933
  return undefined;
@@ -70833,7 +70985,7 @@ var ts;
70833
70985
  function mapTypesByKeyProperty(types, name) {
70834
70986
  var map = new ts.Map();
70835
70987
  var count = 0;
70836
- var _loop_26 = function (type) {
70988
+ var _loop_25 = function (type) {
70837
70989
  if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
70838
70990
  var discriminant = getTypeOfPropertyOfType(type, name);
70839
70991
  if (discriminant) {
@@ -70859,9 +71011,9 @@ var ts;
70859
71011
  };
70860
71012
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70861
71013
  var type = types_15[_i];
70862
- var state_10 = _loop_26(type);
70863
- if (typeof state_10 === "object")
70864
- return state_10.value;
71014
+ var state_9 = _loop_25(type);
71015
+ if (typeof state_9 === "object")
71016
+ return state_9.value;
70865
71017
  }
70866
71018
  return count >= 10 && count * 2 >= types.length ? map : undefined;
70867
71019
  }
@@ -71458,6 +71610,7 @@ var ts;
71458
71610
  ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
71459
71611
  }
71460
71612
  function getExplicitTypeOfSymbol(symbol, diagnostic) {
71613
+ symbol = resolveSymbol(symbol);
71461
71614
  if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) {
71462
71615
  return getTypeOfSymbol(symbol);
71463
71616
  }
@@ -71496,7 +71649,7 @@ var ts;
71496
71649
  switch (node.kind) {
71497
71650
  case 79 /* SyntaxKind.Identifier */:
71498
71651
  var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
71499
- return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic);
71652
+ return getExplicitTypeOfSymbol(symbol, diagnostic);
71500
71653
  case 108 /* SyntaxKind.ThisKeyword */:
71501
71654
  return getExplicitThisType(node);
71502
71655
  case 106 /* SyntaxKind.SuperKeyword */:
@@ -71983,7 +72136,7 @@ var ts;
71983
72136
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71984
72137
  }
71985
72138
  else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
71986
- type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
72139
+ type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
71987
72140
  }
71988
72141
  else {
71989
72142
  if (strictNullChecks) {
@@ -72264,7 +72417,7 @@ var ts;
72264
72417
  !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72265
72418
  !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72266
72419
  }
72267
- function narrowByInKeyword(type, nameType, assumeTrue) {
72420
+ function narrowTypeByInKeyword(type, nameType, assumeTrue) {
72268
72421
  var name = getPropertyNameFromType(nameType);
72269
72422
  var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72270
72423
  if (isKnownProperty) {
@@ -72345,7 +72498,7 @@ var ts;
72345
72498
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72346
72499
  }
72347
72500
  if (isMatchingReference(reference, target)) {
72348
- return narrowByInKeyword(type, leftType, assumeTrue);
72501
+ return narrowTypeByInKeyword(type, leftType, assumeTrue);
72349
72502
  }
72350
72503
  }
72351
72504
  break;
@@ -72534,7 +72687,7 @@ var ts;
72534
72687
  neverType;
72535
72688
  });
72536
72689
  }
72537
- function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72690
+ function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
72538
72691
  var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
72539
72692
  if (!witnesses) {
72540
72693
  return type;
@@ -72922,15 +73075,15 @@ var ts;
72922
73075
  });
72923
73076
  }
72924
73077
  function markAliasReferenced(symbol, location) {
72925
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
73078
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
72926
73079
  var target = resolveAlias(symbol);
72927
- if (target.flags & 111551 /* SymbolFlags.Value */) {
73080
+ if (getAllSymbolFlags(target) & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */)) {
72928
73081
  // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
72929
73082
  // (because the const enum value will not be inlined), or if (2) the alias is an export
72930
73083
  // of a const enum declaration that will be preserved.
72931
73084
  if (compilerOptions.isolatedModules ||
72932
73085
  ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) ||
72933
- !isConstEnumOrConstEnumOnlyModule(target)) {
73086
+ !isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
72934
73087
  markAliasSymbolAsReferenced(symbol);
72935
73088
  }
72936
73089
  else {
@@ -73158,7 +73311,7 @@ var ts;
73158
73311
  // We only look for uninitialized variables in strict null checking mode, and only when we can analyze
73159
73312
  // the entire control flow graph from the variable's declaration (i.e. when the flow container and
73160
73313
  // declaration container are the same).
73161
- var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
73314
+ var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
73162
73315
  type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 ||
73163
73316
  isInTypeQuery(node) || node.parent.kind === 278 /* SyntaxKind.ExportSpecifier */) ||
73164
73317
  node.parent.kind === 232 /* SyntaxKind.NonNullExpression */ ||
@@ -73187,6 +73340,12 @@ var ts;
73187
73340
  }
73188
73341
  return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
73189
73342
  }
73343
+ function isSameScopedBindingElement(node, declaration) {
73344
+ if (ts.isBindingElement(declaration)) {
73345
+ var bindingElement = ts.findAncestor(node, ts.isBindingElement);
73346
+ return bindingElement && ts.getRootDeclaration(bindingElement) === ts.getRootDeclaration(declaration);
73347
+ }
73348
+ }
73190
73349
  function shouldMarkIdentifierAliasReferenced(node) {
73191
73350
  var _a;
73192
73351
  var parent = node.parent;
@@ -73528,12 +73687,17 @@ var ts;
73528
73687
  var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
73529
73688
  var container = immediateContainer;
73530
73689
  var needToCaptureLexicalThis = false;
73690
+ var inAsyncFunction = false;
73531
73691
  // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
73532
73692
  if (!isCallExpression) {
73533
73693
  while (container && container.kind === 216 /* SyntaxKind.ArrowFunction */) {
73694
+ if (ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73695
+ inAsyncFunction = true;
73534
73696
  container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
73535
73697
  needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
73536
73698
  }
73699
+ if (container && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73700
+ inAsyncFunction = true;
73537
73701
  }
73538
73702
  var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
73539
73703
  var nodeCheckFlag = 0;
@@ -73639,12 +73803,12 @@ var ts;
73639
73803
  // as a call expression cannot be used as the target of a destructuring assignment while a property access can.
73640
73804
  //
73641
73805
  // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
73642
- if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */)) {
73806
+ if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && inAsyncFunction) {
73643
73807
  if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
73644
- getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */;
73808
+ getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */;
73645
73809
  }
73646
73810
  else {
73647
- getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */;
73811
+ getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */;
73648
73812
  }
73649
73813
  }
73650
73814
  if (needToCaptureLexicalThis) {
@@ -74340,9 +74504,10 @@ var ts;
74340
74504
  function instantiateContextualType(contextualType, node, contextFlags) {
74341
74505
  if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
74342
74506
  var inferenceContext = getInferenceContext(node);
74343
- // If no inferences have been made, nothing is gained from instantiating as type parameters
74344
- // would just be replaced with their defaults similar to the apparent type.
74345
- if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
74507
+ // If no inferences have been made, and none of the type parameters for which we are inferring
74508
+ // specify default types, nothing is gained from instantiating as type parameters would just be
74509
+ // replaced with their constraints similar to the apparent type.
74510
+ if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
74346
74511
  // For contextual signatures we incorporate all inferences made so far, e.g. from return
74347
74512
  // types as well as arguments to the left in a function call.
74348
74513
  return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
@@ -77316,7 +77481,7 @@ var ts;
77316
77481
  if (spreadIndex >= 0) {
77317
77482
  // Create synthetic arguments from spreads of tuple types.
77318
77483
  var effectiveArgs_1 = args.slice(0, spreadIndex);
77319
- var _loop_27 = function (i) {
77484
+ var _loop_26 = function (i) {
77320
77485
  var arg = args[i];
77321
77486
  // We can call checkExpressionCached because spread expressions never have a contextual type.
77322
77487
  var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -77333,7 +77498,7 @@ var ts;
77333
77498
  }
77334
77499
  };
77335
77500
  for (var i = spreadIndex; i < args.length; i++) {
77336
- _loop_27(i);
77501
+ _loop_26(i);
77337
77502
  }
77338
77503
  return effectiveArgs_1;
77339
77504
  }
@@ -77662,7 +77827,7 @@ var ts;
77662
77827
  var min_3 = Number.MAX_VALUE;
77663
77828
  var minIndex = 0;
77664
77829
  var i_1 = 0;
77665
- var _loop_28 = function (c) {
77830
+ var _loop_27 = function (c) {
77666
77831
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
77667
77832
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
77668
77833
  if (diags_2) {
@@ -77680,7 +77845,7 @@ var ts;
77680
77845
  };
77681
77846
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
77682
77847
  var c = candidatesForArgumentError_1[_a];
77683
- _loop_28(c);
77848
+ _loop_27(c);
77684
77849
  }
77685
77850
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
77686
77851
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -77838,7 +78003,7 @@ var ts;
77838
78003
  }
77839
78004
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
77840
78005
  var parameters = [];
77841
- var _loop_29 = function (i) {
78006
+ var _loop_28 = function (i) {
77842
78007
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
77843
78008
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
77844
78009
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -77846,7 +78011,7 @@ var ts;
77846
78011
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
77847
78012
  };
77848
78013
  for (var i = 0; i < maxNonRestParam; i++) {
77849
- _loop_29(i);
78014
+ _loop_28(i);
77850
78015
  }
77851
78016
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
77852
78017
  var flags = 0 /* SignatureFlags.None */;
@@ -78816,7 +78981,7 @@ var ts;
78816
78981
  if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
78817
78982
  symbol = resolveAlias(symbol);
78818
78983
  }
78819
- return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78984
+ return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78820
78985
  }
78821
78986
  return false;
78822
78987
  }
@@ -79478,7 +79643,17 @@ var ts;
79478
79643
  }
79479
79644
  function isExhaustiveSwitchStatement(node) {
79480
79645
  var links = getNodeLinks(node);
79481
- return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
79646
+ if (links.isExhaustive === undefined) {
79647
+ links.isExhaustive = 0; // Indicate resolution is in process
79648
+ var exhaustive = computeExhaustiveSwitchStatement(node);
79649
+ if (links.isExhaustive === 0) {
79650
+ links.isExhaustive = exhaustive;
79651
+ }
79652
+ }
79653
+ else if (links.isExhaustive === 0) {
79654
+ links.isExhaustive = false; // Resolve circularity to false
79655
+ }
79656
+ return links.isExhaustive;
79482
79657
  }
79483
79658
  function computeExhaustiveSwitchStatement(node) {
79484
79659
  if (node.expression.kind === 218 /* SyntaxKind.TypeOfExpression */) {
@@ -79486,7 +79661,7 @@ var ts;
79486
79661
  if (!witnesses) {
79487
79662
  return false;
79488
79663
  }
79489
- var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression));
79664
+ var operandConstraint = getBaseConstraintOrType(checkExpressionCached(node.expression.expression));
79490
79665
  // Get the not-equal flags for all handled cases.
79491
79666
  var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
79492
79667
  if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) {
@@ -79496,7 +79671,7 @@ var ts;
79496
79671
  // A missing not-equal flag indicates that the type wasn't handled by some case.
79497
79672
  return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
79498
79673
  }
79499
- var type = getTypeOfExpression(node.expression);
79674
+ var type = checkExpressionCached(node.expression);
79500
79675
  if (!isLiteralType(type)) {
79501
79676
  return false;
79502
79677
  }
@@ -81190,6 +81365,9 @@ var ts;
81190
81365
  function hasInferenceCandidates(info) {
81191
81366
  return !!(info.candidates || info.contraCandidates);
81192
81367
  }
81368
+ function hasInferenceCandidatesOrDefault(info) {
81369
+ return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
81370
+ }
81193
81371
  function hasOverlappingInferences(a, b) {
81194
81372
  for (var i = 0; i < a.length; i++) {
81195
81373
  if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
@@ -81891,7 +82069,7 @@ var ts;
81891
82069
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
81892
82070
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
81893
82071
  var indexSignatureMap_1 = new ts.Map();
81894
- var _loop_30 = function (declaration) {
82072
+ var _loop_29 = function (declaration) {
81895
82073
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
81896
82074
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
81897
82075
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -81906,7 +82084,7 @@ var ts;
81906
82084
  };
81907
82085
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
81908
82086
  var declaration = _a[_i];
81909
- _loop_30(declaration);
82087
+ _loop_29(declaration);
81910
82088
  }
81911
82089
  indexSignatureMap_1.forEach(function (entry) {
81912
82090
  if (entry.declarations.length > 1) {
@@ -82183,7 +82361,7 @@ var ts;
82183
82361
  }
82184
82362
  var symbol = getNodeLinks(node).resolvedSymbol;
82185
82363
  if (symbol) {
82186
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
82364
+ if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
82187
82365
  addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
82188
82366
  }
82189
82367
  if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
@@ -82786,7 +82964,7 @@ var ts;
82786
82964
  return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
82787
82965
  }
82788
82966
  // primitives with a `{ then() }` won't be unwrapped/adopted.
82789
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82967
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82790
82968
  return undefined;
82791
82969
  }
82792
82970
  var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
@@ -82853,7 +83031,7 @@ var ts;
82853
83031
  * Determines whether a type is an object with a callable `then` member.
82854
83032
  */
82855
83033
  function isThenableType(type) {
82856
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
83034
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82857
83035
  // primitive types cannot be considered "thenable" since they are not objects.
82858
83036
  return false;
82859
83037
  }
@@ -82887,7 +83065,7 @@ var ts;
82887
83065
  // We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82888
83066
  // or is promise-like.
82889
83067
  if (baseConstraint ?
82890
- baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
83068
+ baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
82891
83069
  maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
82892
83070
  return true;
82893
83071
  }
@@ -83561,7 +83739,7 @@ var ts;
83561
83739
  }
83562
83740
  function errorUnusedLocal(declaration, name, addDiagnostic) {
83563
83741
  var node = ts.getNameOfDeclaration(declaration) || declaration;
83564
- var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
83742
+ var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
83565
83743
  addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
83566
83744
  }
83567
83745
  function isIdentifierThatStartsWithUnderscore(node) {
@@ -84991,7 +85169,16 @@ var ts;
84991
85169
  var message = allowAsyncIterables
84992
85170
  ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
84993
85171
  : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
84994
- return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
85172
+ var suggestAwait =
85173
+ // for (const x of Promise<...>) or [...Promise<...>]
85174
+ !!getAwaitedTypeOfPromise(type)
85175
+ // for (const x of AsyncIterable<...>)
85176
+ || (!allowAsyncIterables &&
85177
+ ts.isForOfStatement(errorNode.parent) &&
85178
+ errorNode.parent.expression === errorNode &&
85179
+ getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
85180
+ isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
85181
+ return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
84995
85182
  }
84996
85183
  /**
84997
85184
  * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
@@ -85506,7 +85693,7 @@ var ts;
85506
85693
  var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
85507
85694
  name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
85508
85695
  var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
85509
- var _loop_31 = function (info) {
85696
+ var _loop_30 = function (info) {
85510
85697
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
85511
85698
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
85512
85699
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -85523,7 +85710,7 @@ var ts;
85523
85710
  };
85524
85711
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
85525
85712
  var info = indexInfos_9[_i];
85526
- _loop_31(info);
85713
+ _loop_30(info);
85527
85714
  }
85528
85715
  }
85529
85716
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -85531,7 +85718,7 @@ var ts;
85531
85718
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
85532
85719
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
85533
85720
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
85534
- var _loop_32 = function (info) {
85721
+ var _loop_31 = function (info) {
85535
85722
  if (info === checkInfo)
85536
85723
  return "continue";
85537
85724
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -85546,7 +85733,7 @@ var ts;
85546
85733
  };
85547
85734
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
85548
85735
  var info = indexInfos_10[_i];
85549
- _loop_32(info);
85736
+ _loop_31(info);
85550
85737
  }
85551
85738
  }
85552
85739
  function checkTypeNameIsReserved(name, message) {
@@ -85601,7 +85788,7 @@ var ts;
85601
85788
  }
85602
85789
  else {
85603
85790
  ts.forEach(jsdocParameters, function (_a, index) {
85604
- var name = _a.name;
85791
+ var name = _a.name, isNameFirst = _a.isNameFirst;
85605
85792
  if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
85606
85793
  return;
85607
85794
  }
@@ -85611,7 +85798,9 @@ var ts;
85611
85798
  }
85612
85799
  }
85613
85800
  else {
85614
- errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
85801
+ if (!isNameFirst) {
85802
+ errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
85803
+ }
85615
85804
  }
85616
85805
  });
85617
85806
  }
@@ -85866,7 +86055,7 @@ var ts;
85866
86055
  var baseTypes = baseTypeNode && getBaseTypes(type);
85867
86056
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
85868
86057
  var baseStaticType = getBaseConstructorTypeOfClass(type);
85869
- var _loop_33 = function (member) {
86058
+ var _loop_32 = function (member) {
85870
86059
  if (ts.hasAmbientModifier(member)) {
85871
86060
  return "continue";
85872
86061
  }
@@ -85883,7 +86072,7 @@ var ts;
85883
86072
  };
85884
86073
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85885
86074
  var member = _a[_i];
85886
- _loop_33(member);
86075
+ _loop_32(member);
85887
86076
  }
85888
86077
  }
85889
86078
  /**
@@ -85971,7 +86160,7 @@ var ts;
85971
86160
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
85972
86161
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
85973
86162
  var issuedMemberError = false;
85974
- var _loop_34 = function (member) {
86163
+ var _loop_33 = function (member) {
85975
86164
  if (ts.isStatic(member)) {
85976
86165
  return "continue";
85977
86166
  }
@@ -85990,7 +86179,7 @@ var ts;
85990
86179
  };
85991
86180
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85992
86181
  var member = _a[_i];
85993
- _loop_34(member);
86182
+ _loop_33(member);
85994
86183
  }
85995
86184
  if (!issuedMemberError) {
85996
86185
  // check again with diagnostics to generate a less-specific error
@@ -86061,7 +86250,7 @@ var ts;
86061
86250
  var _a, _b, _c, _d;
86062
86251
  // NOTE: assignability is checked in checkClassDeclaration
86063
86252
  var baseProperties = getPropertiesOfType(baseType);
86064
- var _loop_35 = function (baseProperty) {
86253
+ var _loop_34 = function (baseProperty) {
86065
86254
  var base = getTargetSymbol(baseProperty);
86066
86255
  if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
86067
86256
  return "continue";
@@ -86171,8 +86360,8 @@ var ts;
86171
86360
  };
86172
86361
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
86173
86362
  var baseProperty = baseProperties_1[_i];
86174
- var state_11 = _loop_35(baseProperty);
86175
- switch (state_11) {
86363
+ var state_10 = _loop_34(baseProperty);
86364
+ switch (state_10) {
86176
86365
  case "continue-basePropertyCheck": continue basePropertyCheck;
86177
86366
  }
86178
86367
  }
@@ -86691,12 +86880,11 @@ var ts;
86691
86880
  }
86692
86881
  }
86693
86882
  function checkModuleAugmentationElement(node, isGlobalAugmentation) {
86694
- var _a;
86695
86883
  switch (node.kind) {
86696
86884
  case 240 /* SyntaxKind.VariableStatement */:
86697
86885
  // error each individual name in variable statement instead of marking the entire variable statement
86698
- for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) {
86699
- var decl = _b[_i];
86886
+ for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
86887
+ var decl = _a[_i];
86700
86888
  checkModuleAugmentationElement(decl, isGlobalAugmentation);
86701
86889
  }
86702
86890
  break;
@@ -86712,8 +86900,8 @@ var ts;
86712
86900
  case 257 /* SyntaxKind.VariableDeclaration */:
86713
86901
  var name = node.name;
86714
86902
  if (ts.isBindingPattern(name)) {
86715
- for (var _c = 0, _d = name.elements; _c < _d.length; _c++) {
86716
- var el = _d[_c];
86903
+ for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
86904
+ var el = _c[_b];
86717
86905
  // mark individual names in binding pattern
86718
86906
  checkModuleAugmentationElement(el, isGlobalAugmentation);
86719
86907
  }
@@ -86729,18 +86917,6 @@ var ts;
86729
86917
  if (isGlobalAugmentation) {
86730
86918
  return;
86731
86919
  }
86732
- var symbol = getSymbolOfNode(node);
86733
- if (symbol) {
86734
- // module augmentations cannot introduce new names on the top level scope of the module
86735
- // this is done it two steps
86736
- // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error
86737
- // 2. main check - report error if value declaration of the parent symbol is module augmentation)
86738
- var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */);
86739
- if (!reportError) {
86740
- // symbol should not originate in augmentation
86741
- reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
86742
- }
86743
- }
86744
86920
  break;
86745
86921
  }
86746
86922
  }
@@ -86842,10 +87018,11 @@ var ts;
86842
87018
  }
86843
87019
  return;
86844
87020
  }
87021
+ var targetFlags = getAllSymbolFlags(target);
86845
87022
  var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
86846
87023
  (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
86847
87024
  (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
86848
- if (target.flags & excludedMeanings) {
87025
+ if (targetFlags & excludedMeanings) {
86849
87026
  var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
86850
87027
  ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
86851
87028
  ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
@@ -86855,7 +87032,7 @@ var ts;
86855
87032
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
86856
87033
  && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
86857
87034
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
86858
- var isType = !(target.flags & 111551 /* SymbolFlags.Value */);
87035
+ var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
86859
87036
  if (isType || typeOnlyAlias) {
86860
87037
  switch (node.kind) {
86861
87038
  case 270 /* SyntaxKind.ImportClause */:
@@ -87015,14 +87192,15 @@ var ts;
87015
87192
  if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
87016
87193
  var target = resolveAlias(getSymbolOfNode(node));
87017
87194
  if (target !== unknownSymbol) {
87018
- if (target.flags & 111551 /* SymbolFlags.Value */) {
87195
+ var targetFlags = getAllSymbolFlags(target);
87196
+ if (targetFlags & 111551 /* SymbolFlags.Value */) {
87019
87197
  // Target is a value symbol, check that it is not hidden by a local declaration with the same name
87020
87198
  var moduleName = ts.getFirstIdentifier(node.moduleReference);
87021
87199
  if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
87022
87200
  error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
87023
87201
  }
87024
87202
  }
87025
- if (target.flags & 788968 /* SymbolFlags.Type */) {
87203
+ if (targetFlags & 788968 /* SymbolFlags.Type */) {
87026
87204
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
87027
87205
  }
87028
87206
  }
@@ -87161,7 +87339,7 @@ var ts;
87161
87339
  markExportAsReferenced(node);
87162
87340
  }
87163
87341
  var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
87164
- if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87342
+ if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87165
87343
  checkExpressionCached(node.propertyName || node.name);
87166
87344
  }
87167
87345
  }
@@ -87208,7 +87386,7 @@ var ts;
87208
87386
  markAliasReferenced(sym, id);
87209
87387
  // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
87210
87388
  var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
87211
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87389
+ if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87212
87390
  // However if it is a value, we need to check it's being used correctly
87213
87391
  checkExpressionCached(node.expression);
87214
87392
  }
@@ -87880,29 +88058,9 @@ var ts;
87880
88058
  }
87881
88059
  function isTypeDeclarationName(name) {
87882
88060
  return name.kind === 79 /* SyntaxKind.Identifier */ &&
87883
- isTypeDeclaration(name.parent) &&
88061
+ ts.isTypeDeclaration(name.parent) &&
87884
88062
  ts.getNameOfDeclaration(name.parent) === name;
87885
88063
  }
87886
- function isTypeDeclaration(node) {
87887
- switch (node.kind) {
87888
- case 165 /* SyntaxKind.TypeParameter */:
87889
- case 260 /* SyntaxKind.ClassDeclaration */:
87890
- case 261 /* SyntaxKind.InterfaceDeclaration */:
87891
- case 262 /* SyntaxKind.TypeAliasDeclaration */:
87892
- case 263 /* SyntaxKind.EnumDeclaration */:
87893
- case 348 /* SyntaxKind.JSDocTypedefTag */:
87894
- case 341 /* SyntaxKind.JSDocCallbackTag */:
87895
- case 342 /* SyntaxKind.JSDocEnumTag */:
87896
- return true;
87897
- case 270 /* SyntaxKind.ImportClause */:
87898
- return node.isTypeOnly;
87899
- case 273 /* SyntaxKind.ImportSpecifier */:
87900
- case 278 /* SyntaxKind.ExportSpecifier */:
87901
- return node.parent.parent.isTypeOnly;
87902
- default:
87903
- return false;
87904
- }
87905
- }
87906
88064
  // True if the given identifier is part of a type reference
87907
88065
  function isTypeReferenceIdentifier(node) {
87908
88066
  while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
@@ -88335,7 +88493,7 @@ var ts;
88335
88493
  var baseType = ts.firstOrUndefined(getBaseTypes(classType));
88336
88494
  return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
88337
88495
  }
88338
- if (isTypeDeclaration(node)) {
88496
+ if (ts.isTypeDeclaration(node)) {
88339
88497
  // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
88340
88498
  var symbol = getSymbolOfNode(node);
88341
88499
  return getDeclaredTypeOfSymbol(symbol);
@@ -88530,7 +88688,7 @@ var ts;
88530
88688
  return symbolLinks.exportsSomeValue;
88531
88689
  function isValue(s) {
88532
88690
  s = resolveSymbol(s);
88533
- return s && !!(s.flags & 111551 /* SymbolFlags.Value */);
88691
+ return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
88534
88692
  }
88535
88693
  }
88536
88694
  function isNameOfModuleOrEnumDeclaration(node) {
@@ -88583,7 +88741,7 @@ var ts;
88583
88741
  var symbol = getReferencedValueOrAliasSymbol(node);
88584
88742
  // We should only get the declaration of an alias if there isn't a local value
88585
88743
  // declaration for the symbol
88586
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
88744
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
88587
88745
  return getDeclarationOfAliasSymbol(symbol);
88588
88746
  }
88589
88747
  }
@@ -88671,7 +88829,7 @@ var ts;
88671
88829
  case 273 /* SyntaxKind.ImportSpecifier */:
88672
88830
  case 278 /* SyntaxKind.ExportSpecifier */:
88673
88831
  var symbol = getSymbolOfNode(node);
88674
- return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
88832
+ return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
88675
88833
  case 275 /* SyntaxKind.ExportDeclaration */:
88676
88834
  var exportClause = node.exportClause;
88677
88835
  return !!exportClause && (ts.isNamespaceExport(exportClause) ||
@@ -88693,6 +88851,7 @@ var ts;
88693
88851
  return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
88694
88852
  }
88695
88853
  function isAliasResolvedToValue(symbol) {
88854
+ var _a;
88696
88855
  if (!symbol) {
88697
88856
  return false;
88698
88857
  }
@@ -88702,7 +88861,7 @@ var ts;
88702
88861
  }
88703
88862
  // const enums and modules that contain only const enums are not considered values from the emit perspective
88704
88863
  // unless 'preserveConstEnums' option is set to true
88705
- return !!(target.flags & 111551 /* SymbolFlags.Value */) &&
88864
+ return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
88706
88865
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
88707
88866
  }
88708
88867
  function isConstEnumOrConstEnumOnlyModule(s) {
@@ -88717,7 +88876,7 @@ var ts;
88717
88876
  }
88718
88877
  var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
88719
88878
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
88720
- target.flags & 111551 /* SymbolFlags.Value */ &&
88879
+ getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
88721
88880
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
88722
88881
  // An `export import ... =` of a value symbol is always considered referenced
88723
88882
  return true;
@@ -98371,8 +98530,11 @@ var ts;
98371
98530
  }
98372
98531
  return ts.visitEachChild(node, visitor, context);
98373
98532
  case 174 /* SyntaxKind.GetAccessor */:
98533
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitGetAccessorDeclaration, node);
98374
98534
  case 175 /* SyntaxKind.SetAccessor */:
98535
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitSetAccessorDeclaration, node);
98375
98536
  case 173 /* SyntaxKind.Constructor */:
98537
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitConstructorDeclaration, node);
98376
98538
  case 260 /* SyntaxKind.ClassDeclaration */:
98377
98539
  case 228 /* SyntaxKind.ClassExpression */:
98378
98540
  return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
@@ -98473,6 +98635,9 @@ var ts;
98473
98635
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
98474
98636
  /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
98475
98637
  }
98638
+ function visitConstructorDeclaration(node) {
98639
+ return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98640
+ }
98476
98641
  /**
98477
98642
  * Visits a MethodDeclaration node.
98478
98643
  *
@@ -98487,7 +98652,14 @@ var ts;
98487
98652
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
98488
98653
  /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
98489
98654
  ? transformAsyncFunctionBody(node)
98490
- : ts.visitFunctionBody(node.body, visitor, context));
98655
+ : transformMethodBody(node));
98656
+ }
98657
+ function visitGetAccessorDeclaration(node) {
98658
+ return factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context),
98659
+ /*type*/ undefined, transformMethodBody(node));
98660
+ }
98661
+ function visitSetAccessorDeclaration(node) {
98662
+ return factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98491
98663
  }
98492
98664
  /**
98493
98665
  * Visits a FunctionDeclaration node.
@@ -98601,6 +98773,42 @@ var ts;
98601
98773
  }
98602
98774
  return false;
98603
98775
  }
98776
+ function transformMethodBody(node) {
98777
+ ts.Debug.assertIsDefined(node.body);
98778
+ var savedCapturedSuperProperties = capturedSuperProperties;
98779
+ var savedHasSuperElementAccess = hasSuperElementAccess;
98780
+ capturedSuperProperties = new ts.Set();
98781
+ hasSuperElementAccess = false;
98782
+ var updated = ts.visitFunctionBody(node.body, visitor, context);
98783
+ // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98784
+ // This step isn't needed if we eventually transform this to ES5.
98785
+ var originalMethod = ts.getOriginalNode(node, ts.isFunctionLikeDeclaration);
98786
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ &&
98787
+ resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) &&
98788
+ (ts.getFunctionFlags(originalMethod) & 3 /* FunctionFlags.AsyncGenerator */) !== 3 /* FunctionFlags.AsyncGenerator */;
98789
+ if (emitSuperHelpers) {
98790
+ enableSubstitutionForAsyncMethodsWithSuper();
98791
+ if (capturedSuperProperties.size) {
98792
+ var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
98793
+ substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
98794
+ var statements = updated.statements.slice();
98795
+ ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
98796
+ updated = factory.updateBlock(updated, statements);
98797
+ }
98798
+ if (hasSuperElementAccess) {
98799
+ // Emit helpers for super element access expressions (`super[x]`).
98800
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98801
+ ts.addEmitHelper(updated, ts.advancedAsyncSuperHelper);
98802
+ }
98803
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98804
+ ts.addEmitHelper(updated, ts.asyncSuperHelper);
98805
+ }
98806
+ }
98807
+ }
98808
+ capturedSuperProperties = savedCapturedSuperProperties;
98809
+ hasSuperElementAccess = savedHasSuperElementAccess;
98810
+ return updated;
98811
+ }
98604
98812
  function transformAsyncFunctionBody(node) {
98605
98813
  resumeLexicalEnvironment();
98606
98814
  var original = ts.getOriginalNode(node, ts.isFunctionLike);
@@ -98633,7 +98841,7 @@ var ts;
98633
98841
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
98634
98842
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98635
98843
  // This step isn't needed if we eventually transform this to ES5.
98636
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
98844
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
98637
98845
  if (emitSuperHelpers) {
98638
98846
  enableSubstitutionForAsyncMethodsWithSuper();
98639
98847
  if (capturedSuperProperties.size) {
@@ -98646,10 +98854,10 @@ var ts;
98646
98854
  ts.setTextRange(block, node.body);
98647
98855
  if (emitSuperHelpers && hasSuperElementAccess) {
98648
98856
  // Emit helpers for super element access expressions (`super[x]`).
98649
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
98857
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98650
98858
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
98651
98859
  }
98652
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
98860
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98653
98861
  ts.addEmitHelper(block, ts.asyncSuperHelper);
98654
98862
  }
98655
98863
  }
@@ -98721,7 +98929,7 @@ var ts;
98721
98929
  // If we need to support substitutions for `super` in an async method,
98722
98930
  // we should track it here.
98723
98931
  if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
98724
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
98932
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
98725
98933
  if (superContainerFlags !== enclosingSuperContainerFlags) {
98726
98934
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
98727
98935
  enclosingSuperContainerFlags = superContainerFlags;
@@ -98798,7 +99006,7 @@ var ts;
98798
99006
  || kind === 175 /* SyntaxKind.SetAccessor */;
98799
99007
  }
98800
99008
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
98801
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99009
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98802
99010
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
98803
99011
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
98804
99012
  }
@@ -98813,7 +99021,7 @@ var ts;
98813
99021
  function createSuperAccessVariableStatement(factory, resolver, node, names) {
98814
99022
  // Create a variable declaration with a getter/setter (if binding) definition for each name:
98815
99023
  // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
98816
- var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0;
99024
+ var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) !== 0;
98817
99025
  var accessors = [];
98818
99026
  names.forEach(function (_, key) {
98819
99027
  var name = ts.unescapeLeadingUnderscores(key);
@@ -99306,11 +99514,22 @@ var ts;
99306
99514
  }
99307
99515
  return node;
99308
99516
  }
99309
- function convertForOfStatementHead(node, boundValue) {
99310
- var binding = ts.createForOfBindingStatement(factory, node.initializer, boundValue);
99517
+ function convertForOfStatementHead(node, boundValue, nonUserCode) {
99518
+ var value = factory.createTempVariable(hoistVariableDeclaration);
99519
+ var iteratorValueExpression = factory.createAssignment(value, boundValue);
99520
+ var iteratorValueStatement = factory.createExpressionStatement(iteratorValueExpression);
99521
+ ts.setSourceMapRange(iteratorValueStatement, node.expression);
99522
+ var exitNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createFalse());
99523
+ var exitNonUserCodeStatement = factory.createExpressionStatement(exitNonUserCodeExpression);
99524
+ ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
99525
+ var enterNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createTrue());
99526
+ var enterNonUserCodeStatement = factory.createExpressionStatement(enterNonUserCodeExpression);
99527
+ ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
99528
+ var statements = [];
99529
+ var binding = ts.createForOfBindingStatement(factory, node.initializer, value);
99530
+ statements.push(ts.visitNode(binding, visitor, ts.isStatement));
99311
99531
  var bodyLocation;
99312
99532
  var statementsLocation;
99313
- var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
99314
99533
  var statement = ts.visitIterationBody(node.statement, visitor, context);
99315
99534
  if (ts.isBlock(statement)) {
99316
99535
  ts.addRange(statements, statement.statements);
@@ -99320,8 +99539,16 @@ var ts;
99320
99539
  else {
99321
99540
  statements.push(statement);
99322
99541
  }
99323
- return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
99542
+ var body = ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
99324
99543
  /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */);
99544
+ return factory.createBlock([
99545
+ iteratorValueStatement,
99546
+ exitNonUserCodeStatement,
99547
+ factory.createTryStatement(body,
99548
+ /*catchClause*/ undefined, factory.createBlock([
99549
+ enterNonUserCodeStatement
99550
+ ]))
99551
+ ]);
99325
99552
  }
99326
99553
  function createDownlevelAwait(expression) {
99327
99554
  return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
@@ -99332,6 +99559,8 @@ var ts;
99332
99559
  var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
99333
99560
  var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined);
99334
99561
  var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(/*recordTempVariable*/ undefined);
99562
+ var nonUserCode = factory.createTempVariable(/*recordTempVariable*/ undefined);
99563
+ var done = factory.createTempVariable(hoistVariableDeclaration);
99335
99564
  var errorRecord = factory.createUniqueName("e");
99336
99565
  var catchVariable = factory.getGeneratedNameForNode(errorRecord);
99337
99566
  var returnMethod = factory.createTempVariable(/*recordTempVariable*/ undefined);
@@ -99348,12 +99577,17 @@ var ts;
99348
99577
  callValues;
99349
99578
  var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(
99350
99579
  /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
99580
+ factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
99351
99581
  ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
99352
99582
  factory.createVariableDeclaration(result)
99353
99583
  ]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
99354
- /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)),
99584
+ /*condition*/ factory.inlineExpressions([
99585
+ factory.createAssignment(result, createDownlevelAwait(callNext)),
99586
+ factory.createAssignment(done, getDone),
99587
+ factory.createLogicalNot(done)
99588
+ ]),
99355
99589
  /*incrementor*/ undefined,
99356
- /*statement*/ convertForOfStatementHead(node, getValue)),
99590
+ /*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)),
99357
99591
  /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
99358
99592
  ts.setOriginalNode(forStatement, node);
99359
99593
  return factory.createTryStatement(factory.createBlock([
@@ -99365,7 +99599,7 @@ var ts;
99365
99599
  ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([
99366
99600
  factory.createTryStatement(
99367
99601
  /*tryBlock*/ factory.createBlock([
99368
- ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */)
99602
+ ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(factory.createLogicalNot(nonUserCode), factory.createLogicalNot(done)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */)
99369
99603
  ]),
99370
99604
  /*catchClause*/ undefined,
99371
99605
  /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([
@@ -99521,7 +99755,7 @@ var ts;
99521
99755
  /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
99522
99756
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
99523
99757
  // This step isn't needed if we eventually transform this to ES5.
99524
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
99758
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
99525
99759
  if (emitSuperHelpers) {
99526
99760
  enableSubstitutionForAsyncMethodsWithSuper();
99527
99761
  var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
@@ -99532,10 +99766,10 @@ var ts;
99532
99766
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
99533
99767
  var block = factory.updateBlock(node.body, statements);
99534
99768
  if (emitSuperHelpers && hasSuperElementAccess) {
99535
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99769
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99536
99770
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
99537
99771
  }
99538
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
99772
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
99539
99773
  ts.addEmitHelper(block, ts.asyncSuperHelper);
99540
99774
  }
99541
99775
  }
@@ -99664,7 +99898,7 @@ var ts;
99664
99898
  // If we need to support substitutions for `super` in an async method,
99665
99899
  // we should track it here.
99666
99900
  if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
99667
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
99901
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
99668
99902
  if (superContainerFlags !== enclosingSuperContainerFlags) {
99669
99903
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
99670
99904
  enclosingSuperContainerFlags = superContainerFlags;
@@ -99741,7 +99975,7 @@ var ts;
99741
99975
  || kind === 175 /* SyntaxKind.SetAccessor */;
99742
99976
  }
99743
99977
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
99744
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99978
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99745
99979
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
99746
99980
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
99747
99981
  }
@@ -101210,11 +101444,13 @@ var ts;
101210
101444
  return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
101211
101445
  }
101212
101446
  function visitIdentifier(node) {
101213
- if (!convertedLoopState) {
101214
- return node;
101447
+ if (convertedLoopState) {
101448
+ if (resolver.isArgumentsLocalBinding(node)) {
101449
+ return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101450
+ }
101215
101451
  }
101216
- if (resolver.isArgumentsLocalBinding(node)) {
101217
- return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101452
+ if (node.hasExtendedUnicodeEscape) {
101453
+ return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
101218
101454
  }
101219
101455
  return node;
101220
101456
  }
@@ -105361,7 +105597,6 @@ var ts;
105361
105597
  return node;
105362
105598
  }
105363
105599
  function transformAndEmitForInStatement(node) {
105364
- // TODO(rbuckton): Source map locations
105365
105600
  if (containsYield(node)) {
105366
105601
  // [source]
105367
105602
  // for (var p in o) {
@@ -105369,34 +105604,41 @@ var ts;
105369
105604
  // }
105370
105605
  //
105371
105606
  // [intermediate]
105372
- // .local _a, _b, _i
105373
- // _a = [];
105374
- // for (_b in o) _a.push(_b);
105607
+ // .local _b, _a, _c, _i
105608
+ // _b = [];
105609
+ // _a = o;
105610
+ // for (_c in _a) _b.push(_c);
105375
105611
  // _i = 0;
105376
105612
  // .loop incrementLabel, endLoopLabel
105377
105613
  // .mark conditionLabel
105378
- // .brfalse endLoopLabel, (_i < _a.length)
105379
- // p = _a[_i];
105614
+ // .brfalse endLoopLabel, (_i < _b.length)
105615
+ // _c = _b[_i];
105616
+ // .brfalse incrementLabel, (_c in _a)
105617
+ // p = _c;
105380
105618
  // /*body*/
105381
105619
  // .mark incrementLabel
105382
- // _b++;
105620
+ // _c++;
105383
105621
  // .br conditionLabel
105384
105622
  // .endloop
105385
105623
  // .mark endLoopLabel
105386
- var keysArray = declareLocal(); // _a
105387
- var key = declareLocal(); // _b
105624
+ var obj = declareLocal(); // _a
105625
+ var keysArray = declareLocal(); // _b
105626
+ var key = declareLocal(); // _c
105388
105627
  var keysIndex = factory.createLoopVariable(); // _i
105389
105628
  var initializer = node.initializer;
105390
105629
  hoistVariableDeclaration(keysIndex);
105630
+ emitAssignment(obj, ts.visitNode(node.expression, visitor, ts.isExpression));
105391
105631
  emitAssignment(keysArray, factory.createArrayLiteralExpression());
105392
- emitStatement(factory.createForInStatement(key, ts.visitNode(node.expression, visitor, ts.isExpression), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
105632
+ emitStatement(factory.createForInStatement(key, obj, factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
105393
105633
  /*typeArguments*/ undefined, [key]))));
105394
105634
  emitAssignment(keysIndex, factory.createNumericLiteral(0));
105395
105635
  var conditionLabel = defineLabel();
105396
105636
  var incrementLabel = defineLabel();
105397
- var endLabel = beginLoopBlock(incrementLabel);
105637
+ var endLoopLabel = beginLoopBlock(incrementLabel);
105398
105638
  markLabel(conditionLabel);
105399
- emitBreakWhenFalse(endLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
105639
+ emitBreakWhenFalse(endLoopLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
105640
+ emitAssignment(key, factory.createElementAccessExpression(keysArray, keysIndex));
105641
+ emitBreakWhenFalse(incrementLabel, factory.createBinaryExpression(key, 101 /* SyntaxKind.InKeyword */, obj));
105400
105642
  var variable = void 0;
105401
105643
  if (ts.isVariableDeclarationList(initializer)) {
105402
105644
  for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
@@ -105409,7 +105651,7 @@ var ts;
105409
105651
  variable = ts.visitNode(initializer, visitor, ts.isExpression);
105410
105652
  ts.Debug.assert(ts.isLeftHandSideExpression(variable));
105411
105653
  }
105412
- emitAssignment(variable, factory.createElementAccessExpression(keysArray, keysIndex));
105654
+ emitAssignment(variable, key);
105413
105655
  transformAndEmitEmbeddedStatement(node.statement);
105414
105656
  markLabel(incrementLabel);
105415
105657
  emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
@@ -107250,7 +107492,7 @@ var ts;
107250
107492
  return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
107251
107493
  case ts.ModuleKind.CommonJS:
107252
107494
  default:
107253
- return createImportCallExpressionCommonJS(argument, containsLexicalThis);
107495
+ return createImportCallExpressionCommonJS(argument);
107254
107496
  }
107255
107497
  }
107256
107498
  function createImportCallExpressionUMD(arg, containsLexicalThis) {
@@ -107273,7 +107515,7 @@ var ts;
107273
107515
  return factory.createConditionalExpression(
107274
107516
  /*condition*/ factory.createIdentifier("__syncRequire"),
107275
107517
  /*questionToken*/ undefined,
107276
- /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
107518
+ /*whenTrue*/ createImportCallExpressionCommonJS(arg),
107277
107519
  /*colonToken*/ undefined,
107278
107520
  /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
107279
107521
  }
@@ -107282,7 +107524,7 @@ var ts;
107282
107524
  return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
107283
107525
  /*condition*/ factory.createIdentifier("__syncRequire"),
107284
107526
  /*questionToken*/ undefined,
107285
- /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
107527
+ /*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
107286
107528
  /*colonToken*/ undefined,
107287
107529
  /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
107288
107530
  }
@@ -107332,14 +107574,20 @@ var ts;
107332
107574
  }
107333
107575
  return promise;
107334
107576
  }
107335
- function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
107336
- // import("./blah")
107577
+ function createImportCallExpressionCommonJS(arg, isInlineable) {
107578
+ // import(x)
107337
107579
  // emit as
107338
- // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
107580
+ // var _a;
107581
+ // (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
107339
107582
  // We have to wrap require in then callback so that require is done in asynchronously
107340
107583
  // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
107341
- var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
107342
- var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
107584
+ // If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
107585
+ var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
107586
+ var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
107587
+ /*typeArguments*/ undefined,
107588
+ /*argumentsArray*/ []);
107589
+ var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
107590
+ /*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
107343
107591
  if (ts.getESModuleInterop(compilerOptions)) {
107344
107592
  requireCall = emitHelpers().createImportStarHelper(requireCall);
107345
107593
  }
@@ -107360,14 +107608,9 @@ var ts;
107360
107608
  /*typeParameters*/ undefined,
107361
107609
  /*parameters*/ [],
107362
107610
  /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
107363
- // if there is a lexical 'this' in the import call arguments, ensure we indicate
107364
- // that this new function expression indicates it captures 'this' so that the
107365
- // es2015 transformer will properly substitute 'this' with '_this'.
107366
- if (containsLexicalThis) {
107367
- ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
107368
- }
107369
107611
  }
107370
- return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107612
+ var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
107613
+ return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
107371
107614
  }
107372
107615
  function getHelperExpressionForExport(node, innerExpr) {
107373
107616
  if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
@@ -118360,14 +118603,16 @@ var ts;
118360
118603
  }
118361
118604
  return setReadFileCache(key, fileName);
118362
118605
  };
118363
- var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
118606
+ var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
118364
118607
  var key = toPath(fileName);
118365
- var value = sourceFileCache.get(key);
118608
+ var impliedNodeFormat = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.impliedNodeFormat : undefined;
118609
+ var forImpliedNodeFormat = sourceFileCache.get(impliedNodeFormat);
118610
+ var value = forImpliedNodeFormat === null || forImpliedNodeFormat === void 0 ? void 0 : forImpliedNodeFormat.get(key);
118366
118611
  if (value)
118367
118612
  return value;
118368
- var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
118613
+ var sourceFile = getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
118369
118614
  if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) {
118370
- sourceFileCache.set(key, sourceFile);
118615
+ sourceFileCache.set(impliedNodeFormat, (forImpliedNodeFormat || new ts.Map()).set(key, sourceFile));
118371
118616
  }
118372
118617
  return sourceFile;
118373
118618
  } : undefined;
@@ -118392,13 +118637,15 @@ var ts;
118392
118637
  var value = readFileCache.get(key);
118393
118638
  if (value !== undefined && value !== data) {
118394
118639
  readFileCache.delete(key);
118395
- sourceFileCache.delete(key);
118640
+ sourceFileCache.forEach(function (map) { return map.delete(key); });
118396
118641
  }
118397
118642
  else if (getSourceFileWithCache) {
118398
- var sourceFile = sourceFileCache.get(key);
118399
- if (sourceFile && sourceFile.text !== data) {
118400
- sourceFileCache.delete(key);
118401
- }
118643
+ sourceFileCache.forEach(function (map) {
118644
+ var sourceFile = map.get(key);
118645
+ if (sourceFile && sourceFile.text !== data) {
118646
+ map.delete(key);
118647
+ }
118648
+ });
118402
118649
  }
118403
118650
  originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
118404
118651
  };
@@ -122540,10 +122787,16 @@ var ts;
122540
122787
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
122541
122788
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
122542
122789
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122790
+ // We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged,
122791
+ // which will eg be depedent on change in options like declarationDir and outDir options are unchanged.
122792
+ // We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because
122793
+ // oldCompilerOptions can be undefined if there was change in say module from None to some other option
122794
+ // 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
122795
+ // but that option change does not affect d.ts file name so emitSignatures should still be reused.
122543
122796
  var canCopyEmitSignatures = compilerOptions.composite &&
122544
122797
  (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
122545
122798
  !outFilePath &&
122546
- !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
122799
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122547
122800
  if (useOldState) {
122548
122801
  // Copy old state's changed files set
122549
122802
  (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
@@ -123758,7 +124011,7 @@ var ts;
123758
124011
  var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
123759
124012
  if (isNonDirectorySeparatorRoot &&
123760
124013
  dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
123761
- pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart
124014
+ pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) { // Dos style nextPart
123762
124015
  nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
123763
124016
  if (nextDirectorySeparator === -1) {
123764
124017
  // ignore "//vda1cs4850/c$/folderAtRoot"
@@ -125012,7 +125265,7 @@ var ts;
125012
125265
  });
125013
125266
  // Sort by paths closest to importing file Name directory
125014
125267
  var sortedPaths = [];
125015
- var _loop_36 = function (directory) {
125268
+ var _loop_35 = function (directory) {
125016
125269
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
125017
125270
  var pathsInDirectory;
125018
125271
  allFileNames.forEach(function (_a, fileName) {
@@ -125036,9 +125289,9 @@ var ts;
125036
125289
  };
125037
125290
  var out_directory_1;
125038
125291
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
125039
- var state_12 = _loop_36(directory);
125292
+ var state_11 = _loop_35(directory);
125040
125293
  directory = out_directory_1;
125041
- if (state_12 === "break")
125294
+ if (state_11 === "break")
125042
125295
  break;
125043
125296
  }
125044
125297
  if (allFileNames.size) {
@@ -125107,7 +125360,7 @@ var ts;
125107
125360
  }
125108
125361
  function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
125109
125362
  for (var key in paths) {
125110
- var _loop_37 = function (patternText_1) {
125363
+ var _loop_36 = function (patternText_1) {
125111
125364
  var pattern = ts.normalizePath(patternText_1);
125112
125365
  var indexOfStar = pattern.indexOf("*");
125113
125366
  // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
@@ -125174,9 +125427,9 @@ var ts;
125174
125427
  };
125175
125428
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
125176
125429
  var patternText_1 = _a[_i];
125177
- var state_13 = _loop_37(patternText_1);
125178
- if (typeof state_13 === "object")
125179
- return state_13.value;
125430
+ var state_12 = _loop_36(patternText_1);
125431
+ if (typeof state_12 === "object")
125432
+ return state_12.value;
125180
125433
  }
125181
125434
  }
125182
125435
  function validateEnding(_a) {
@@ -125264,15 +125517,21 @@ var ts;
125264
125517
  return undefined;
125265
125518
  }
125266
125519
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
125267
- var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125268
- if (normalizedTargetPath === undefined) {
125520
+ var normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125521
+ if (normalizedTargetPaths === undefined) {
125522
+ return undefined;
125523
+ }
125524
+ var normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125525
+ var relativePaths = ts.flatMap(normalizedSourcePaths, function (sourcePath) {
125526
+ return ts.map(normalizedTargetPaths, function (targetPath) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName)); });
125527
+ });
125528
+ var shortest = ts.min(relativePaths, ts.compareNumberOfDirectorySeparators);
125529
+ if (!shortest) {
125269
125530
  return undefined;
125270
125531
  }
125271
- var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125272
- var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
125273
125532
  return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
125274
- ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
125275
- : ts.removeFileExtension(relativePath);
125533
+ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions)
125534
+ : ts.removeFileExtension(shortest);
125276
125535
  }
125277
125536
  function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
125278
125537
  var path = _a.path, isRedirect = _a.isRedirect;
@@ -125409,8 +125668,8 @@ var ts;
125409
125668
  }
125410
125669
  }
125411
125670
  }
125412
- function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125413
- return ts.firstDefined(rootDirs, function (rootDir) {
125671
+ function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125672
+ return ts.mapDefined(rootDirs, function (rootDir) {
125414
125673
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
125415
125674
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
125416
125675
  });
@@ -127978,8 +128237,15 @@ var ts;
127978
128237
  }
127979
128238
  if (buildInfo.program) {
127980
128239
  // If there are pending changes that are not emitted, project is out of date
128240
+ // When there are syntax errors, changeFileSet will have list of files changed (irrespective of noEmit)
128241
+ // But in case of semantic error we need special treatment.
128242
+ // Checking presence of affectedFilesPendingEmit list is fast and good way to tell if there were semantic errors and file emit was blocked
128243
+ // 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
128244
+ // So with noEmit set to true, check on semantic diagnostics needs to be explicit as oppose to when it is false when only files pending emit is sufficient
127981
128245
  if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
127982
- (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
128246
+ (!project.options.noEmit ?
128247
+ (_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length :
128248
+ ts.some(buildInfo.program.semanticDiagnosticsPerFile, ts.isArray))) {
127983
128249
  return {
127984
128250
  type: ts.UpToDateStatusType.OutOfDateBuildInfo,
127985
128251
  buildInfoFile: buildInfoPath
@@ -129160,6 +129426,12 @@ var ts;
129160
129426
  SemanticClassificationFormat["Original"] = "original";
129161
129427
  SemanticClassificationFormat["TwentyTwenty"] = "2020";
129162
129428
  })(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
129429
+ var OrganizeImportsMode;
129430
+ (function (OrganizeImportsMode) {
129431
+ OrganizeImportsMode["All"] = "All";
129432
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
129433
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
129434
+ })(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
129163
129435
  var CompletionTriggerKind;
129164
129436
  (function (CompletionTriggerKind) {
129165
129437
  /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
@@ -130205,6 +130477,8 @@ var ts;
130205
130477
  return lastTypeNode;
130206
130478
  }
130207
130479
  function getContextualTypeFromParentOrAncestorTypeNode(node, checker) {
130480
+ if (node.flags & (8388608 /* NodeFlags.JSDoc */ & ~262144 /* NodeFlags.JavaScriptFile */))
130481
+ return undefined;
130208
130482
  var contextualType = getContextualTypeFromParent(node, checker);
130209
130483
  if (contextualType)
130210
130484
  return contextualType;
@@ -132691,6 +132965,10 @@ var ts;
132691
132965
  return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
132692
132966
  }
132693
132967
  ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
132968
+ function isSourceFileFromLibrary(program, node) {
132969
+ return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
132970
+ }
132971
+ ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
132694
132972
  // #endregion
132695
132973
  })(ts || (ts = {}));
132696
132974
  /*@internal*/
@@ -135717,7 +135995,7 @@ var ts;
135717
135995
  if (preferences.includeCompletionsWithClassMemberSnippets &&
135718
135996
  preferences.includeCompletionsWithInsertText &&
135719
135997
  completionKind === 3 /* CompletionKind.MemberLike */ &&
135720
- isClassLikeMemberCompletion(symbol, location)) {
135998
+ isClassLikeMemberCompletion(symbol, location, sourceFile)) {
135721
135999
  var importAdder = void 0;
135722
136000
  (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
135723
136001
  sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
@@ -135789,7 +136067,7 @@ var ts;
135789
136067
  data: data,
135790
136068
  };
135791
136069
  }
135792
- function isClassLikeMemberCompletion(symbol, location) {
136070
+ function isClassLikeMemberCompletion(symbol, location, sourceFile) {
135793
136071
  // TODO: support JS files.
135794
136072
  if (ts.isInJSFile(location)) {
135795
136073
  return false;
@@ -135823,6 +136101,7 @@ var ts;
135823
136101
  location.parent.parent &&
135824
136102
  ts.isClassElement(location.parent) &&
135825
136103
  location === location.parent.name &&
136104
+ location.parent.getLastToken(sourceFile) === location.parent.name &&
135826
136105
  ts.isClassLike(location.parent.parent)) ||
135827
136106
  (location.parent &&
135828
136107
  ts.isSyntaxList(location) &&
@@ -142984,6 +143263,12 @@ var ts;
142984
143263
  var label = ts.getTargetLabel(node.parent, node.text);
142985
143264
  return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
142986
143265
  }
143266
+ if (node.kind === 105 /* SyntaxKind.ReturnKeyword */) {
143267
+ var functionDeclaration = ts.findAncestor(node.parent, function (n) {
143268
+ return ts.isClassStaticBlockDeclaration(n) ? "quit" : ts.isFunctionLikeDeclaration(n);
143269
+ });
143270
+ return functionDeclaration ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] : undefined;
143271
+ }
142987
143272
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
142988
143273
  var classDecl = node.parent.parent;
142989
143274
  var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
@@ -143119,13 +143404,16 @@ var ts;
143119
143404
  if (!baseDeclaration)
143120
143405
  return;
143121
143406
  var baseTypeNode = ts.getEffectiveBaseTypeNode(baseDeclaration);
143122
- var baseType = baseTypeNode ? typeChecker.getTypeAtLocation(baseTypeNode) : undefined;
143123
- if (!baseType)
143407
+ if (!baseTypeNode)
143408
+ return;
143409
+ var expression = ts.skipParentheses(baseTypeNode.expression);
143410
+ var base = ts.isClassExpression(expression) ? expression.symbol : typeChecker.getSymbolAtLocation(expression);
143411
+ if (!base)
143124
143412
  return;
143125
143413
  var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(classElement.name));
143126
143414
  var symbol = ts.hasStaticModifier(classElement)
143127
- ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbolAtLocation(baseType.symbol, baseDeclaration), name)
143128
- : typeChecker.getPropertyOfType(baseType, name);
143415
+ ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbol(base), name)
143416
+ : typeChecker.getPropertyOfType(typeChecker.getDeclaredTypeOfSymbol(base), name);
143129
143417
  if (!symbol)
143130
143418
  return;
143131
143419
  return getDefinitionFromSymbol(typeChecker, symbol, node);
@@ -143832,19 +144120,24 @@ var ts;
143832
144120
  return getCommentOwnerInfoWorker(commentOwner.initializer, options);
143833
144121
  case 260 /* SyntaxKind.ClassDeclaration */:
143834
144122
  case 261 /* SyntaxKind.InterfaceDeclaration */:
143835
- case 168 /* SyntaxKind.PropertySignature */:
143836
144123
  case 263 /* SyntaxKind.EnumDeclaration */:
143837
144124
  case 302 /* SyntaxKind.EnumMember */:
143838
144125
  case 262 /* SyntaxKind.TypeAliasDeclaration */:
143839
144126
  return { commentOwner: commentOwner };
144127
+ case 168 /* SyntaxKind.PropertySignature */: {
144128
+ var host_1 = commentOwner;
144129
+ return host_1.type && ts.isFunctionTypeNode(host_1.type)
144130
+ ? { commentOwner: commentOwner, parameters: host_1.type.parameters, hasReturn: hasReturn(host_1.type, options) }
144131
+ : { commentOwner: commentOwner };
144132
+ }
143840
144133
  case 240 /* SyntaxKind.VariableStatement */: {
143841
144134
  var varStatement = commentOwner;
143842
144135
  var varDeclarations = varStatement.declarationList.declarations;
143843
- var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer
144136
+ var host_2 = varDeclarations.length === 1 && varDeclarations[0].initializer
143844
144137
  ? getRightHandSideOfAssignment(varDeclarations[0].initializer)
143845
144138
  : undefined;
143846
- return host_1
143847
- ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) }
144139
+ return host_2
144140
+ ? { commentOwner: commentOwner, parameters: host_2.parameters, hasReturn: hasReturn(host_2, options) }
143848
144141
  : { commentOwner: commentOwner };
143849
144142
  }
143850
144143
  case 308 /* SyntaxKind.SourceFile */:
@@ -143874,7 +144167,7 @@ var ts;
143874
144167
  }
143875
144168
  function hasReturn(node, options) {
143876
144169
  return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) &&
143877
- (ts.isArrowFunction(node) && ts.isExpression(node.body)
144170
+ (ts.isFunctionTypeNode(node) || ts.isArrowFunction(node) && ts.isExpression(node.body)
143878
144171
  || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }));
143879
144172
  }
143880
144173
  function getRightHandSideOfAssignment(rightHandSide) {
@@ -144915,23 +145208,39 @@ var ts;
144915
145208
  * 2) Coalescing imports from the same module
144916
145209
  * 3) Sorting imports
144917
145210
  */
144918
- function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) {
145211
+ function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
144919
145212
  var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
144920
- var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
145213
+ var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
145214
+ var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
145215
+ var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
145216
+ var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
145217
+ var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
145218
+ var processImportsOfSameModuleSpecifier = function (importGroup) {
145219
+ var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
145220
+ return shouldSort
145221
+ ? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
145222
+ : processedDeclarations;
145223
+ };
144921
145224
  // All of the old ImportDeclarations in the file, in syntactic order.
144922
145225
  var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
144923
- topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144924
- // All of the old ExportDeclarations in the file, in syntactic order.
144925
- var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
144926
- organizeImportsWorker(topLevelExportDecls, coalesceExports);
145226
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
145227
+ // Exports are always used
145228
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
145229
+ // All of the old ExportDeclarations in the file, in syntactic order.
145230
+ var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
145231
+ organizeImportsWorker(topLevelExportDecls, coalesceExports);
145232
+ }
144927
145233
  for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
144928
145234
  var ambientModule = _a[_i];
144929
145235
  if (!ambientModule.body)
144930
145236
  continue;
144931
145237
  var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
144932
- ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144933
- var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
144934
- organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
145238
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
145239
+ // Exports are always used
145240
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
145241
+ var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
145242
+ organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
145243
+ }
144935
145244
  }
144936
145245
  return changeTracker.getChanges();
144937
145246
  function organizeImportsWorker(oldImportDecls, coalesce) {
@@ -144944,8 +145253,12 @@ var ts;
144944
145253
  // Consider: we could do a more careful check that this trivia is actually a header,
144945
145254
  // but the consequences of being wrong are very minor.
144946
145255
  ts.suppressLeadingTrivia(oldImportDecls[0]);
144947
- var oldImportGroups = ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); });
144948
- var sortedImportGroups = ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); });
145256
+ var oldImportGroups = shouldCombine
145257
+ ? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
145258
+ : [oldImportDecls];
145259
+ var sortedImportGroups = shouldSort
145260
+ ? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
145261
+ : oldImportGroups;
144949
145262
  var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
144950
145263
  return getExternalModuleName(importGroup[0].moduleSpecifier)
144951
145264
  ? coalesce(importGroup)
@@ -145009,11 +145322,7 @@ var ts;
145009
145322
  }
145010
145323
  return false;
145011
145324
  }
145012
- function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
145013
- // As a precaution, consider unused import detection to be destructive (GH #43051)
145014
- if (skipDestructiveCodeActions) {
145015
- return oldImports;
145016
- }
145325
+ function removeUnusedImports(oldImports, sourceFile, program) {
145017
145326
  var typeChecker = program.getTypeChecker();
145018
145327
  var compilerOptions = program.getCompilerOptions();
145019
145328
  var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
@@ -145869,7 +146178,7 @@ var ts;
145869
146178
  return bestMatch;
145870
146179
  }
145871
146180
  function betterMatch(a, b) {
145872
- return ts.min(a, b, compareMatches);
146181
+ return ts.min([a, b], compareMatches);
145873
146182
  }
145874
146183
  function compareMatches(a, b) {
145875
146184
  return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
@@ -146478,8 +146787,8 @@ var ts;
146478
146787
  }
146479
146788
  if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
146480
146789
  var stack = [ts.scanner.getToken()];
146481
- var token = ts.scanner.scan();
146482
146790
  loop: while (ts.length(stack)) {
146791
+ var token = ts.scanner.scan();
146483
146792
  switch (token) {
146484
146793
  case 1 /* SyntaxKind.EndOfFileToken */:
146485
146794
  break loop;
@@ -146507,7 +146816,6 @@ var ts;
146507
146816
  }
146508
146817
  break;
146509
146818
  }
146510
- token = ts.scanner.scan();
146511
146819
  }
146512
146820
  nextToken();
146513
146821
  }
@@ -148986,7 +149294,7 @@ var ts;
148986
149294
  tags = signature.getJsDocTags();
148987
149295
  if (allSignatures.length > 1 && documentation.length === 0 && tags.length === 0) {
148988
149296
  documentation = allSignatures[0].getDocumentationComment(typeChecker);
148989
- tags = allSignatures[0].getJsDocTags();
149297
+ tags = allSignatures[0].getJsDocTags().filter(function (tag) { return tag.name !== "deprecated"; }); // should only include @deprecated JSDoc tag on the first overload (#49368)
148990
149298
  }
148991
149299
  }
148992
149300
  function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
@@ -149329,7 +149637,7 @@ var ts;
149329
149637
  return false;
149330
149638
  }
149331
149639
  function shouldRescanJsxText(node) {
149332
- return ts.isJsxText(node);
149640
+ return ts.isJsxText(node) || ts.isJsxElement(node) && (lastTokenInfo === null || lastTokenInfo === void 0 ? void 0 : lastTokenInfo.token.kind) === 11 /* SyntaxKind.JsxText */;
149333
149641
  }
149334
149642
  function shouldRescanSlashToken(container) {
149335
149643
  return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
@@ -150098,10 +150406,10 @@ var ts;
150098
150406
  !nodeIsInDecoratorContext(context.nextTokenParent);
150099
150407
  }
150100
150408
  function nodeIsInDecoratorContext(node) {
150101
- while (ts.isExpressionNode(node)) {
150409
+ while (node && ts.isExpression(node)) {
150102
150410
  node = node.parent;
150103
150411
  }
150104
- return node.kind === 167 /* SyntaxKind.Decorator */;
150412
+ return node && node.kind === 167 /* SyntaxKind.Decorator */;
150105
150413
  }
150106
150414
  function isStartOfVariableDeclarationList(context) {
150107
150415
  return context.currentTokenParent.kind === 258 /* SyntaxKind.VariableDeclarationList */ &&
@@ -153019,6 +153327,26 @@ var ts;
153019
153327
  function startPositionToDeleteNodeInList(sourceFile, node) {
153020
153328
  return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
153021
153329
  }
153330
+ function endPositionToDeleteNodeInList(sourceFile, node, prevNode, nextNode) {
153331
+ var end = startPositionToDeleteNodeInList(sourceFile, nextNode);
153332
+ if (prevNode === undefined || ts.positionsAreOnSameLine(getAdjustedEndPosition(sourceFile, node, {}), end, sourceFile)) {
153333
+ return end;
153334
+ }
153335
+ var token = ts.findPrecedingToken(nextNode.getStart(sourceFile), sourceFile);
153336
+ if (isSeparator(node, token)) {
153337
+ var prevToken = ts.findPrecedingToken(node.getStart(sourceFile), sourceFile);
153338
+ if (isSeparator(prevNode, prevToken)) {
153339
+ var pos = ts.skipTrivia(sourceFile.text, token.getEnd(), /*stopAfterLineBreak*/ true, /*stopAtComments*/ true);
153340
+ if (ts.positionsAreOnSameLine(prevToken.getStart(sourceFile), token.getStart(sourceFile), sourceFile)) {
153341
+ return ts.isLineBreak(sourceFile.text.charCodeAt(pos - 1)) ? pos - 1 : pos;
153342
+ }
153343
+ if (ts.isLineBreak(sourceFile.text.charCodeAt(pos))) {
153344
+ return pos;
153345
+ }
153346
+ }
153347
+ }
153348
+ return end;
153349
+ }
153022
153350
  function getClassOrObjectBraceEnds(cls, sourceFile) {
153023
153351
  var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
153024
153352
  var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
@@ -153576,7 +153904,7 @@ var ts;
153576
153904
  deletedNodesInLists.add(node);
153577
153905
  changes.deleteRange(sourceFile, {
153578
153906
  pos: startPositionToDeleteNodeInList(sourceFile, node),
153579
- end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
153907
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : endPositionToDeleteNodeInList(sourceFile, node, containingList[index - 1], containingList[index + 1]),
153580
153908
  });
153581
153909
  }
153582
153910
  })(textChanges = ts.textChanges || (ts.textChanges = {}));
@@ -154046,6 +154374,15 @@ var ts;
154046
154374
  });
154047
154375
  }
154048
154376
  function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
154377
+ if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
154378
+ var exprType = checker.getTypeAtLocation(insertionSite);
154379
+ var asyncIter = checker.getAsyncIterableType();
154380
+ if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
154381
+ var forOf = insertionSite.parent;
154382
+ changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
154383
+ return;
154384
+ }
154385
+ }
154049
154386
  if (ts.isBinaryExpression(insertionSite)) {
154050
154387
  for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
154051
154388
  var side = _a[_i];
@@ -157771,6 +158108,143 @@ var ts;
157771
158108
  })(ts || (ts = {}));
157772
158109
  /* @internal */
157773
158110
  var ts;
158111
+ (function (ts) {
158112
+ var codefix;
158113
+ (function (codefix) {
158114
+ var fixId = "fixImportNonExportedMember";
158115
+ var errorCodes = [
158116
+ ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
158117
+ ];
158118
+ codefix.registerCodeFix({
158119
+ errorCodes: errorCodes,
158120
+ fixIds: [fixId],
158121
+ getCodeActions: function (context) {
158122
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
158123
+ var info = getInfo(sourceFile, span.start, program);
158124
+ if (info === undefined)
158125
+ return undefined;
158126
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
158127
+ 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)];
158128
+ },
158129
+ getAllCodeActions: function (context) {
158130
+ var program = context.program;
158131
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
158132
+ var exports = new ts.Map();
158133
+ codefix.eachDiagnostic(context, errorCodes, function (diag) {
158134
+ var info = getInfo(diag.file, diag.start, program);
158135
+ if (info === undefined)
158136
+ return undefined;
158137
+ var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
158138
+ if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
158139
+ changes.insertExportModifier(moduleSourceFile, node);
158140
+ }
158141
+ else {
158142
+ var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
158143
+ if (exportName.isTypeOnly) {
158144
+ moduleExports.typeOnlyExports.push(exportName);
158145
+ }
158146
+ else {
158147
+ moduleExports.exports.push(exportName);
158148
+ }
158149
+ exports.set(moduleSourceFile, moduleExports);
158150
+ }
158151
+ });
158152
+ exports.forEach(function (moduleExports, moduleSourceFile) {
158153
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
158154
+ if (exportDeclaration && exportDeclaration.isTypeOnly) {
158155
+ doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
158156
+ doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
158157
+ }
158158
+ else {
158159
+ doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
158160
+ }
158161
+ });
158162
+ }));
158163
+ }
158164
+ });
158165
+ function getInfo(sourceFile, pos, program) {
158166
+ var _a;
158167
+ var token = ts.getTokenAtPosition(sourceFile, pos);
158168
+ if (ts.isIdentifier(token)) {
158169
+ var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
158170
+ if (importDeclaration === undefined)
158171
+ return undefined;
158172
+ var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
158173
+ if (moduleSpecifier === undefined)
158174
+ return undefined;
158175
+ var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
158176
+ if (resolvedModule === undefined)
158177
+ return undefined;
158178
+ var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
158179
+ if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
158180
+ return undefined;
158181
+ var moduleSymbol = moduleSourceFile.symbol;
158182
+ var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
158183
+ if (locals === undefined)
158184
+ return undefined;
158185
+ var localSymbol = locals.get(token.escapedText);
158186
+ if (localSymbol === undefined)
158187
+ return undefined;
158188
+ var node = getNodeOfSymbol(localSymbol);
158189
+ if (node === undefined)
158190
+ return undefined;
158191
+ var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
158192
+ return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
158193
+ }
158194
+ return undefined;
158195
+ }
158196
+ function doChange(changes, program, _a) {
158197
+ var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
158198
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
158199
+ if (exportDeclaration) {
158200
+ updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
158201
+ }
158202
+ else if (ts.canHaveExportModifier(node)) {
158203
+ changes.insertExportModifier(moduleSourceFile, node);
158204
+ }
158205
+ else {
158206
+ createExport(changes, program, moduleSourceFile, [exportName]);
158207
+ }
158208
+ }
158209
+ function doChanges(changes, program, sourceFile, moduleExports, node) {
158210
+ if (ts.length(moduleExports)) {
158211
+ if (node) {
158212
+ updateExport(changes, program, sourceFile, node, moduleExports);
158213
+ }
158214
+ else {
158215
+ createExport(changes, program, sourceFile, moduleExports);
158216
+ }
158217
+ }
158218
+ }
158219
+ function tryGetExportDeclaration(sourceFile, isTypeOnly) {
158220
+ var predicate = function (node) {
158221
+ return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
158222
+ };
158223
+ return ts.findLast(sourceFile.statements, predicate);
158224
+ }
158225
+ function updateExport(changes, program, sourceFile, node, names) {
158226
+ var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
158227
+ var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
158228
+ 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));
158229
+ }
158230
+ function createExport(changes, program, sourceFile, names) {
158231
+ changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
158232
+ }
158233
+ function createExportSpecifiers(names, allowTypeModifier) {
158234
+ return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
158235
+ }
158236
+ function getNodeOfSymbol(symbol) {
158237
+ if (symbol.valueDeclaration === undefined) {
158238
+ return ts.firstOrUndefined(symbol.declarations);
158239
+ }
158240
+ var declaration = symbol.valueDeclaration;
158241
+ var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
158242
+ return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
158243
+ }
158244
+ })(codefix = ts.codefix || (ts.codefix = {}));
158245
+ })(ts || (ts = {}));
158246
+ /* @internal */
158247
+ var ts;
157774
158248
  (function (ts) {
157775
158249
  var codefix;
157776
158250
  (function (codefix) {
@@ -158301,7 +158775,7 @@ var ts;
158301
158775
  var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
158302
158776
  if (argIndex < 0)
158303
158777
  return undefined;
158304
- var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */));
158778
+ var signature = checker.getResolvedSignature(parent.parent);
158305
158779
  if (!(signature && signature.declaration && signature.parameters[argIndex]))
158306
158780
  return undefined;
158307
158781
  var param = signature.parameters[argIndex].valueDeclaration;
@@ -158348,13 +158822,13 @@ var ts;
158348
158822
  if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
158349
158823
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
158350
158824
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
158351
- if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
158825
+ if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
158352
158826
  return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
158353
158827
  }
158354
158828
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
158355
158829
  if (sourceFile.commonJsModuleIndicator)
158356
158830
  return undefined;
158357
- if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
158831
+ if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
158358
158832
  return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
158359
158833
  }
158360
158834
  }
@@ -158364,7 +158838,7 @@ var ts;
158364
158838
  return undefined;
158365
158839
  // Prefer to change the class instead of the interface if they are merged
158366
158840
  var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
158367
- if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
158841
+ if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
158368
158842
  var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
158369
158843
  if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
158370
158844
  return undefined;
@@ -158376,14 +158850,11 @@ var ts;
158376
158850
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
158377
158851
  }
158378
158852
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
158379
- if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158853
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158380
158854
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
158381
158855
  }
158382
158856
  return undefined;
158383
158857
  }
158384
- function isSourceFileFromLibrary(program, node) {
158385
- return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
158386
- }
158387
158858
  function getActionsForMissingMemberDeclaration(context, info) {
158388
158859
  return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
158389
158860
  createActionsForAddMissingMemberInTypeScriptFile(context, info);
@@ -163809,8 +164280,8 @@ var ts;
163809
164280
  var i = 0;
163810
164281
  for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
163811
164282
  var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
163812
- var description = functionExtraction.description;
163813
164283
  if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
164284
+ var description = functionExtraction.description;
163814
164285
  if (functionExtraction.errors.length === 0) {
163815
164286
  // Don't issue refactorings with duplicated names.
163816
164287
  // Scopes come back in "innermost first" order, so extractions will
@@ -163834,15 +164305,15 @@ var ts;
163834
164305
  }
163835
164306
  }
163836
164307
  if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
164308
+ var description = constantExtraction.description;
163837
164309
  if (constantExtraction.errors.length === 0) {
163838
164310
  // Don't issue refactorings with duplicated names.
163839
164311
  // Scopes come back in "innermost first" order, so extractions will
163840
164312
  // preferentially go into nearer scopes
163841
- var description_1 = constantExtraction.description;
163842
- if (!usedConstantNames.has(description_1)) {
163843
- usedConstantNames.set(description_1, true);
164313
+ if (!usedConstantNames.has(description)) {
164314
+ usedConstantNames.set(description, true);
163844
164315
  constantActions.push({
163845
- description: description_1,
164316
+ description: description,
163846
164317
  name: "constant_scope_".concat(i),
163847
164318
  kind: extractConstantAction.kind
163848
164319
  });
@@ -163987,7 +164458,6 @@ var ts;
163987
164458
  var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
163988
164459
  // Do the same for the ending position
163989
164460
  var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
163990
- var declarations = [];
163991
164461
  // We'll modify these flags as we walk the tree to collect data
163992
164462
  // about what things need to be done as part of the extraction.
163993
164463
  var rangeFacts = RangeFacts.None;
@@ -164030,7 +164500,7 @@ var ts;
164030
164500
  // the expression.
164031
164501
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
164032
164502
  }
164033
- return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
164503
+ return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
164034
164504
  }
164035
164505
  if (ts.isReturnStatement(start) && !start.expression) {
164036
164506
  // Makes no sense to extract an expression-less return statement.
@@ -164042,7 +164512,7 @@ var ts;
164042
164512
  if (errors) {
164043
164513
  return { errors: errors };
164044
164514
  }
164045
- return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
164515
+ return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
164046
164516
  /**
164047
164517
  * Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
164048
164518
  * @param node The unrefined extraction node.
@@ -164054,10 +164524,10 @@ var ts;
164054
164524
  }
164055
164525
  }
164056
164526
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
164057
- var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164527
+ var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
164058
164528
  var numInitializers = 0;
164059
164529
  var lastInitializer = void 0;
164060
- for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
164530
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
164061
164531
  var declaration = declarations_5[_i];
164062
164532
  if (declaration.initializer) {
164063
164533
  numInitializers++;
@@ -164157,7 +164627,6 @@ var ts;
164157
164627
  (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
164158
164628
  return true;
164159
164629
  }
164160
- declarations.push(node.symbol);
164161
164630
  }
164162
164631
  // Some things can't be extracted in certain situations
164163
164632
  switch (node.kind) {
@@ -165882,7 +166351,7 @@ var ts;
165882
166351
  function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
165883
166352
  var checker = program.getTypeChecker();
165884
166353
  var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective);
165885
- if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
166354
+ if (oldFile.externalModuleIndicator === undefined && oldFile.commonJsModuleIndicator === undefined && usage.oldImportsNeededByNewFile.size() === 0) {
165886
166355
  deleteMovedStatements(oldFile, toMove.ranges, changes);
165887
166356
  return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
165888
166357
  }
@@ -166123,7 +166592,12 @@ var ts;
166123
166592
  switch (name.kind) {
166124
166593
  case 79 /* SyntaxKind.Identifier */:
166125
166594
  if (isUnused(name)) {
166126
- changes.delete(sourceFile, name);
166595
+ if (varDecl.initializer && ts.isRequireCall(varDecl.initializer, /*requireStringLiteralLikeArgument*/ true)) {
166596
+ changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && ts.length(varDecl.parent.declarations) === 1 ? varDecl.parent.parent : varDecl);
166597
+ }
166598
+ else {
166599
+ changes.delete(sourceFile, name);
166600
+ }
166127
166601
  }
166128
166602
  break;
166129
166603
  case 204 /* SyntaxKind.ArrayBindingPattern */:
@@ -166355,6 +166829,9 @@ var ts;
166355
166829
  ts.copyEntries(this.map, clone.map);
166356
166830
  return clone;
166357
166831
  };
166832
+ SymbolSet.prototype.size = function () {
166833
+ return this.map.size;
166834
+ };
166358
166835
  return SymbolSet;
166359
166836
  }());
166360
166837
  function isTopLevelDeclaration(node) {
@@ -166443,7 +166920,8 @@ var ts;
166443
166920
  if (useEs6Exports) {
166444
166921
  return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText)));
166445
166922
  }
166446
- return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
166923
+ return !!sourceFile.symbol && !!sourceFile.symbol.exports &&
166924
+ getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
166447
166925
  }
166448
166926
  function addExport(decl, useEs6Exports) {
166449
166927
  return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
@@ -168203,8 +168681,8 @@ var ts;
168203
168681
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
168204
168682
  }
168205
168683
  };
168206
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168207
- var declaration = declarations_7[_i];
168684
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
168685
+ var declaration = declarations_6[_i];
168208
168686
  _loop_20(declaration);
168209
168687
  }
168210
168688
  }
@@ -168230,8 +168708,8 @@ var ts;
168230
168708
  if (inheritedDocs)
168231
168709
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
168232
168710
  };
168233
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
168234
- var declaration = declarations_8[_i];
168711
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
168712
+ var declaration = declarations_7[_i];
168235
168713
  _loop_21(declaration);
168236
168714
  }
168237
168715
  }
@@ -169401,12 +169879,14 @@ var ts;
169401
169879
  return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
169402
169880
  }
169403
169881
  function organizeImports(args, formatOptions, preferences) {
169882
+ var _a;
169404
169883
  if (preferences === void 0) { preferences = ts.emptyOptions; }
169405
169884
  synchronizeHostData();
169406
169885
  ts.Debug.assert(args.type === "file");
169407
169886
  var sourceFile = getValidSourceFile(args.fileName);
169408
169887
  var formatContext = ts.formatting.getFormatContext(formatOptions, host);
169409
- return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions);
169888
+ var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
169889
+ return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
169410
169890
  }
169411
169891
  function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
169412
169892
  if (preferences === void 0) { preferences = ts.emptyOptions; }
@@ -171986,6 +172466,12 @@ var ts;
171986
172466
  CommandTypes["ProvideInlayHints"] = "provideInlayHints";
171987
172467
  // NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
171988
172468
  })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {}));
172469
+ var OrganizeImportsMode;
172470
+ (function (OrganizeImportsMode) {
172471
+ OrganizeImportsMode["All"] = "All";
172472
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
172473
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
172474
+ })(OrganizeImportsMode = protocol.OrganizeImportsMode || (protocol.OrganizeImportsMode = {}));
171989
172475
  var WatchFileKind;
171990
172476
  (function (WatchFileKind) {
171991
172477
  WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
@@ -172872,6 +173358,7 @@ var ts;
172872
173358
  this.watchOptions = watchOptions;
172873
173359
  this.rootFiles = [];
172874
173360
  this.rootFilesMap = new ts.Map();
173361
+ /*@internal*/
172875
173362
  this.plugins = [];
172876
173363
  /*@internal*/
172877
173364
  /**
@@ -173400,6 +173887,7 @@ var ts;
173400
173887
  this.directoryStructureHost = undefined;
173401
173888
  this.exportMapCache = undefined;
173402
173889
  this.projectErrors = undefined;
173890
+ this.plugins.length = 0;
173403
173891
  // Clean up file watchers waiting for missing files
173404
173892
  if (this.missingFilesMap) {
173405
173893
  ts.clearMap(this.missingFilesMap, ts.closeFileWatcher);
@@ -174073,35 +174561,39 @@ var ts;
174073
174561
  Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) {
174074
174562
  return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
174075
174563
  };
174564
+ /*@internal*/
174565
+ Project.prototype.getGlobalPluginSearchPaths = function () {
174566
+ // Search any globally-specified probe paths, then our peer node_modules
174567
+ return __spreadArray(__spreadArray([], this.projectService.pluginProbeLocations, true), [
174568
+ // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174569
+ ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
174570
+ ], false);
174571
+ };
174076
174572
  Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
174573
+ if (!this.projectService.globalPlugins.length)
174574
+ return;
174077
174575
  var host = this.projectService.host;
174078
174576
  if (!host.require && !host.importPlugin) {
174079
174577
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
174080
174578
  return;
174081
174579
  }
174082
- // Search any globally-specified probe paths, then our peer node_modules
174083
- var searchPaths = __spreadArray(__spreadArray([], this.projectService.pluginProbeLocations, true), [
174084
- // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174085
- ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
174086
- ], false);
174087
- if (this.projectService.globalPlugins) {
174088
- var _loop_1 = function (globalPluginName) {
174089
- // Skip empty names from odd commandline parses
174090
- if (!globalPluginName)
174091
- return "continue";
174092
- // Skip already-locally-loaded plugins
174093
- if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; }))
174094
- return "continue";
174095
- // Provide global: true so plugins can detect why they can't find their config
174096
- this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName));
174097
- this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides);
174098
- };
174099
- var this_1 = this;
174100
- // Enable global plugins with synthetic configuration entries
174101
- for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
174102
- var globalPluginName = _a[_i];
174103
- _loop_1(globalPluginName);
174104
- }
174580
+ // Enable global plugins with synthetic configuration entries
174581
+ var searchPaths = this.getGlobalPluginSearchPaths();
174582
+ var _loop_1 = function (globalPluginName) {
174583
+ // Skip empty names from odd commandline parses
174584
+ if (!globalPluginName)
174585
+ return "continue";
174586
+ // Skip already-locally-loaded plugins
174587
+ if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; }))
174588
+ return "continue";
174589
+ // Provide global: true so plugins can detect why they can't find their config
174590
+ this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName));
174591
+ this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides);
174592
+ };
174593
+ var this_1 = this;
174594
+ for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
174595
+ var globalPluginName = _a[_i];
174596
+ _loop_1(globalPluginName);
174105
174597
  }
174106
174598
  };
174107
174599
  /**
@@ -174832,14 +175324,16 @@ var ts;
174832
175324
  };
174833
175325
  /*@internal*/
174834
175326
  ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
175327
+ var _a;
175328
+ this.plugins.length = 0;
175329
+ if (!((_a = options.plugins) === null || _a === void 0 ? void 0 : _a.length) && !this.projectService.globalPlugins.length)
175330
+ return;
174835
175331
  var host = this.projectService.host;
174836
175332
  if (!host.require && !host.importPlugin) {
174837
175333
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
174838
175334
  return;
174839
175335
  }
174840
- // Search our peer node_modules, then any globally-specified probe paths
174841
- // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
174842
- var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true);
175336
+ var searchPaths = this.getGlobalPluginSearchPaths();
174843
175337
  if (this.projectService.allowLocalPluginLoads) {
174844
175338
  var local = ts.getDirectoryPath(this.canonicalConfigFilePath);
174845
175339
  this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths"));
@@ -174847,8 +175341,8 @@ var ts;
174847
175341
  }
174848
175342
  // Enable tsconfig-specified plugins
174849
175343
  if (options.plugins) {
174850
- for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) {
174851
- var pluginConfigEntry = _a[_i];
175344
+ for (var _i = 0, _b = options.plugins; _i < _b.length; _i++) {
175345
+ var pluginConfigEntry = _b[_i];
174852
175346
  this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
174853
175347
  }
174854
175348
  }
@@ -175693,18 +176187,20 @@ var ts;
175693
176187
  return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName);
175694
176188
  };
175695
176189
  /* @internal */
175696
- ProjectService.prototype.tryGetDefaultProjectForFile = function (fileName) {
175697
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
176190
+ ProjectService.prototype.tryGetDefaultProjectForFile = function (fileNameOrScriptInfo) {
176191
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
175698
176192
  return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined;
175699
176193
  };
175700
176194
  /* @internal */
175701
- ProjectService.prototype.ensureDefaultProjectForFile = function (fileName) {
175702
- return this.tryGetDefaultProjectForFile(fileName) || this.doEnsureDefaultProjectForFile(fileName);
176195
+ ProjectService.prototype.ensureDefaultProjectForFile = function (fileNameOrScriptInfo) {
176196
+ return this.tryGetDefaultProjectForFile(fileNameOrScriptInfo) || this.doEnsureDefaultProjectForFile(fileNameOrScriptInfo);
175703
176197
  };
175704
- ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) {
176198
+ ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileNameOrScriptInfo) {
175705
176199
  this.ensureProjectStructuresUptoDate();
175706
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
175707
- return scriptInfo ? scriptInfo.getDefaultProject() : (this.logErrorForScriptInfoNotFound(fileName), server.Errors.ThrowNoProject());
176200
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
176201
+ return scriptInfo ?
176202
+ scriptInfo.getDefaultProject() :
176203
+ (this.logErrorForScriptInfoNotFound(ts.isString(fileNameOrScriptInfo) ? fileNameOrScriptInfo : fileNameOrScriptInfo.fileName), server.Errors.ThrowNoProject());
175708
176204
  };
175709
176205
  ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) {
175710
176206
  this.ensureProjectStructuresUptoDate();
@@ -177876,7 +178372,7 @@ var ts;
177876
178372
  if (this.serverMode !== ts.LanguageServiceMode.Semantic || !this.eventHandler || !scriptInfo.isJavaScript() || !ts.addToSeen(this.allJsFilesForOpenFileTelemetry, scriptInfo.path)) {
177877
178373
  return;
177878
178374
  }
177879
- var project = scriptInfo.getDefaultProject();
178375
+ var project = this.ensureDefaultProjectForFile(scriptInfo);
177880
178376
  if (!project.languageServiceEnabled) {
177881
178377
  return;
177882
178378
  }
@@ -180476,6 +180972,10 @@ var ts;
180476
180972
  this.projectService.logErrorForScriptInfoNotFound(args.file);
180477
180973
  return server.Errors.ThrowNoProject();
180478
180974
  }
180975
+ else if (!getScriptInfoEnsuringProjectsUptoDate) {
180976
+ // Ensure there are containing projects are present
180977
+ this.projectService.ensureDefaultProjectForFile(scriptInfo);
180978
+ }
180479
180979
  projects = scriptInfo.containingProjects;
180480
180980
  symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo);
180481
180981
  }
@@ -180544,6 +181044,7 @@ var ts;
180544
181044
  var references = getReferencesWorker(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
180545
181045
  if (!simplifiedResult)
180546
181046
  return references;
181047
+ var preferences = this.getPreferences(file);
180547
181048
  var defaultProject = this.getDefaultProject(args);
180548
181049
  var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file);
180549
181050
  var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position);
@@ -180552,7 +181053,7 @@ var ts;
180552
181053
  var symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0;
180553
181054
  var symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)) : "";
180554
181055
  var refs = ts.flatMap(references, function (referencedSymbol) {
180555
- return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
181056
+ return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
180556
181057
  });
180557
181058
  return { refs: refs, symbolName: symbolName, symbolStartOffset: symbolStartOffset, symbolDisplayString: symbolDisplayString };
180558
181059
  };
@@ -180560,6 +181061,7 @@ var ts;
180560
181061
  var _this = this;
180561
181062
  var projects = this.getProjects(args);
180562
181063
  var fileName = args.file;
181064
+ var preferences = this.getPreferences(server.toNormalizedPath(fileName));
180563
181065
  var references = [];
180564
181066
  var seen = createDocumentSpanSet();
180565
181067
  forEachProjectInProjects(projects, /*path*/ undefined, function (project) {
@@ -180578,7 +181080,7 @@ var ts;
180578
181080
  });
180579
181081
  if (!simplifiedResult)
180580
181082
  return references;
180581
- var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
181083
+ var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
180582
181084
  return {
180583
181085
  refs: refs,
180584
181086
  symbolName: "\"".concat(args.file, "\"")
@@ -180602,13 +181104,7 @@ var ts;
180602
181104
  return this.getFileAndProjectWorker(args.file, args.projectFileName);
180603
181105
  };
180604
181106
  Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) {
180605
- // Since this is syntactic operation, there should always be project for the file
180606
- // throw if we dont get project
180607
- var file = server.toNormalizedPath(args.file);
180608
- var project = this.getProject(args.projectFileName) || this.projectService.ensureDefaultProjectForFile(file);
180609
- if (!project) {
180610
- return server.Errors.ThrowNoProject();
180611
- }
181107
+ var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
180612
181108
  return {
180613
181109
  file: file,
180614
181110
  languageService: project.getLanguageService(/*ensureSynchronized*/ false)
@@ -181149,11 +181645,12 @@ var ts;
181149
181645
  }
181150
181646
  };
181151
181647
  Session.prototype.organizeImports = function (args, simplifiedResult) {
181648
+ var _a;
181152
181649
  ts.Debug.assert(args.scope.type === "file");
181153
- var _a = this.getFileAndProject(args.scope.args), file = _a.file, project = _a.project;
181650
+ var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
181154
181651
  var changes = project.getLanguageService().organizeImports({
181155
181652
  fileName: file,
181156
- skipDestructiveCodeActions: args.skipDestructiveCodeActions,
181653
+ mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
181157
181654
  type: "file",
181158
181655
  }, this.getFormatOptions(file), this.getPreferences(file));
181159
181656
  if (simplifiedResult) {
@@ -181647,14 +182144,18 @@ var ts;
181647
182144
  }
181648
182145
  return text;
181649
182146
  }
181650
- function referenceEntryToReferencesResponseItem(projectService, _a) {
182147
+ function referenceEntryToReferencesResponseItem(projectService, _a, _b) {
181651
182148
  var fileName = _a.fileName, textSpan = _a.textSpan, contextSpan = _a.contextSpan, isWriteAccess = _a.isWriteAccess, isDefinition = _a.isDefinition;
182149
+ var disableLineTextInReferences = _b.disableLineTextInReferences;
181652
182150
  var scriptInfo = ts.Debug.checkDefined(projectService.getScriptInfo(fileName));
181653
182151
  var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo);
181654
- var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1);
181655
- var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
182152
+ var lineText = disableLineTextInReferences ? undefined : getLineText(scriptInfo, span);
181656
182153
  return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition });
181657
182154
  }
182155
+ function getLineText(scriptInfo, span) {
182156
+ var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1);
182157
+ return scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
182158
+ }
181658
182159
  function isCompletionEntryData(data) {
181659
182160
  return data === undefined || data && typeof data === "object"
181660
182161
  && typeof data.exportName === "string"