@typescript-deploys/pr-build 5.1.0-pr-52226-2 → 5.1.0-pr-52845-10

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.
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-insiders.20230306`;
57
+ var version = `${versionMajorMinor}.0-insiders.20230308`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -266,21 +266,6 @@ function some(array, predicate) {
266
266
  }
267
267
  return false;
268
268
  }
269
- function getRangesWhere(arr, pred, cb) {
270
- let start;
271
- for (let i = 0; i < arr.length; i++) {
272
- if (pred(arr[i])) {
273
- start = start === void 0 ? i : start;
274
- } else {
275
- if (start !== void 0) {
276
- cb(start, i);
277
- start = void 0;
278
- }
279
- }
280
- }
281
- if (start !== void 0)
282
- cb(start, arr.length);
283
- }
284
269
  function concatenate(array1, array2) {
285
270
  if (!some(array2))
286
271
  return array1;
@@ -497,41 +482,6 @@ function multiMapRemove(key, value) {
497
482
  }
498
483
  }
499
484
  }
500
- function createQueue(items) {
501
- const elements = (items == null ? void 0 : items.slice()) || [];
502
- let headIndex = 0;
503
- function isEmpty() {
504
- return headIndex === elements.length;
505
- }
506
- function enqueue(...items2) {
507
- elements.push(...items2);
508
- }
509
- function dequeue() {
510
- if (isEmpty()) {
511
- throw new Error("Queue is empty");
512
- }
513
- const result = elements[headIndex];
514
- elements[headIndex] = void 0;
515
- headIndex++;
516
- if (headIndex > 100 && headIndex > elements.length >> 1) {
517
- const newLength = elements.length - headIndex;
518
- elements.copyWithin(
519
- /*target*/
520
- 0,
521
- /*start*/
522
- headIndex
523
- );
524
- elements.length = newLength;
525
- headIndex = 0;
526
- }
527
- return result;
528
- }
529
- return {
530
- enqueue,
531
- dequeue,
532
- isEmpty
533
- };
534
- }
535
485
  function isArray(value) {
536
486
  return Array.isArray(value);
537
487
  }
@@ -541,9 +491,6 @@ function toArray(value) {
541
491
  function isString(text) {
542
492
  return typeof text === "string";
543
493
  }
544
- function tryCast(value, test) {
545
- return value !== void 0 && test(value) ? value : void 0;
546
- }
547
494
  function cast(value, test) {
548
495
  if (value !== void 0 && test(value))
549
496
  return value;
@@ -3269,6 +3216,7 @@ var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
3269
3216
  })(DiagnosticCategory || {});
3270
3217
  var ModuleResolutionKind = /* @__PURE__ */ ((ModuleResolutionKind2) => {
3271
3218
  ModuleResolutionKind2[ModuleResolutionKind2["Classic"] = 1] = "Classic";
3219
+ ModuleResolutionKind2[ModuleResolutionKind2["NodeJs"] = 2] = "NodeJs";
3272
3220
  ModuleResolutionKind2[ModuleResolutionKind2["Node10"] = 2] = "Node10";
3273
3221
  ModuleResolutionKind2[ModuleResolutionKind2["Node16"] = 3] = "Node16";
3274
3222
  ModuleResolutionKind2[ModuleResolutionKind2["NodeNext"] = 99] = "NodeNext";
@@ -6263,12 +6211,14 @@ var Diagnostics = {
6263
6211
  Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set: diag(5096, 1 /* Error */, "Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set_5096", "Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set."),
6264
6212
  An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled: diag(5097, 1 /* Error */, "An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled_5097", "An import path can only end with a '{0}' extension when 'allowImportingTsExtensions' is enabled."),
6265
6213
  Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler: diag(5098, 1 /* Error */, "Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler_5098", "Option '{0}' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'."),
6266
- Flag_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error: diag(5101, 1 /* Error */, "Flag_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecat_5101", `Flag '{0}' is deprecated and will stop functioning in TypeScript {1}. Specify compilerOption '"ignoreDeprecations": "{2}"' to silence this error.`),
6267
- Flag_0_is_deprecated_Please_remove_it_from_your_configuration: diag(5102, 1 /* Error */, "Flag_0_is_deprecated_Please_remove_it_from_your_configuration_5102", "Flag '{0}' is deprecated. Please remove it from your configuration."),
6214
+ Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error: diag(5101, 1 /* Error */, "Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprec_5101", `Option '{0}' is deprecated and will stop functioning in TypeScript {1}. Specify compilerOption '"ignoreDeprecations": "{2}"' to silence this error.`),
6215
+ Option_0_has_been_removed_Please_remove_it_from_your_configuration: diag(5102, 1 /* Error */, "Option_0_has_been_removed_Please_remove_it_from_your_configuration_5102", "Option '{0}' has been removed. Please remove it from your configuration."),
6268
6216
  Invalid_value_for_ignoreDeprecations: diag(5103, 1 /* Error */, "Invalid_value_for_ignoreDeprecations_5103", "Invalid value for '--ignoreDeprecations'."),
6269
6217
  Option_0_is_redundant_and_cannot_be_specified_with_option_1: diag(5104, 1 /* Error */, "Option_0_is_redundant_and_cannot_be_specified_with_option_1_5104", "Option '{0}' is redundant and cannot be specified with option '{1}'."),
6270
6218
  Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System: diag(5105, 1 /* Error */, "Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System_5105", "Option 'verbatimModuleSyntax' cannot be used when 'module' is set to 'UMD', 'AMD', or 'System'."),
6271
6219
  Use_0_instead: diag(5106, 3 /* Message */, "Use_0_instead_5106", "Use '{0}' instead."),
6220
+ Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDeprecations_Colon_3_to_silence_this_error: diag(5107, 1 /* Error */, "Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDepr_5107", `Option '{0}={1}' is deprecated and will stop functioning in TypeScript {2}. Specify compilerOption '"ignoreDeprecations": "{3}"' to silence this error.`),
6221
+ Option_0_1_has_been_removed_Please_remove_it_from_your_configuration: diag(5108, 1 /* Error */, "Option_0_1_has_been_removed_Please_remove_it_from_your_configuration_5108", "Option '{0}={1}' has been removed. Please remove it from your configuration."),
6272
6222
  Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6e3, 3 /* Message */, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."),
6273
6223
  Concatenate_and_emit_output_to_single_file: diag(6001, 3 /* Message */, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."),
6274
6224
  Generates_corresponding_d_ts_file: diag(6002, 3 /* Message */, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
@@ -7785,8 +7735,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
7785
7735
  var text = textInitial;
7786
7736
  var pos;
7787
7737
  var end;
7788
- var startPos;
7789
- var tokenPos;
7738
+ var fullStartPos;
7739
+ var tokenStart;
7790
7740
  var token;
7791
7741
  var tokenValue;
7792
7742
  var tokenFlags;
@@ -7794,11 +7744,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
7794
7744
  var inJSDocType = 0;
7795
7745
  setText(text, start, length2);
7796
7746
  var scanner = {
7797
- getStartPos: () => startPos,
7747
+ getTokenFullStart: () => fullStartPos,
7748
+ getStartPos: () => fullStartPos,
7749
+ getTokenEnd: () => pos,
7798
7750
  getTextPos: () => pos,
7799
7751
  getToken: () => token,
7800
- getTokenPos: () => tokenPos,
7801
- getTokenText: () => text.substring(tokenPos, pos),
7752
+ getTokenStart: () => tokenStart,
7753
+ getTokenPos: () => tokenStart,
7754
+ getTokenText: () => text.substring(tokenStart, pos),
7802
7755
  getTokenValue: () => tokenValue,
7803
7756
  hasUnicodeEscape: () => (tokenFlags & 1024 /* UnicodeEscape */) !== 0,
7804
7757
  hasExtendedUnicodeEscape: () => (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0,
@@ -7832,7 +7785,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
7832
7785
  setScriptTarget,
7833
7786
  setLanguageVariant,
7834
7787
  setOnError,
7835
- setTextPos,
7788
+ resetTokenState,
7789
+ setTextPos: resetTokenState,
7836
7790
  setInJSDocType,
7837
7791
  tryScan,
7838
7792
  lookAhead,
@@ -7842,7 +7796,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
7842
7796
  Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
7843
7797
  get: () => {
7844
7798
  const text2 = scanner.getText();
7845
- return text2.slice(0, scanner.getStartPos()) + "\u2551" + text2.slice(scanner.getStartPos());
7799
+ return text2.slice(0, scanner.getTokenFullStart()) + "\u2551" + text2.slice(scanner.getTokenFullStart());
7846
7800
  }
7847
7801
  });
7848
7802
  }
@@ -8365,11 +8319,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8365
8319
  }
8366
8320
  }
8367
8321
  function scan() {
8368
- startPos = pos;
8322
+ fullStartPos = pos;
8369
8323
  tokenFlags = 0 /* None */;
8370
8324
  let asteriskSeen = false;
8371
8325
  while (true) {
8372
- tokenPos = pos;
8326
+ tokenStart = pos;
8373
8327
  if (pos >= end) {
8374
8328
  return token = 1 /* EndOfFileToken */;
8375
8329
  }
@@ -8528,9 +8482,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8528
8482
  }
8529
8483
  commentDirectives = appendIfCommentDirective(
8530
8484
  commentDirectives,
8531
- text.slice(tokenPos, pos),
8485
+ text.slice(tokenStart, pos),
8532
8486
  commentDirectiveRegExSingleLine,
8533
- tokenPos
8487
+ tokenStart
8534
8488
  );
8535
8489
  if (skipTrivia2) {
8536
8490
  continue;
@@ -8544,7 +8498,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8544
8498
  tokenFlags |= 2 /* PrecedingJSDocComment */;
8545
8499
  }
8546
8500
  let commentClosed = false;
8547
- let lastLineStart = tokenPos;
8501
+ let lastLineStart = tokenStart;
8548
8502
  while (pos < end) {
8549
8503
  const ch2 = text.charCodeAt(pos);
8550
8504
  if (ch2 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
@@ -8822,7 +8776,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8822
8776
  }
8823
8777
  function reScanInvalidIdentifier() {
8824
8778
  Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'.");
8825
- pos = tokenPos = startPos;
8779
+ pos = tokenStart = fullStartPos;
8826
8780
  tokenFlags = 0;
8827
8781
  const ch = codePointAt(text, pos);
8828
8782
  const identifierKind = scanIdentifier(ch, 99 /* ESNext */);
@@ -8838,7 +8792,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8838
8792
  pos += charSize(ch);
8839
8793
  while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion2))
8840
8794
  pos += charSize(ch);
8841
- tokenValue = text.substring(tokenPos, pos);
8795
+ tokenValue = text.substring(tokenStart, pos);
8842
8796
  if (ch === 92 /* backslash */) {
8843
8797
  tokenValue += scanIdentifierParts();
8844
8798
  }
@@ -8869,12 +8823,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8869
8823
  }
8870
8824
  function reScanAsteriskEqualsToken() {
8871
8825
  Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='");
8872
- pos = tokenPos + 1;
8826
+ pos = tokenStart + 1;
8873
8827
  return token = 63 /* EqualsToken */;
8874
8828
  }
8875
8829
  function reScanSlashToken() {
8876
8830
  if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) {
8877
- let p = tokenPos + 1;
8831
+ let p = tokenStart + 1;
8878
8832
  let inEscape = false;
8879
8833
  let inCharacterClass = false;
8880
8834
  while (true) {
@@ -8907,7 +8861,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8907
8861
  p++;
8908
8862
  }
8909
8863
  pos = p;
8910
- tokenValue = text.substring(tokenPos, pos);
8864
+ tokenValue = text.substring(tokenStart, pos);
8911
8865
  token = 13 /* RegularExpressionLiteral */;
8912
8866
  }
8913
8867
  return token;
@@ -8940,41 +8894,41 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8940
8894
  }
8941
8895
  function reScanTemplateToken(isTaggedTemplate) {
8942
8896
  Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'");
8943
- pos = tokenPos;
8897
+ pos = tokenStart;
8944
8898
  return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
8945
8899
  }
8946
8900
  function reScanTemplateHeadOrNoSubstitutionTemplate() {
8947
- pos = tokenPos;
8901
+ pos = tokenStart;
8948
8902
  return token = scanTemplateAndSetTokenValue(
8949
8903
  /* isTaggedTemplate */
8950
8904
  true
8951
8905
  );
8952
8906
  }
8953
8907
  function reScanJsxToken(allowMultilineJsxText = true) {
8954
- pos = tokenPos = startPos;
8908
+ pos = tokenStart = fullStartPos;
8955
8909
  return token = scanJsxToken(allowMultilineJsxText);
8956
8910
  }
8957
8911
  function reScanLessThanToken() {
8958
8912
  if (token === 47 /* LessThanLessThanToken */) {
8959
- pos = tokenPos + 1;
8913
+ pos = tokenStart + 1;
8960
8914
  return token = 29 /* LessThanToken */;
8961
8915
  }
8962
8916
  return token;
8963
8917
  }
8964
8918
  function reScanHashToken() {
8965
8919
  if (token === 80 /* PrivateIdentifier */) {
8966
- pos = tokenPos + 1;
8920
+ pos = tokenStart + 1;
8967
8921
  return token = 62 /* HashToken */;
8968
8922
  }
8969
8923
  return token;
8970
8924
  }
8971
8925
  function reScanQuestionToken() {
8972
8926
  Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'");
8973
- pos = tokenPos + 1;
8927
+ pos = tokenStart + 1;
8974
8928
  return token = 57 /* QuestionToken */;
8975
8929
  }
8976
8930
  function scanJsxToken(allowMultilineJsxText = true) {
8977
- startPos = tokenPos = pos;
8931
+ fullStartPos = tokenStart = pos;
8978
8932
  if (pos >= end) {
8979
8933
  return token = 1 /* EndOfFileToken */;
8980
8934
  }
@@ -9019,7 +8973,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9019
8973
  }
9020
8974
  pos++;
9021
8975
  }
9022
- tokenValue = text.substring(startPos, pos);
8976
+ tokenValue = text.substring(fullStartPos, pos);
9023
8977
  return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */;
9024
8978
  }
9025
8979
  function scanJsxIdentifier() {
@@ -9053,7 +9007,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9053
9007
  return token;
9054
9008
  }
9055
9009
  function scanJsxAttributeValue() {
9056
- startPos = pos;
9010
+ fullStartPos = pos;
9057
9011
  switch (text.charCodeAt(pos)) {
9058
9012
  case 34 /* doubleQuote */:
9059
9013
  case 39 /* singleQuote */:
@@ -9067,11 +9021,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9067
9021
  }
9068
9022
  }
9069
9023
  function reScanJsxAttributeValue() {
9070
- pos = tokenPos = startPos;
9024
+ pos = tokenStart = fullStartPos;
9071
9025
  return scanJsxAttributeValue();
9072
9026
  }
9073
9027
  function scanJsDocToken() {
9074
- startPos = tokenPos = pos;
9028
+ fullStartPos = tokenStart = pos;
9075
9029
  tokenFlags = 0 /* None */;
9076
9030
  if (pos >= end) {
9077
9031
  return token = 1 /* EndOfFileToken */;
@@ -9143,7 +9097,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9143
9097
  let char = ch;
9144
9098
  while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */)
9145
9099
  pos += charSize(char);
9146
- tokenValue = text.substring(tokenPos, pos);
9100
+ tokenValue = text.substring(tokenStart, pos);
9147
9101
  if (char === 92 /* backslash */) {
9148
9102
  tokenValue += scanIdentifierParts();
9149
9103
  }
@@ -9154,16 +9108,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9154
9108
  }
9155
9109
  function speculationHelper(callback, isLookahead) {
9156
9110
  const savePos = pos;
9157
- const saveStartPos = startPos;
9158
- const saveTokenPos = tokenPos;
9111
+ const saveStartPos = fullStartPos;
9112
+ const saveTokenPos = tokenStart;
9159
9113
  const saveToken = token;
9160
9114
  const saveTokenValue = tokenValue;
9161
9115
  const saveTokenFlags = tokenFlags;
9162
9116
  const result = callback();
9163
9117
  if (!result || isLookahead) {
9164
9118
  pos = savePos;
9165
- startPos = saveStartPos;
9166
- tokenPos = saveTokenPos;
9119
+ fullStartPos = saveStartPos;
9120
+ tokenStart = saveTokenPos;
9167
9121
  token = saveToken;
9168
9122
  tokenValue = saveTokenValue;
9169
9123
  tokenFlags = saveTokenFlags;
@@ -9173,8 +9127,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9173
9127
  function scanRange(start2, length3, callback) {
9174
9128
  const saveEnd = end;
9175
9129
  const savePos = pos;
9176
- const saveStartPos = startPos;
9177
- const saveTokenPos = tokenPos;
9130
+ const saveStartPos = fullStartPos;
9131
+ const saveTokenPos = tokenStart;
9178
9132
  const saveToken = token;
9179
9133
  const saveTokenValue = tokenValue;
9180
9134
  const saveTokenFlags = tokenFlags;
@@ -9183,8 +9137,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9183
9137
  const result = callback();
9184
9138
  end = saveEnd;
9185
9139
  pos = savePos;
9186
- startPos = saveStartPos;
9187
- tokenPos = saveTokenPos;
9140
+ fullStartPos = saveStartPos;
9141
+ tokenStart = saveTokenPos;
9188
9142
  token = saveToken;
9189
9143
  tokenValue = saveTokenValue;
9190
9144
  tokenFlags = saveTokenFlags;
@@ -9214,7 +9168,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9214
9168
  function setText(newText, start2, length3) {
9215
9169
  text = newText || "";
9216
9170
  end = length3 === void 0 ? text.length : start2 + length3;
9217
- setTextPos(start2 || 0);
9171
+ resetTokenState(start2 || 0);
9218
9172
  }
9219
9173
  function setOnError(errorCallback) {
9220
9174
  onError = errorCallback;
@@ -9225,11 +9179,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9225
9179
  function setLanguageVariant(variant) {
9226
9180
  languageVariant = variant;
9227
9181
  }
9228
- function setTextPos(textPos) {
9229
- Debug.assert(textPos >= 0);
9230
- pos = textPos;
9231
- startPos = textPos;
9232
- tokenPos = textPos;
9182
+ function resetTokenState(position) {
9183
+ Debug.assert(position >= 0);
9184
+ pos = position;
9185
+ fullStartPos = position;
9186
+ tokenStart = position;
9233
9187
  token = 0 /* Unknown */;
9234
9188
  tokenValue = void 0;
9235
9189
  tokenFlags = 0 /* None */;
@@ -9307,39 +9261,6 @@ function createTextChangeRange(span, newLength) {
9307
9261
  return { span, newLength };
9308
9262
  }
9309
9263
  var unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
9310
- function isParameterPropertyDeclaration(node, parent) {
9311
- return isParameter(node) && hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 173 /* Constructor */;
9312
- }
9313
- function walkUpBindingElementsAndPatterns(binding) {
9314
- let node = binding.parent;
9315
- while (isBindingElement(node.parent)) {
9316
- node = node.parent.parent;
9317
- }
9318
- return node.parent;
9319
- }
9320
- function getCombinedFlags(node, getFlags) {
9321
- if (isBindingElement(node)) {
9322
- node = walkUpBindingElementsAndPatterns(node);
9323
- }
9324
- let flags = getFlags(node);
9325
- if (node.kind === 257 /* VariableDeclaration */) {
9326
- node = node.parent;
9327
- }
9328
- if (node && node.kind === 258 /* VariableDeclarationList */) {
9329
- flags |= getFlags(node);
9330
- node = node.parent;
9331
- }
9332
- if (node && node.kind === 240 /* VariableStatement */) {
9333
- flags |= getFlags(node);
9334
- }
9335
- return flags;
9336
- }
9337
- function getCombinedModifierFlags(node) {
9338
- return getCombinedFlags(node, getEffectiveModifierFlags);
9339
- }
9340
- function getCombinedNodeFlags(node) {
9341
- return getCombinedFlags(node, (n) => n.flags);
9342
- }
9343
9264
  function findAncestor(node, callback) {
9344
9265
  while (node) {
9345
9266
  const result = callback(node);
@@ -9377,10 +9298,6 @@ function unescapeLeadingUnderscores(identifier) {
9377
9298
  function idText(identifierOrPrivateName) {
9378
9299
  return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
9379
9300
  }
9380
- function identifierToKeywordKind(node) {
9381
- const token = stringToToken(node.escapedText);
9382
- return token ? tryCast(token, isKeyword) : void 0;
9383
- }
9384
9301
  function symbolName(symbol) {
9385
9302
  if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) {
9386
9303
  return idText(symbol.valueDeclaration.name);
@@ -9431,15 +9348,6 @@ function getDeclarationIdentifier(node) {
9431
9348
  const name = getNameOfDeclaration(node);
9432
9349
  return name && isIdentifier(name) ? name : void 0;
9433
9350
  }
9434
- function nodeHasName(statement, name) {
9435
- if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
9436
- return true;
9437
- }
9438
- if (isVariableStatement(statement) && some(statement.declarationList.declarations, (d) => nodeHasName(d, name))) {
9439
- return true;
9440
- }
9441
- return false;
9442
- }
9443
9351
  function getNameOfJSDocTypedef(declaration) {
9444
9352
  return declaration.name || nameForNamelessJSDocTypedef(declaration);
9445
9353
  }
@@ -9654,18 +9562,6 @@ function isOptionalChain(node) {
9654
9562
  const kind = node.kind;
9655
9563
  return !!(node.flags & 32 /* OptionalChain */) && (kind === 208 /* PropertyAccessExpression */ || kind === 209 /* ElementAccessExpression */ || kind === 210 /* CallExpression */ || kind === 232 /* NonNullExpression */);
9656
9564
  }
9657
- function isOptionalChainRoot(node) {
9658
- return isOptionalChain(node) && !isNonNullExpression(node) && !!node.questionDotToken;
9659
- }
9660
- function isExpressionOfOptionalChainRoot(node) {
9661
- return isOptionalChainRoot(node.parent) && node.parent.expression === node;
9662
- }
9663
- function isOutermostOptionalChain(node) {
9664
- return !isOptionalChain(node.parent) || isOptionalChainRoot(node.parent) || node !== node.parent.expression;
9665
- }
9666
- function isNullishCoalesce(node) {
9667
- return node.kind === 223 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
9668
- }
9669
9565
  function skipPartiallyEmittedExpressions(node) {
9670
9566
  return skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */);
9671
9567
  }
@@ -9753,12 +9649,6 @@ function isBindingName(node) {
9753
9649
  function isFunctionLike(node) {
9754
9650
  return !!node && isFunctionLikeKind(node.kind);
9755
9651
  }
9756
- function isFunctionLikeOrClassStaticBlockDeclaration(node) {
9757
- return !!node && (isFunctionLikeKind(node.kind) || isClassStaticBlockDeclaration(node));
9758
- }
9759
- function isFunctionLikeDeclaration(node) {
9760
- return node && isFunctionLikeDeclarationKind(node.kind);
9761
- }
9762
9652
  function isFunctionLikeDeclarationKind(kind) {
9763
9653
  switch (kind) {
9764
9654
  case 259 /* FunctionDeclaration */:
@@ -9792,15 +9682,9 @@ function isClassElement(node) {
9792
9682
  const kind = node.kind;
9793
9683
  return kind === 173 /* Constructor */ || kind === 169 /* PropertyDeclaration */ || kind === 171 /* MethodDeclaration */ || kind === 174 /* GetAccessor */ || kind === 175 /* SetAccessor */ || kind === 178 /* IndexSignature */ || kind === 172 /* ClassStaticBlockDeclaration */ || kind === 237 /* SemicolonClassElement */;
9794
9684
  }
9795
- function isClassLike(node) {
9796
- return node && (node.kind === 260 /* ClassDeclaration */ || node.kind === 228 /* ClassExpression */);
9797
- }
9798
9685
  function isAccessor(node) {
9799
9686
  return node && (node.kind === 174 /* GetAccessor */ || node.kind === 175 /* SetAccessor */);
9800
9687
  }
9801
- function isAutoAccessorPropertyDeclaration(node) {
9802
- return isPropertyDeclaration(node) && hasAccessorModifier(node);
9803
- }
9804
9688
  function isMethodOrAccessor(node) {
9805
9689
  switch (node.kind) {
9806
9690
  case 171 /* MethodDeclaration */:
@@ -9950,9 +9834,6 @@ function isExpressionKind(kind) {
9950
9834
  return isUnaryExpressionKind(kind);
9951
9835
  }
9952
9836
  }
9953
- function isForInOrOfStatement(node) {
9954
- return node.kind === 246 /* ForInStatement */ || node.kind === 247 /* ForOfStatement */;
9955
- }
9956
9837
  function isConciseBody(node) {
9957
9838
  return isBlock(node) || isExpression(node);
9958
9839
  }
@@ -9967,114 +9848,6 @@ function isNamedImportBindings(node) {
9967
9848
  const kind = node.kind;
9968
9849
  return kind === 272 /* NamedImports */ || kind === 271 /* NamespaceImport */;
9969
9850
  }
9970
- function canHaveSymbol(node) {
9971
- switch (node.kind) {
9972
- case 216 /* ArrowFunction */:
9973
- case 223 /* BinaryExpression */:
9974
- case 205 /* BindingElement */:
9975
- case 210 /* CallExpression */:
9976
- case 176 /* CallSignature */:
9977
- case 260 /* ClassDeclaration */:
9978
- case 228 /* ClassExpression */:
9979
- case 172 /* ClassStaticBlockDeclaration */:
9980
- case 173 /* Constructor */:
9981
- case 182 /* ConstructorType */:
9982
- case 177 /* ConstructSignature */:
9983
- case 209 /* ElementAccessExpression */:
9984
- case 263 /* EnumDeclaration */:
9985
- case 302 /* EnumMember */:
9986
- case 274 /* ExportAssignment */:
9987
- case 275 /* ExportDeclaration */:
9988
- case 278 /* ExportSpecifier */:
9989
- case 259 /* FunctionDeclaration */:
9990
- case 215 /* FunctionExpression */:
9991
- case 181 /* FunctionType */:
9992
- case 174 /* GetAccessor */:
9993
- case 79 /* Identifier */:
9994
- case 270 /* ImportClause */:
9995
- case 268 /* ImportEqualsDeclaration */:
9996
- case 273 /* ImportSpecifier */:
9997
- case 178 /* IndexSignature */:
9998
- case 261 /* InterfaceDeclaration */:
9999
- case 341 /* JSDocCallbackTag */:
10000
- case 343 /* JSDocEnumTag */:
10001
- case 320 /* JSDocFunctionType */:
10002
- case 344 /* JSDocParameterTag */:
10003
- case 351 /* JSDocPropertyTag */:
10004
- case 326 /* JSDocSignature */:
10005
- case 349 /* JSDocTypedefTag */:
10006
- case 325 /* JSDocTypeLiteral */:
10007
- case 288 /* JsxAttribute */:
10008
- case 289 /* JsxAttributes */:
10009
- case 290 /* JsxSpreadAttribute */:
10010
- case 197 /* MappedType */:
10011
- case 171 /* MethodDeclaration */:
10012
- case 170 /* MethodSignature */:
10013
- case 264 /* ModuleDeclaration */:
10014
- case 199 /* NamedTupleMember */:
10015
- case 277 /* NamespaceExport */:
10016
- case 267 /* NamespaceExportDeclaration */:
10017
- case 271 /* NamespaceImport */:
10018
- case 211 /* NewExpression */:
10019
- case 14 /* NoSubstitutionTemplateLiteral */:
10020
- case 8 /* NumericLiteral */:
10021
- case 207 /* ObjectLiteralExpression */:
10022
- case 166 /* Parameter */:
10023
- case 208 /* PropertyAccessExpression */:
10024
- case 299 /* PropertyAssignment */:
10025
- case 169 /* PropertyDeclaration */:
10026
- case 168 /* PropertySignature */:
10027
- case 175 /* SetAccessor */:
10028
- case 300 /* ShorthandPropertyAssignment */:
10029
- case 308 /* SourceFile */:
10030
- case 301 /* SpreadAssignment */:
10031
- case 10 /* StringLiteral */:
10032
- case 262 /* TypeAliasDeclaration */:
10033
- case 184 /* TypeLiteral */:
10034
- case 165 /* TypeParameter */:
10035
- case 257 /* VariableDeclaration */:
10036
- return true;
10037
- default:
10038
- return false;
10039
- }
10040
- }
10041
- function canHaveLocals(node) {
10042
- switch (node.kind) {
10043
- case 216 /* ArrowFunction */:
10044
- case 238 /* Block */:
10045
- case 176 /* CallSignature */:
10046
- case 266 /* CaseBlock */:
10047
- case 295 /* CatchClause */:
10048
- case 172 /* ClassStaticBlockDeclaration */:
10049
- case 191 /* ConditionalType */:
10050
- case 173 /* Constructor */:
10051
- case 182 /* ConstructorType */:
10052
- case 177 /* ConstructSignature */:
10053
- case 245 /* ForStatement */:
10054
- case 246 /* ForInStatement */:
10055
- case 247 /* ForOfStatement */:
10056
- case 259 /* FunctionDeclaration */:
10057
- case 215 /* FunctionExpression */:
10058
- case 181 /* FunctionType */:
10059
- case 174 /* GetAccessor */:
10060
- case 178 /* IndexSignature */:
10061
- case 341 /* JSDocCallbackTag */:
10062
- case 343 /* JSDocEnumTag */:
10063
- case 320 /* JSDocFunctionType */:
10064
- case 326 /* JSDocSignature */:
10065
- case 349 /* JSDocTypedefTag */:
10066
- case 197 /* MappedType */:
10067
- case 171 /* MethodDeclaration */:
10068
- case 170 /* MethodSignature */:
10069
- case 264 /* ModuleDeclaration */:
10070
- case 175 /* SetAccessor */:
10071
- case 308 /* SourceFile */:
10072
- case 262 /* TypeAliasDeclaration */:
10073
- return true;
10074
- default:
10075
- return false;
10076
- }
10077
- }
10078
9851
  function isDeclarationKind(kind) {
10079
9852
  return kind === 216 /* ArrowFunction */ || kind === 205 /* BindingElement */ || kind === 260 /* ClassDeclaration */ || kind === 228 /* ClassExpression */ || kind === 172 /* ClassStaticBlockDeclaration */ || kind === 173 /* Constructor */ || kind === 263 /* EnumDeclaration */ || kind === 302 /* EnumMember */ || kind === 278 /* ExportSpecifier */ || kind === 259 /* FunctionDeclaration */ || kind === 215 /* FunctionExpression */ || kind === 174 /* GetAccessor */ || kind === 270 /* ImportClause */ || kind === 268 /* ImportEqualsDeclaration */ || kind === 273 /* ImportSpecifier */ || kind === 261 /* InterfaceDeclaration */ || kind === 288 /* JsxAttribute */ || kind === 171 /* MethodDeclaration */ || kind === 170 /* MethodSignature */ || kind === 264 /* ModuleDeclaration */ || kind === 267 /* NamespaceExportDeclaration */ || kind === 271 /* NamespaceImport */ || kind === 277 /* NamespaceExport */ || kind === 166 /* Parameter */ || kind === 299 /* PropertyAssignment */ || kind === 169 /* PropertyDeclaration */ || kind === 168 /* PropertySignature */ || kind === 175 /* SetAccessor */ || kind === 300 /* ShorthandPropertyAssignment */ || kind === 262 /* TypeAliasDeclaration */ || kind === 165 /* TypeParameter */ || kind === 257 /* VariableDeclaration */ || kind === 349 /* JSDocTypedefTag */ || kind === 341 /* JSDocCallbackTag */ || kind === 351 /* JSDocPropertyTag */;
10080
9853
  }
@@ -10090,12 +9863,6 @@ function isDeclaration(node) {
10090
9863
  }
10091
9864
  return isDeclarationKind(node.kind);
10092
9865
  }
10093
- function isDeclarationStatement(node) {
10094
- return isDeclarationStatementKind(node.kind);
10095
- }
10096
- function isStatementButNotDeclaration(node) {
10097
- return isStatementKindButNotDeclarationKind(node.kind);
10098
- }
10099
9866
  function isStatement(node) {
10100
9867
  const kind = node.kind;
10101
9868
  return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) || isBlockStatement(node);
@@ -10155,15 +9922,6 @@ function isStringLiteralLike(node) {
10155
9922
  }
10156
9923
 
10157
9924
  // src/compiler/utilities.ts
10158
- function createSymbolTable(symbols) {
10159
- const result = /* @__PURE__ */ new Map();
10160
- if (symbols) {
10161
- for (const symbol of symbols) {
10162
- result.set(symbol.escapedName, symbol);
10163
- }
10164
- }
10165
- return result;
10166
- }
10167
9925
  var stringWriter = createSingleLineStringWriter();
10168
9926
  function createSingleLineStringWriter() {
10169
9927
  var str = "";
@@ -10257,36 +10015,6 @@ function nodeIsMissing(node) {
10257
10015
  function nodeIsPresent(node) {
10258
10016
  return !nodeIsMissing(node);
10259
10017
  }
10260
- function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
10261
- if (nodeIsMissing(node)) {
10262
- return node.pos;
10263
- }
10264
- if (isJSDocNode(node) || node.kind === 11 /* JsxText */) {
10265
- return skipTrivia(
10266
- (sourceFile || getSourceFileOfNode(node)).text,
10267
- node.pos,
10268
- /*stopAfterLineBreak*/
10269
- false,
10270
- /*stopAtComments*/
10271
- true
10272
- );
10273
- }
10274
- if (includeJsDoc && hasJSDocNodes(node)) {
10275
- return getTokenPosOfNode(node.jsDoc[0], sourceFile);
10276
- }
10277
- if (node.kind === 354 /* SyntaxList */ && node._children.length > 0) {
10278
- return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
10279
- }
10280
- return skipTrivia(
10281
- (sourceFile || getSourceFileOfNode(node)).text,
10282
- node.pos,
10283
- /*stopAfterLineBreak*/
10284
- false,
10285
- /*stopAtComments*/
10286
- false,
10287
- isInJSDoc(node)
10288
- );
10289
- }
10290
10018
  function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia = false) {
10291
10019
  return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
10292
10020
  }
@@ -10303,71 +10031,16 @@ function getTextOfNodeFromSourceText(sourceText, node, includeTrivia = false) {
10303
10031
  }
10304
10032
  return text;
10305
10033
  }
10306
- function getTextOfNode(node, includeTrivia = false) {
10307
- return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
10308
- }
10309
10034
  function getEmitFlags(node) {
10310
10035
  const emitNode = node.emitNode;
10311
10036
  return emitNode && emitNode.flags || 0;
10312
10037
  }
10313
- function isBlockOrCatchScoped(declaration) {
10314
- return (getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration);
10315
- }
10316
- function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
10317
- const node = getRootDeclaration(declaration);
10318
- return node.kind === 257 /* VariableDeclaration */ && node.parent.kind === 295 /* CatchClause */;
10319
- }
10320
- function isAmbientModule(node) {
10321
- return isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node));
10322
- }
10323
10038
  function isModuleWithStringLiteralName(node) {
10324
10039
  return isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */;
10325
10040
  }
10326
- function isEffectiveModuleDeclaration(node) {
10327
- return isModuleDeclaration(node) || isIdentifier(node);
10328
- }
10329
10041
  function isGlobalScopeAugmentation(module2) {
10330
10042
  return !!(module2.flags & 1024 /* GlobalAugmentation */);
10331
10043
  }
10332
- function isModuleAugmentationExternal(node) {
10333
- switch (node.parent.kind) {
10334
- case 308 /* SourceFile */:
10335
- return isExternalModule(node.parent);
10336
- case 265 /* ModuleBlock */:
10337
- return isAmbientModule(node.parent.parent) && isSourceFile(node.parent.parent.parent) && !isExternalModule(node.parent.parent.parent);
10338
- }
10339
- return false;
10340
- }
10341
- function isBlockScope(node, parentNode) {
10342
- switch (node.kind) {
10343
- case 308 /* SourceFile */:
10344
- case 266 /* CaseBlock */:
10345
- case 295 /* CatchClause */:
10346
- case 264 /* ModuleDeclaration */:
10347
- case 245 /* ForStatement */:
10348
- case 246 /* ForInStatement */:
10349
- case 247 /* ForOfStatement */:
10350
- case 173 /* Constructor */:
10351
- case 171 /* MethodDeclaration */:
10352
- case 174 /* GetAccessor */:
10353
- case 175 /* SetAccessor */:
10354
- case 259 /* FunctionDeclaration */:
10355
- case 215 /* FunctionExpression */:
10356
- case 216 /* ArrowFunction */:
10357
- case 169 /* PropertyDeclaration */:
10358
- case 172 /* ClassStaticBlockDeclaration */:
10359
- return true;
10360
- case 238 /* Block */:
10361
- return !isFunctionLikeOrClassStaticBlockDeclaration(parentNode);
10362
- }
10363
- return false;
10364
- }
10365
- function getEnclosingBlockScopeContainer(node) {
10366
- return findAncestor(node.parent, (current) => isBlockScope(current, current.parent));
10367
- }
10368
- function declarationNameToString(name) {
10369
- return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
10370
- }
10371
10044
  function isComputedNonLiteralName(name) {
10372
10045
  return name.kind === 164 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression);
10373
10046
  }
@@ -10416,8 +10089,8 @@ function getSpanOfTokenAtPosition(sourceFile, pos) {
10416
10089
  pos
10417
10090
  );
10418
10091
  scanner.scan();
10419
- const start = scanner.getTokenPos();
10420
- return createTextSpanFromBounds(start, scanner.getTextPos());
10092
+ const start = scanner.getTokenStart();
10093
+ return createTextSpanFromBounds(start, scanner.getTokenEnd());
10421
10094
  }
10422
10095
  function getErrorSpanForArrowFunction(sourceFile, node) {
10423
10096
  const pos = skipTrivia(sourceFile.text, node.pos);
@@ -10433,7 +10106,7 @@ function getErrorSpanForArrowFunction(sourceFile, node) {
10433
10106
  function getErrorSpanForNode(sourceFile, node) {
10434
10107
  let errorNode = node;
10435
10108
  switch (node.kind) {
10436
- case 308 /* SourceFile */:
10109
+ case 308 /* SourceFile */: {
10437
10110
  const pos2 = skipTrivia(
10438
10111
  sourceFile.text,
10439
10112
  0,
@@ -10444,6 +10117,7 @@ function getErrorSpanForNode(sourceFile, node) {
10444
10117
  return createTextSpan(0, 0);
10445
10118
  }
10446
10119
  return getSpanOfTokenAtPosition(sourceFile, pos2);
10120
+ }
10447
10121
  case 257 /* VariableDeclaration */:
10448
10122
  case 205 /* BindingElement */:
10449
10123
  case 260 /* ClassDeclaration */:
@@ -10466,10 +10140,16 @@ function getErrorSpanForNode(sourceFile, node) {
10466
10140
  case 216 /* ArrowFunction */:
10467
10141
  return getErrorSpanForArrowFunction(sourceFile, node);
10468
10142
  case 292 /* CaseClause */:
10469
- case 293 /* DefaultClause */:
10143
+ case 293 /* DefaultClause */: {
10470
10144
  const start = skipTrivia(sourceFile.text, node.pos);
10471
10145
  const end = node.statements.length > 0 ? node.statements[0].pos : node.end;
10472
10146
  return createTextSpanFromBounds(start, end);
10147
+ }
10148
+ case 250 /* ReturnStatement */:
10149
+ case 226 /* YieldExpression */: {
10150
+ const pos2 = skipTrivia(sourceFile.text, node.pos);
10151
+ return getSpanOfTokenAtPosition(sourceFile, pos2);
10152
+ }
10473
10153
  }
10474
10154
  if (errorNode === void 0) {
10475
10155
  return getSpanOfTokenAtPosition(sourceFile, node.pos);
@@ -10492,9 +10172,6 @@ function isExternalOrCommonJsModule(file) {
10492
10172
  function isJsonSourceFile(file) {
10493
10173
  return file.scriptKind === 6 /* JSON */;
10494
10174
  }
10495
- function isEnumConst(node) {
10496
- return !!(getCombinedModifierFlags(node) & 2048 /* Const */);
10497
- }
10498
10175
  function isPrologueDirective(node) {
10499
10176
  return node.kind === 241 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */;
10500
10177
  }
@@ -10533,197 +10210,28 @@ function isVariableLike(node) {
10533
10210
  function isFunctionBlock(node) {
10534
10211
  return node && node.kind === 238 /* Block */ && isFunctionLike(node.parent);
10535
10212
  }
10536
- function isObjectLiteralMethod(node) {
10537
- return node && node.kind === 171 /* MethodDeclaration */ && node.parent.kind === 207 /* ObjectLiteralExpression */;
10538
- }
10539
- function isObjectLiteralOrClassExpressionMethodOrAccessor(node) {
10540
- return (node.kind === 171 /* MethodDeclaration */ || node.kind === 174 /* GetAccessor */ || node.kind === 175 /* SetAccessor */) && (node.parent.kind === 207 /* ObjectLiteralExpression */ || node.parent.kind === 228 /* ClassExpression */);
10541
- }
10542
- function getContainingClass(node) {
10543
- return findAncestor(node.parent, isClassLike);
10544
- }
10545
- function getThisContainer(node, includeArrowFunctions, includeClassComputedPropertyName) {
10546
- Debug.assert(node.kind !== 308 /* SourceFile */);
10547
- while (true) {
10548
- node = node.parent;
10549
- if (!node) {
10550
- return Debug.fail();
10551
- }
10552
- switch (node.kind) {
10553
- case 164 /* ComputedPropertyName */:
10554
- if (includeClassComputedPropertyName && isClassLike(node.parent.parent)) {
10555
- return node;
10556
- }
10557
- node = node.parent.parent;
10558
- break;
10559
- case 167 /* Decorator */:
10560
- if (node.parent.kind === 166 /* Parameter */ && isClassElement(node.parent.parent)) {
10561
- node = node.parent.parent;
10562
- } else if (isClassElement(node.parent)) {
10563
- node = node.parent;
10564
- }
10565
- break;
10566
- case 216 /* ArrowFunction */:
10567
- if (!includeArrowFunctions) {
10568
- continue;
10569
- }
10570
- case 259 /* FunctionDeclaration */:
10571
- case 215 /* FunctionExpression */:
10572
- case 264 /* ModuleDeclaration */:
10573
- case 172 /* ClassStaticBlockDeclaration */:
10574
- case 169 /* PropertyDeclaration */:
10575
- case 168 /* PropertySignature */:
10576
- case 171 /* MethodDeclaration */:
10577
- case 170 /* MethodSignature */:
10578
- case 173 /* Constructor */:
10579
- case 174 /* GetAccessor */:
10580
- case 175 /* SetAccessor */:
10581
- case 176 /* CallSignature */:
10582
- case 177 /* ConstructSignature */:
10583
- case 178 /* IndexSignature */:
10584
- case 263 /* EnumDeclaration */:
10585
- case 308 /* SourceFile */:
10586
- return node;
10587
- }
10588
- }
10589
- }
10590
- function isInTopLevelContext(node) {
10591
- if (isIdentifier(node) && (isClassDeclaration(node.parent) || isFunctionDeclaration(node.parent)) && node.parent.name === node) {
10592
- node = node.parent;
10593
- }
10594
- const container = getThisContainer(
10595
- node,
10596
- /*includeArrowFunctions*/
10597
- true,
10598
- /*includeClassComputedPropertyName*/
10599
- false
10600
- );
10601
- return isSourceFile(container);
10602
- }
10603
- function getImmediatelyInvokedFunctionExpression(func) {
10604
- if (func.kind === 215 /* FunctionExpression */ || func.kind === 216 /* ArrowFunction */) {
10605
- let prev = func;
10606
- let parent = func.parent;
10607
- while (parent.kind === 214 /* ParenthesizedExpression */) {
10608
- prev = parent;
10609
- parent = parent.parent;
10610
- }
10611
- if (parent.kind === 210 /* CallExpression */ && parent.expression === prev) {
10612
- return parent;
10613
- }
10614
- }
10615
- }
10616
10213
  function isSuperProperty(node) {
10617
10214
  const kind = node.kind;
10618
10215
  return (kind === 208 /* PropertyAccessExpression */ || kind === 209 /* ElementAccessExpression */) && node.expression.kind === 106 /* SuperKeyword */;
10619
10216
  }
10620
- function isThisInitializedDeclaration(node) {
10621
- var _a2;
10622
- return !!node && isVariableDeclaration(node) && ((_a2 = node.initializer) == null ? void 0 : _a2.kind) === 108 /* ThisKeyword */;
10623
- }
10624
- function isPartOfTypeQuery(node) {
10625
- while (node.kind === 163 /* QualifiedName */ || node.kind === 79 /* Identifier */) {
10626
- node = node.parent;
10627
- }
10628
- return node.kind === 183 /* TypeQuery */;
10629
- }
10630
10217
  function isInJSFile(node) {
10631
10218
  return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
10632
10219
  }
10633
- function isInJSDoc(node) {
10634
- return !!node && !!(node.flags & 8388608 /* JSDoc */);
10635
- }
10636
- function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
10637
- if (callExpression.kind !== 210 /* CallExpression */) {
10638
- return false;
10639
- }
10640
- const { expression, arguments: args } = callExpression;
10641
- if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") {
10642
- return false;
10643
- }
10644
- if (args.length !== 1) {
10645
- return false;
10646
- }
10647
- const arg = args[0];
10648
- return !requireStringLiteralLikeArgument || isStringLiteralLike(arg);
10220
+ function isStringDoubleQuoted(str, sourceFile) {
10221
+ return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */;
10649
10222
  }
10650
- function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
10651
- return isVariableDeclarationInitializedWithRequireHelper(
10223
+ function getRightMostAssignedExpression(node) {
10224
+ while (isAssignmentExpression(
10652
10225
  node,
10653
- /*allowAccessedRequire*/
10654
- true
10655
- );
10656
- }
10657
- function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
10658
- return isVariableDeclaration(node) && !!node.initializer && isRequireCall(
10659
- allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer,
10660
- /*requireStringLiteralLikeArgument*/
10226
+ /*excludeCompoundAssignments*/
10661
10227
  true
10662
- );
10228
+ )) {
10229
+ node = node.right;
10230
+ }
10231
+ return node;
10663
10232
  }
10664
- function isStringDoubleQuoted(str, sourceFile) {
10665
- return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */;
10666
- }
10667
- function isAssignmentDeclaration(decl) {
10668
- return isBinaryExpression(decl) || isAccessExpression(decl) || isIdentifier(decl) || isCallExpression(decl);
10669
- }
10670
- function hasExpandoValueProperty(node, isPrototypeAssignment) {
10671
- return forEach(node.properties, (p) => isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment));
10672
- }
10673
- function getAssignedExpandoInitializer(node) {
10674
- if (node && node.parent && isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) {
10675
- const isPrototypeAssignment = isPrototypeAccess(node.parent.left);
10676
- return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
10677
- }
10678
- if (node && isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) {
10679
- const result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype");
10680
- if (result) {
10681
- return result;
10682
- }
10683
- }
10684
- }
10685
- function getExpandoInitializer(initializer, isPrototypeAssignment) {
10686
- if (isCallExpression(initializer)) {
10687
- const e = skipParentheses(initializer.expression);
10688
- return e.kind === 215 /* FunctionExpression */ || e.kind === 216 /* ArrowFunction */ ? initializer : void 0;
10689
- }
10690
- if (initializer.kind === 215 /* FunctionExpression */ || initializer.kind === 228 /* ClassExpression */ || initializer.kind === 216 /* ArrowFunction */) {
10691
- return initializer;
10692
- }
10693
- if (isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
10694
- return initializer;
10695
- }
10696
- }
10697
- function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
10698
- const e = isBinaryExpression(initializer) && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment);
10699
- if (e && isSameEntityName(name, initializer.left)) {
10700
- return e;
10701
- }
10702
- }
10703
- function isSameEntityName(name, initializer) {
10704
- if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
10705
- return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
10706
- }
10707
- if (isMemberName(name) && isLiteralLikeAccess(initializer) && (initializer.expression.kind === 108 /* ThisKeyword */ || isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) {
10708
- return isSameEntityName(name, getNameOrArgument(initializer));
10709
- }
10710
- if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
10711
- return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) && isSameEntityName(name.expression, initializer.expression);
10712
- }
10713
- return false;
10714
- }
10715
- function getRightMostAssignedExpression(node) {
10716
- while (isAssignmentExpression(
10717
- node,
10718
- /*excludeCompoundAssignments*/
10719
- true
10720
- )) {
10721
- node = node.right;
10722
- }
10723
- return node;
10724
- }
10725
- function isExportsIdentifier(node) {
10726
- return isIdentifier(node) && node.escapedText === "exports";
10233
+ function isExportsIdentifier(node) {
10234
+ return isIdentifier(node) && node.escapedText === "exports";
10727
10235
  }
10728
10236
  function isModuleIdentifier(node) {
10729
10237
  return isIdentifier(node) && node.escapedText === "module";
@@ -10742,9 +10250,6 @@ function isBindableObjectDefinePropertyCall(expr) {
10742
10250
  true
10743
10251
  );
10744
10252
  }
10745
- function isLiteralLikeAccess(node) {
10746
- return isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
10747
- }
10748
10253
  function isLiteralLikeElementAccess(node) {
10749
10254
  return isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression);
10750
10255
  }
@@ -10765,12 +10270,6 @@ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
10765
10270
  function isBindableStaticNameExpression(node, excludeThisKeyword) {
10766
10271
  return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword);
10767
10272
  }
10768
- function getNameOrArgument(expr) {
10769
- if (isPropertyAccessExpression(expr)) {
10770
- return expr.name;
10771
- }
10772
- return expr.argumentExpression;
10773
- }
10774
10273
  function getAssignmentDeclarationKindWorker(expr) {
10775
10274
  if (isCallExpression(expr)) {
10776
10275
  if (!isBindableObjectDefinePropertyCall(expr)) {
@@ -10860,33 +10359,6 @@ function getInitializerOfBinaryExpression(expr) {
10860
10359
  }
10861
10360
  return expr.right;
10862
10361
  }
10863
- function isSpecialPropertyDeclaration(expr) {
10864
- return isInJSFile(expr) && expr.parent && expr.parent.kind === 241 /* ExpressionStatement */ && (!isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!getJSDocTypeTag(expr.parent);
10865
- }
10866
- function setValueDeclaration(symbol, node) {
10867
- const { valueDeclaration } = symbol;
10868
- if (!valueDeclaration || !(node.flags & 16777216 /* Ambient */ && !isInJSFile(node) && !(valueDeclaration.flags & 16777216 /* Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration)) {
10869
- symbol.valueDeclaration = node;
10870
- }
10871
- }
10872
- function isFunctionSymbol(symbol) {
10873
- if (!symbol || !symbol.valueDeclaration) {
10874
- return false;
10875
- }
10876
- const decl = symbol.valueDeclaration;
10877
- return decl.kind === 259 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
10878
- }
10879
- function isJSDocConstructSignature(node) {
10880
- const param = isJSDocFunctionType(node) ? firstOrUndefined(node.parameters) : void 0;
10881
- const name = tryCast(param && param.name, isIdentifier);
10882
- return !!name && name.escapedText === "new";
10883
- }
10884
- function isJSDocTypeAlias(node) {
10885
- return node.kind === 349 /* JSDocTypedefTag */ || node.kind === 341 /* JSDocCallbackTag */ || node.kind === 343 /* JSDocEnumTag */;
10886
- }
10887
- function getSourceOfAssignment(node) {
10888
- return isExpressionStatement(node) && isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 63 /* EqualsToken */ ? getRightMostAssignedExpression(node.expression) : void 0;
10889
- }
10890
10362
  function getSourceOfDefaultedAssignment(node) {
10891
10363
  return isExpressionStatement(node) && isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && isBinaryExpression(node.expression.right) && (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : void 0;
10892
10364
  }
@@ -11021,149 +10493,19 @@ function getNextJSDocCommentLocation(node) {
11021
10493
  return parent.parent.parent;
11022
10494
  }
11023
10495
  }
11024
- function getEffectiveContainerForJSDocTemplateTag(node) {
11025
- if (isJSDoc(node.parent) && node.parent.tags) {
11026
- const typeAlias = find(node.parent.tags, isJSDocTypeAlias);
11027
- if (typeAlias) {
11028
- return typeAlias;
11029
- }
11030
- }
11031
- return getHostSignatureFromJSDoc(node);
11032
- }
11033
- function getHostSignatureFromJSDoc(node) {
11034
- const host = getEffectiveJSDocHost(node);
11035
- if (host) {
11036
- return isPropertySignature(host) && host.type && isFunctionLike(host.type) ? host.type : isFunctionLike(host) ? host : void 0;
11037
- }
11038
- return void 0;
11039
- }
11040
- function getEffectiveJSDocHost(node) {
11041
- const host = getJSDocHost(node);
11042
- if (host) {
11043
- return getSourceOfDefaultedAssignment(host) || getSourceOfAssignment(host) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) || getSingleVariableOfVariableStatement(host) || getNestedModuleDeclaration(host) || host;
11044
- }
11045
- }
11046
- function getJSDocHost(node) {
11047
- const jsDoc = getJSDocRoot(node);
11048
- if (!jsDoc) {
11049
- return void 0;
11050
- }
11051
- const host = jsDoc.parent;
11052
- if (host && host.jsDoc && jsDoc === lastOrUndefined(host.jsDoc)) {
11053
- return host;
11054
- }
11055
- }
11056
- function getJSDocRoot(node) {
11057
- return findAncestor(node.parent, isJSDoc);
11058
- }
11059
- function getAssignmentTargetKind(node) {
11060
- let parent = node.parent;
11061
- while (true) {
11062
- switch (parent.kind) {
11063
- case 223 /* BinaryExpression */:
11064
- const binaryOperator = parent.operatorToken.kind;
11065
- return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */;
11066
- case 221 /* PrefixUnaryExpression */:
11067
- case 222 /* PostfixUnaryExpression */:
11068
- const unaryOperator = parent.operator;
11069
- return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */;
11070
- case 246 /* ForInStatement */:
11071
- case 247 /* ForOfStatement */:
11072
- return parent.initializer === node ? 1 /* Definite */ : 0 /* None */;
11073
- case 214 /* ParenthesizedExpression */:
11074
- case 206 /* ArrayLiteralExpression */:
11075
- case 227 /* SpreadElement */:
11076
- case 232 /* NonNullExpression */:
11077
- node = parent;
11078
- break;
11079
- case 301 /* SpreadAssignment */:
11080
- node = parent.parent;
11081
- break;
11082
- case 300 /* ShorthandPropertyAssignment */:
11083
- if (parent.name !== node) {
11084
- return 0 /* None */;
11085
- }
11086
- node = parent.parent;
11087
- break;
11088
- case 299 /* PropertyAssignment */:
11089
- if (parent.name === node) {
11090
- return 0 /* None */;
11091
- }
11092
- node = parent.parent;
11093
- break;
11094
- default:
11095
- return 0 /* None */;
11096
- }
11097
- parent = node.parent;
11098
- }
11099
- }
11100
- function isAssignmentTarget(node) {
11101
- return getAssignmentTargetKind(node) !== 0 /* None */;
11102
- }
11103
10496
  function skipParentheses(node, excludeJSDocTypeAssertions) {
11104
10497
  const flags = excludeJSDocTypeAssertions ? 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : 1 /* Parentheses */;
11105
10498
  return skipOuterExpressions(node, flags);
11106
10499
  }
11107
- function isIdentifierName(node) {
11108
- const parent = node.parent;
11109
- switch (parent.kind) {
11110
- case 169 /* PropertyDeclaration */:
11111
- case 168 /* PropertySignature */:
11112
- case 171 /* MethodDeclaration */:
11113
- case 170 /* MethodSignature */:
11114
- case 174 /* GetAccessor */:
11115
- case 175 /* SetAccessor */:
11116
- case 302 /* EnumMember */:
11117
- case 299 /* PropertyAssignment */:
11118
- case 208 /* PropertyAccessExpression */:
11119
- return parent.name === node;
11120
- case 163 /* QualifiedName */:
11121
- return parent.right === node;
11122
- case 205 /* BindingElement */:
11123
- case 273 /* ImportSpecifier */:
11124
- return parent.propertyName === node;
11125
- case 278 /* ExportSpecifier */:
11126
- case 288 /* JsxAttribute */:
11127
- case 282 /* JsxSelfClosingElement */:
11128
- case 283 /* JsxOpeningElement */:
11129
- case 284 /* JsxClosingElement */:
11130
- return true;
11131
- }
11132
- return false;
11133
- }
11134
- function isAliasableExpression(e) {
11135
- return isEntityNameExpression(e) || isClassExpression(e);
11136
- }
11137
- function exportAssignmentIsAlias(node) {
11138
- const e = getExportAssignmentExpression(node);
11139
- return isAliasableExpression(e);
11140
- }
11141
- function getExportAssignmentExpression(node) {
11142
- return isExportAssignment(node) ? node.expression : node.right;
11143
- }
11144
10500
  function isKeyword(token) {
11145
10501
  return 81 /* FirstKeyword */ <= token && token <= 162 /* LastKeyword */;
11146
10502
  }
11147
- function isAsyncFunction(node) {
11148
- switch (node.kind) {
11149
- case 259 /* FunctionDeclaration */:
11150
- case 215 /* FunctionExpression */:
11151
- case 216 /* ArrowFunction */:
11152
- case 171 /* MethodDeclaration */:
11153
- return node.body !== void 0 && node.asteriskToken === void 0 && hasSyntacticModifier(node, 512 /* Async */);
11154
- }
11155
- return false;
11156
- }
11157
10503
  function isStringOrNumericLiteralLike(node) {
11158
10504
  return isStringLiteralLike(node) || isNumericLiteral(node);
11159
10505
  }
11160
10506
  function isSignedNumericLiteral(node) {
11161
10507
  return isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && isNumericLiteral(node.operand);
11162
10508
  }
11163
- function hasDynamicName(declaration) {
11164
- const name = getNameOfDeclaration(declaration);
11165
- return !!name && isDynamicName(name);
11166
- }
11167
10509
  function isDynamicName(name) {
11168
10510
  if (!(name.kind === 164 /* ComputedPropertyName */ || name.kind === 209 /* ElementAccessExpression */)) {
11169
10511
  return false;
@@ -11171,39 +10513,9 @@ function isDynamicName(name) {
11171
10513
  const expr = isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
11172
10514
  return !isStringOrNumericLiteralLike(expr) && !isSignedNumericLiteral(expr);
11173
10515
  }
11174
- function isPropertyNameLiteral(node) {
11175
- switch (node.kind) {
11176
- case 79 /* Identifier */:
11177
- case 10 /* StringLiteral */:
11178
- case 14 /* NoSubstitutionTemplateLiteral */:
11179
- case 8 /* NumericLiteral */:
11180
- return true;
11181
- default:
11182
- return false;
11183
- }
11184
- }
11185
10516
  function getTextOfIdentifierOrLiteral(node) {
11186
10517
  return isMemberName(node) ? idText(node) : node.text;
11187
10518
  }
11188
- function getEscapedTextOfIdentifierOrLiteral(node) {
11189
- return isMemberName(node) ? node.escapedText : escapeLeadingUnderscores(node.text);
11190
- }
11191
- function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) {
11192
- return `__#${getSymbolId(containingClassSymbol)}@${description}`;
11193
- }
11194
- function isPushOrUnshiftIdentifier(node) {
11195
- return node.escapedText === "push" || node.escapedText === "unshift";
11196
- }
11197
- function isParameterDeclaration(node) {
11198
- const root = getRootDeclaration(node);
11199
- return root.kind === 166 /* Parameter */;
11200
- }
11201
- function getRootDeclaration(node) {
11202
- while (node.kind === 205 /* BindingElement */) {
11203
- node = node.parent.parent;
11204
- }
11205
- return node;
11206
- }
11207
10519
  function nodeIsSynthesized(range) {
11208
10520
  return positionIsSynthesized(range.pos) || positionIsSynthesized(range.end);
11209
10521
  }
@@ -11459,15 +10771,6 @@ function identifierIsThisKeyword(id) {
11459
10771
  function hasSyntacticModifier(node, flags) {
11460
10772
  return !!getSelectedSyntacticModifierFlags(node, flags);
11461
10773
  }
11462
- function isStatic(node) {
11463
- return isClassElement(node) && hasStaticModifier(node) || isClassStaticBlockDeclaration(node);
11464
- }
11465
- function hasStaticModifier(node) {
11466
- return hasSyntacticModifier(node, 32 /* Static */);
11467
- }
11468
- function hasAccessorModifier(node) {
11469
- return hasSyntacticModifier(node, 128 /* Accessor */);
11470
- }
11471
10774
  function getSelectedSyntacticModifierFlags(node, flags) {
11472
10775
  return getSyntacticModifierFlags(node) & flags;
11473
10776
  }
@@ -11483,13 +10786,6 @@ function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) {
11483
10786
  }
11484
10787
  return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */);
11485
10788
  }
11486
- function getEffectiveModifierFlags(node) {
11487
- return getModifierFlagsWorker(
11488
- node,
11489
- /*includeJSDoc*/
11490
- true
11491
- );
11492
- }
11493
10789
  function getSyntacticModifierFlags(node) {
11494
10790
  return getModifierFlagsWorker(
11495
10791
  node,
@@ -11573,53 +10869,24 @@ function modifierToFlag(token) {
11573
10869
  }
11574
10870
  return 0 /* None */;
11575
10871
  }
11576
- function isBinaryLogicalOperator(token) {
11577
- return token === 56 /* BarBarToken */ || token === 55 /* AmpersandAmpersandToken */;
11578
- }
11579
10872
  function isLogicalOrCoalescingAssignmentOperator(token) {
11580
10873
  return token === 75 /* BarBarEqualsToken */ || token === 76 /* AmpersandAmpersandEqualsToken */ || token === 77 /* QuestionQuestionEqualsToken */;
11581
10874
  }
11582
- function isLogicalOrCoalescingAssignmentExpression(expr) {
11583
- return isBinaryExpression(expr) && isLogicalOrCoalescingAssignmentOperator(expr.operatorToken.kind);
11584
- }
11585
- function isLogicalOrCoalescingBinaryOperator(token) {
11586
- return isBinaryLogicalOperator(token) || token === 60 /* QuestionQuestionToken */;
11587
- }
11588
- function isLogicalOrCoalescingBinaryExpression(expr) {
11589
- return isBinaryExpression(expr) && isLogicalOrCoalescingBinaryOperator(expr.operatorToken.kind);
11590
- }
11591
10875
  function isAssignmentOperator(token) {
11592
10876
  return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */;
11593
10877
  }
11594
10878
  function isAssignmentExpression(node, excludeCompoundAssignment) {
11595
10879
  return isBinaryExpression(node) && (excludeCompoundAssignment ? node.operatorToken.kind === 63 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && isLeftHandSideExpression(node.left);
11596
10880
  }
11597
- function isDestructuringAssignment(node) {
11598
- if (isAssignmentExpression(
11599
- node,
11600
- /*excludeCompoundAssignment*/
11601
- true
11602
- )) {
11603
- const kind = node.left.kind;
11604
- return kind === 207 /* ObjectLiteralExpression */ || kind === 206 /* ArrayLiteralExpression */;
11605
- }
11606
- return false;
11607
- }
11608
10881
  function isEntityNameExpression(node) {
11609
10882
  return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node);
11610
10883
  }
11611
- function isDottedName(node) {
11612
- return node.kind === 79 /* Identifier */ || node.kind === 108 /* ThisKeyword */ || node.kind === 106 /* SuperKeyword */ || node.kind === 233 /* MetaProperty */ || node.kind === 208 /* PropertyAccessExpression */ && isDottedName(node.expression) || node.kind === 214 /* ParenthesizedExpression */ && isDottedName(node.expression);
11613
- }
11614
10884
  function isPropertyAccessEntityNameExpression(node) {
11615
10885
  return isPropertyAccessExpression(node) && isIdentifier(node.name) && isEntityNameExpression(node.expression);
11616
10886
  }
11617
10887
  function isPrototypeAccess(node) {
11618
10888
  return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype";
11619
10889
  }
11620
- function isEmptyObjectLiteral(expression) {
11621
- return expression.kind === 207 /* ObjectLiteralExpression */ && expression.properties.length === 0;
11622
- }
11623
10890
  function tryExtractTSExtension(fileName) {
11624
10891
  return find(supportedTSExtensionsForExtractExtension, (extension) => fileExtensionIs(fileName, extension));
11625
10892
  }
@@ -11668,12 +10935,6 @@ function isTypeNodeKind(kind) {
11668
10935
  function isAccessExpression(node) {
11669
10936
  return node.kind === 208 /* PropertyAccessExpression */ || node.kind === 209 /* ElementAccessExpression */;
11670
10937
  }
11671
- function getLeftmostAccessExpression(expr) {
11672
- while (isAccessExpression(expr)) {
11673
- expr = expr.expression;
11674
- }
11675
- return expr;
11676
- }
11677
10938
  function getLeftmostExpression(node, stopAtCallExpressions) {
11678
10939
  while (true) {
11679
10940
  switch (node.kind) {
@@ -11923,12 +11184,6 @@ function getEmitModuleResolutionKind(compilerOptions) {
11923
11184
  function getIsolatedModules(options) {
11924
11185
  return !!(options.isolatedModules || options.verbatimModuleSyntax);
11925
11186
  }
11926
- function unreachableCodeIsError(options) {
11927
- return options.allowUnreachableCode === false;
11928
- }
11929
- function unusedLabelIsError(options) {
11930
- return options.allowUnusedLabels === false;
11931
- }
11932
11187
  function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
11933
11188
  return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
11934
11189
  }
@@ -11938,12 +11193,6 @@ function getResolveJsonModule(compilerOptions) {
11938
11193
  }
11939
11194
  return getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */;
11940
11195
  }
11941
- function shouldPreserveConstEnums(compilerOptions) {
11942
- return !!(compilerOptions.preserveConstEnums || getIsolatedModules(compilerOptions));
11943
- }
11944
- function getStrictOptionValue(compilerOptions, flag) {
11945
- return compilerOptions[flag] === void 0 ? !!compilerOptions.strict : !!compilerOptions[flag];
11946
- }
11947
11196
  var reservedCharacterPattern = /[^\w\s\/]/g;
11948
11197
  var wildcardCharCodes = [42 /* asterisk */, 63 /* question */];
11949
11198
  var commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
@@ -12231,11 +11480,6 @@ function matchPatternOrExact(patternOrStrings, candidate) {
12231
11480
  }
12232
11481
  return findBestPatternMatch(patterns, (_) => _, candidate);
12233
11482
  }
12234
- function sliceAfter(arr, value) {
12235
- const index = arr.indexOf(value);
12236
- Debug.assert(index !== -1);
12237
- return arr.slice(index);
12238
- }
12239
11483
  function addRelatedInfo(diagnostic, ...relatedInformation) {
12240
11484
  if (!relatedInformation.length) {
12241
11485
  return diagnostic;
@@ -17556,9 +16800,6 @@ function isMethodSignature(node) {
17556
16800
  function isMethodDeclaration(node) {
17557
16801
  return node.kind === 171 /* MethodDeclaration */;
17558
16802
  }
17559
- function isClassStaticBlockDeclaration(node) {
17560
- return node.kind === 172 /* ClassStaticBlockDeclaration */;
17561
- }
17562
16803
  function isConstructorDeclaration(node) {
17563
16804
  return node.kind === 173 /* Constructor */;
17564
16805
  }
@@ -17682,9 +16923,6 @@ function isFunctionExpression(node) {
17682
16923
  function isArrowFunction(node) {
17683
16924
  return node.kind === 216 /* ArrowFunction */;
17684
16925
  }
17685
- function isTypeOfExpression(node) {
17686
- return node.kind === 218 /* TypeOfExpression */;
17687
- }
17688
16926
  function isVoidExpression(node) {
17689
16927
  return node.kind === 219 /* VoidExpression */;
17690
16928
  }
@@ -17754,9 +16992,6 @@ function isEnumDeclaration(node) {
17754
16992
  function isModuleDeclaration(node) {
17755
16993
  return node.kind === 264 /* ModuleDeclaration */;
17756
16994
  }
17757
- function isModuleBlock(node) {
17758
- return node.kind === 265 /* ModuleBlock */;
17759
- }
17760
16995
  function isCaseBlock(node) {
17761
16996
  return node.kind === 266 /* CaseBlock */;
17762
16997
  }
@@ -17778,9 +17013,6 @@ function isAssertClause(node) {
17778
17013
  function isAssertEntry(node) {
17779
17014
  return node.kind === 297 /* AssertEntry */;
17780
17015
  }
17781
- function isNamespaceExport(node) {
17782
- return node.kind === 277 /* NamespaceExport */;
17783
- }
17784
17016
  function isImportSpecifier(node) {
17785
17017
  return node.kind === 273 /* ImportSpecifier */;
17786
17018
  }
@@ -17826,9 +17058,6 @@ function isCatchClause(node) {
17826
17058
  function isPropertyAssignment(node) {
17827
17059
  return node.kind === 299 /* PropertyAssignment */;
17828
17060
  }
17829
- function isShorthandPropertyAssignment(node) {
17830
- return node.kind === 300 /* ShorthandPropertyAssignment */;
17831
- }
17832
17061
  function isEnumMember(node) {
17833
17062
  return node.kind === 302 /* EnumMember */;
17834
17063
  }
@@ -17865,9 +17094,6 @@ function isJSDocOverrideTag(node) {
17865
17094
  function isJSDocDeprecatedTag(node) {
17866
17095
  return node.kind === 334 /* JSDocDeprecatedTag */;
17867
17096
  }
17868
- function isJSDocEnumTag(node) {
17869
- return node.kind === 343 /* JSDocEnumTag */;
17870
- }
17871
17097
  function isJSDocParameterTag(node) {
17872
17098
  return node.kind === 344 /* JSDocParameterTag */;
17873
17099
  }
@@ -18162,32 +17388,6 @@ var BinaryExpressionState;
18162
17388
  }
18163
17389
  }
18164
17390
  })(BinaryExpressionState || (BinaryExpressionState = {}));
18165
- var BinaryExpressionStateMachine = class {
18166
- constructor(onEnter, onLeft, onOperator, onRight, onExit, foldState) {
18167
- this.onEnter = onEnter;
18168
- this.onLeft = onLeft;
18169
- this.onOperator = onOperator;
18170
- this.onRight = onRight;
18171
- this.onExit = onExit;
18172
- this.foldState = foldState;
18173
- }
18174
- };
18175
- function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) {
18176
- const machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState);
18177
- return trampoline;
18178
- function trampoline(node, outerState) {
18179
- const resultHolder = { value: void 0 };
18180
- const stateStack = [BinaryExpressionState.enter];
18181
- const nodeStack = [node];
18182
- const userStateStack = [void 0];
18183
- let stackIndex = 0;
18184
- while (stateStack[stackIndex] !== BinaryExpressionState.done) {
18185
- stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState);
18186
- }
18187
- Debug.assertEqual(stackIndex, 0);
18188
- return resultHolder.value;
18189
- }
18190
- }
18191
17391
  function formatGeneratedNamePart(part, generateName) {
18192
17392
  return typeof part === "object" ? formatGeneratedName(
18193
17393
  /*privateName*/
@@ -19177,13 +18377,13 @@ var Parser;
19177
18377
  speculationHelper(() => {
19178
18378
  const savedContextFlags = contextFlags;
19179
18379
  contextFlags |= 32768 /* AwaitContext */;
19180
- scanner.setTextPos(nextStatement.pos);
18380
+ scanner.resetTokenState(nextStatement.pos);
19181
18381
  nextToken();
19182
18382
  while (token() !== 1 /* EndOfFileToken */) {
19183
- const startPos = scanner.getStartPos();
18383
+ const startPos = scanner.getTokenFullStart();
19184
18384
  const statement = parseListElement(0 /* SourceElements */, parseStatement);
19185
18385
  statements.push(statement);
19186
- if (startPos === scanner.getStartPos()) {
18386
+ if (startPos === scanner.getTokenFullStart()) {
19187
18387
  nextToken();
19188
18388
  }
19189
18389
  if (pos >= 0) {
@@ -19371,7 +18571,7 @@ var Parser;
19371
18571
  return inContext(32768 /* AwaitContext */);
19372
18572
  }
19373
18573
  function parseErrorAtCurrentToken(message, arg0) {
19374
- return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
18574
+ return parseErrorAt(scanner.getTokenStart(), scanner.getTokenEnd(), message, arg0);
19375
18575
  }
19376
18576
  function parseErrorAtPosition(start, length2, message, arg0) {
19377
18577
  const lastError = lastOrUndefined(parseDiagnostics);
@@ -19390,10 +18590,10 @@ var Parser;
19390
18590
  parseErrorAt(range.pos, range.end, message, arg0);
19391
18591
  }
19392
18592
  function scanError(message, length2) {
19393
- parseErrorAtPosition(scanner.getTextPos(), length2, message);
18593
+ parseErrorAtPosition(scanner.getTokenEnd(), length2, message);
19394
18594
  }
19395
18595
  function getNodePos() {
19396
- return scanner.getStartPos();
18596
+ return scanner.getTokenFullStart();
19397
18597
  }
19398
18598
  function hasPrecedingJSDocComment() {
19399
18599
  return scanner.hasPrecedingJSDocComment();
@@ -19410,7 +18610,7 @@ var Parser;
19410
18610
  }
19411
18611
  function nextToken() {
19412
18612
  if (isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) {
19413
- parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), Diagnostics.Keywords_cannot_contain_escape_characters);
18613
+ parseErrorAt(scanner.getTokenStart(), scanner.getTokenEnd(), Diagnostics.Keywords_cannot_contain_escape_characters);
19414
18614
  }
19415
18615
  return nextTokenWithoutCheck();
19416
18616
  }
@@ -19523,7 +18723,7 @@ var Parser;
19523
18723
  parseErrorForInvalidName(Diagnostics.Interface_name_cannot_be_0, Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */);
19524
18724
  return;
19525
18725
  case "is":
19526
- parseErrorAt(pos, scanner.getTextPos(), Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
18726
+ parseErrorAt(pos, scanner.getTokenStart(), Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
19527
18727
  return;
19528
18728
  case "module":
19529
18729
  case "namespace":
@@ -19678,11 +18878,11 @@ var Parser;
19678
18878
  }
19679
18879
  function createNodeArray(elements, pos, end, hasTrailingComma) {
19680
18880
  const array = factoryCreateNodeArray(elements, hasTrailingComma);
19681
- setTextRangePosEnd(array, pos, end != null ? end : scanner.getStartPos());
18881
+ setTextRangePosEnd(array, pos, end != null ? end : scanner.getTokenFullStart());
19682
18882
  return array;
19683
18883
  }
19684
18884
  function finishNode(node, pos, end) {
19685
- setTextRangePosEnd(node, pos, end != null ? end : scanner.getStartPos());
18885
+ setTextRangePosEnd(node, pos, end != null ? end : scanner.getTokenFullStart());
19686
18886
  if (contextFlags) {
19687
18887
  node.flags |= contextFlags;
19688
18888
  }
@@ -19694,7 +18894,7 @@ var Parser;
19694
18894
  }
19695
18895
  function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
19696
18896
  if (reportAtCurrentPosition) {
19697
- parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
18897
+ parseErrorAtPosition(scanner.getTokenFullStart(), 0, diagnosticMessage, arg0);
19698
18898
  } else if (diagnosticMessage) {
19699
18899
  parseErrorAtCurrentToken(diagnosticMessage, arg0);
19700
18900
  }
@@ -20080,7 +19280,7 @@ var Parser;
20080
19280
  if (!syntaxCursor || !isReusableParsingContext(parsingContext2) || parseErrorBeforeNextFinishedNode) {
20081
19281
  return void 0;
20082
19282
  }
20083
- const node = syntaxCursor.currentNode(pos != null ? pos : scanner.getStartPos());
19283
+ const node = syntaxCursor.currentNode(pos != null ? pos : scanner.getTokenFullStart());
20084
19284
  if (nodeIsMissing(node) || node.intersectsChange || containsParseError(node)) {
20085
19285
  return void 0;
20086
19286
  }
@@ -20097,7 +19297,7 @@ var Parser;
20097
19297
  return node;
20098
19298
  }
20099
19299
  function consumeNode(node) {
20100
- scanner.setTextPos(node.end);
19300
+ scanner.resetTokenState(node.end);
20101
19301
  nextToken();
20102
19302
  return node;
20103
19303
  }
@@ -20311,14 +19511,14 @@ var Parser;
20311
19511
  /*inErrorRecovery*/
20312
19512
  false
20313
19513
  )) {
20314
- const startPos = scanner.getStartPos();
19514
+ const startPos = scanner.getTokenFullStart();
20315
19515
  const result = parseListElement(kind, parseElement);
20316
19516
  if (!result) {
20317
19517
  parsingContext = saveParsingContext;
20318
19518
  return void 0;
20319
19519
  }
20320
19520
  list.push(result);
20321
- commaStart = scanner.getTokenPos();
19521
+ commaStart = scanner.getTokenStart();
20322
19522
  if (parseOptional(27 /* CommaToken */)) {
20323
19523
  continue;
20324
19524
  }
@@ -20330,7 +19530,7 @@ var Parser;
20330
19530
  if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) {
20331
19531
  nextToken();
20332
19532
  }
20333
- if (startPos === scanner.getStartPos()) {
19533
+ if (startPos === scanner.getTokenFullStart()) {
20334
19534
  nextToken();
20335
19535
  }
20336
19536
  continue;
@@ -21159,7 +20359,7 @@ var Parser;
21159
20359
  }
21160
20360
  function parseImportTypeAssertions() {
21161
20361
  const pos = getNodePos();
21162
- const openBracePosition = scanner.getTokenPos();
20362
+ const openBracePosition = scanner.getTokenStart();
21163
20363
  parseExpected(18 /* OpenBraceToken */);
21164
20364
  const multiLine = scanner.hasPrecedingLineBreak();
21165
20365
  parseExpected(130 /* AssertKeyword */);
@@ -21833,7 +21033,7 @@ var Parser;
21833
21033
  }
21834
21034
  }
21835
21035
  function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
21836
- const tokenPos = scanner.getTokenPos();
21036
+ const tokenPos = scanner.getTokenStart();
21837
21037
  if (notParenthesizedArrow == null ? void 0 : notParenthesizedArrow.has(tokenPos)) {
21838
21038
  return void 0;
21839
21039
  }
@@ -22732,7 +21932,7 @@ var Parser;
22732
21932
  }
22733
21933
  function parseArrayLiteralExpression() {
22734
21934
  const pos = getNodePos();
22735
- const openBracketPosition = scanner.getTokenPos();
21935
+ const openBracketPosition = scanner.getTokenStart();
22736
21936
  const openBracketParsed = parseExpected(22 /* OpenBracketToken */);
22737
21937
  const multiLine = scanner.hasPrecedingLineBreak();
22738
21938
  const elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
@@ -22792,7 +21992,7 @@ var Parser;
22792
21992
  }
22793
21993
  function parseObjectLiteralExpression() {
22794
21994
  const pos = getNodePos();
22795
- const openBracePosition = scanner.getTokenPos();
21995
+ const openBracePosition = scanner.getTokenStart();
22796
21996
  const openBraceParsed = parseExpected(18 /* OpenBraceToken */);
22797
21997
  const multiLine = scanner.hasPrecedingLineBreak();
22798
21998
  const properties = parseDelimitedList(
@@ -22864,7 +22064,7 @@ var Parser;
22864
22064
  function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
22865
22065
  const pos = getNodePos();
22866
22066
  const hasJSDoc = hasPrecedingJSDocComment();
22867
- const openBracePosition = scanner.getTokenPos();
22067
+ const openBracePosition = scanner.getTokenStart();
22868
22068
  const openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage);
22869
22069
  if (openBraceParsed || ignoreMissingOpenBrace) {
22870
22070
  const multiLine = scanner.hasPrecedingLineBreak();
@@ -22921,7 +22121,7 @@ var Parser;
22921
22121
  const pos = getNodePos();
22922
22122
  const hasJSDoc = hasPrecedingJSDocComment();
22923
22123
  parseExpected(99 /* IfKeyword */);
22924
- const openParenPosition = scanner.getTokenPos();
22124
+ const openParenPosition = scanner.getTokenStart();
22925
22125
  const openParenParsed = parseExpected(20 /* OpenParenToken */);
22926
22126
  const expression = allowInAnd(parseExpression);
22927
22127
  parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
@@ -22935,7 +22135,7 @@ var Parser;
22935
22135
  parseExpected(90 /* DoKeyword */);
22936
22136
  const statement = parseStatement();
22937
22137
  parseExpected(115 /* WhileKeyword */);
22938
- const openParenPosition = scanner.getTokenPos();
22138
+ const openParenPosition = scanner.getTokenStart();
22939
22139
  const openParenParsed = parseExpected(20 /* OpenParenToken */);
22940
22140
  const expression = allowInAnd(parseExpression);
22941
22141
  parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
@@ -22946,7 +22146,7 @@ var Parser;
22946
22146
  const pos = getNodePos();
22947
22147
  const hasJSDoc = hasPrecedingJSDocComment();
22948
22148
  parseExpected(115 /* WhileKeyword */);
22949
- const openParenPosition = scanner.getTokenPos();
22149
+ const openParenPosition = scanner.getTokenStart();
22950
22150
  const openParenParsed = parseExpected(20 /* OpenParenToken */);
22951
22151
  const expression = allowInAnd(parseExpression);
22952
22152
  parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
@@ -23013,7 +22213,7 @@ var Parser;
23013
22213
  const pos = getNodePos();
23014
22214
  const hasJSDoc = hasPrecedingJSDocComment();
23015
22215
  parseExpected(116 /* WithKeyword */);
23016
- const openParenPosition = scanner.getTokenPos();
22216
+ const openParenPosition = scanner.getTokenStart();
23017
22217
  const openParenParsed = parseExpected(20 /* OpenParenToken */);
23018
22218
  const expression = allowInAnd(parseExpression);
23019
22219
  parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
@@ -24109,7 +23309,7 @@ var Parser;
24109
23309
  }
24110
23310
  function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, modifiers) {
24111
23311
  parseExpected(100 /* ImportKeyword */);
24112
- const afterImportPos = scanner.getStartPos();
23312
+ const afterImportPos = scanner.getTokenFullStart();
24113
23313
  let identifier;
24114
23314
  if (isIdentifier2()) {
24115
23315
  identifier = parseIdentifier();
@@ -24153,7 +23353,7 @@ var Parser;
24153
23353
  if (!skipAssertKeyword) {
24154
23354
  parseExpected(130 /* AssertKeyword */);
24155
23355
  }
24156
- const openBracePosition = scanner.getTokenPos();
23356
+ const openBracePosition = scanner.getTokenStart();
24157
23357
  if (parseExpected(18 /* OpenBraceToken */)) {
24158
23358
  const multiLine = scanner.hasPrecedingLineBreak();
24159
23359
  const elements = parseDelimitedList(
@@ -24254,8 +23454,8 @@ var Parser;
24254
23454
  function parseImportOrExportSpecifier(kind) {
24255
23455
  const pos = getNodePos();
24256
23456
  let checkIdentifierIsKeyword = isKeyword(token()) && !isIdentifier2();
24257
- let checkIdentifierStart = scanner.getTokenPos();
24258
- let checkIdentifierEnd = scanner.getTextPos();
23457
+ let checkIdentifierStart = scanner.getTokenStart();
23458
+ let checkIdentifierEnd = scanner.getTokenEnd();
24259
23459
  let isTypeOnly = false;
24260
23460
  let propertyName;
24261
23461
  let canParseAsKeyword = true;
@@ -24300,8 +23500,8 @@ var Parser;
24300
23500
  return finishNode(node, pos);
24301
23501
  function parseNameWithKeywordCheck() {
24302
23502
  checkIdentifierIsKeyword = isKeyword(token()) && !isIdentifier2();
24303
- checkIdentifierStart = scanner.getTokenPos();
24304
- checkIdentifierEnd = scanner.getTextPos();
23503
+ checkIdentifierStart = scanner.getTokenStart();
23504
+ checkIdentifierEnd = scanner.getTokenEnd();
24305
23505
  return parseIdentifierName();
24306
23506
  }
24307
23507
  }
@@ -24587,8 +23787,8 @@ var Parser;
24587
23787
  break loop;
24588
23788
  case 18 /* OpenBraceToken */:
24589
23789
  state = 2 /* SavingComments */;
24590
- const commentEnd = scanner.getStartPos();
24591
- const linkStart = scanner.getTextPos() - 1;
23790
+ const commentEnd = scanner.getTokenFullStart();
23791
+ const linkStart = scanner.getTokenEnd() - 1;
24592
23792
  const link = parseJSDocLink(linkStart);
24593
23793
  if (link) {
24594
23794
  if (!linkEnd) {
@@ -24597,7 +23797,7 @@ var Parser;
24597
23797
  parts.push(finishNode(factory2.createJSDocText(comments.join("")), linkEnd != null ? linkEnd : start, commentEnd));
24598
23798
  parts.push(link);
24599
23799
  comments = [];
24600
- linkEnd = scanner.getTextPos();
23800
+ linkEnd = scanner.getTokenEnd();
24601
23801
  break;
24602
23802
  }
24603
23803
  default:
@@ -24671,7 +23871,7 @@ var Parser;
24671
23871
  }
24672
23872
  function parseTag(margin) {
24673
23873
  Debug.assert(token() === 59 /* AtToken */);
24674
- const start2 = scanner.getTokenPos();
23874
+ const start2 = scanner.getTokenStart();
24675
23875
  nextTokenJSDoc();
24676
23876
  const tagName = parseJSDocIdentifierName(
24677
23877
  /*message*/
@@ -24799,7 +23999,7 @@ var Parser;
24799
23999
  comments2.push(scanner.getTokenText());
24800
24000
  break;
24801
24001
  }
24802
- scanner.setTextPos(scanner.getTextPos() - 1);
24002
+ scanner.resetTokenState(scanner.getTokenEnd() - 1);
24803
24003
  case 1 /* EndOfFileToken */:
24804
24004
  break loop;
24805
24005
  case 5 /* WhitespaceTrivia */:
@@ -24815,14 +24015,14 @@ var Parser;
24815
24015
  break;
24816
24016
  case 18 /* OpenBraceToken */:
24817
24017
  state = 2 /* SavingComments */;
24818
- const commentEnd = scanner.getStartPos();
24819
- const linkStart = scanner.getTextPos() - 1;
24018
+ const commentEnd = scanner.getTokenFullStart();
24019
+ const linkStart = scanner.getTokenEnd() - 1;
24820
24020
  const link = parseJSDocLink(linkStart);
24821
24021
  if (link) {
24822
24022
  parts2.push(finishNode(factory2.createJSDocText(comments2.join("")), linkEnd2 != null ? linkEnd2 : commentsPos2, commentEnd));
24823
24023
  parts2.push(link);
24824
24024
  comments2 = [];
24825
- linkEnd2 = scanner.getTextPos();
24025
+ linkEnd2 = scanner.getTokenEnd();
24826
24026
  } else {
24827
24027
  pushComment(scanner.getTokenText());
24828
24028
  }
@@ -24857,7 +24057,7 @@ var Parser;
24857
24057
  if (comments2.length) {
24858
24058
  parts2.push(finishNode(factory2.createJSDocText(comments2.join("")), linkEnd2 != null ? linkEnd2 : commentsPos2));
24859
24059
  }
24860
- return createNodeArray(parts2, commentsPos2, scanner.getTextPos());
24060
+ return createNodeArray(parts2, commentsPos2, scanner.getTokenEnd());
24861
24061
  } else if (comments2.length) {
24862
24062
  return comments2.join("");
24863
24063
  }
@@ -24891,7 +24091,7 @@ var Parser;
24891
24091
  nextTokenJSDoc();
24892
24092
  }
24893
24093
  const create = linkType === "link" ? factory2.createJSDocLink : linkType === "linkcode" ? factory2.createJSDocLinkCode : factory2.createJSDocLinkPlain;
24894
- return finishNode(create(name, text.join("")), start2, scanner.getTextPos());
24094
+ return finishNode(create(name, text.join("")), start2, scanner.getTokenEnd());
24895
24095
  }
24896
24096
  function parseJSDocLinkPrefix() {
24897
24097
  skipWhitespaceOrAsterisk();
@@ -24988,14 +24188,14 @@ var Parser;
24988
24188
  }
24989
24189
  function parseReturnTag(start2, tagName, indent2, indentText) {
24990
24190
  if (some(tags, isJSDocReturnTag)) {
24991
- parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText);
24191
+ parseErrorAt(tagName.pos, scanner.getTokenStart(), Diagnostics._0_tag_already_specified, tagName.escapedText);
24992
24192
  }
24993
24193
  const typeExpression = tryParseTypeExpression();
24994
24194
  return finishNode(factory2.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start2, getNodePos(), indent2, indentText)), start2);
24995
24195
  }
24996
24196
  function parseTypeTag(start2, tagName, indent2, indentText) {
24997
24197
  if (some(tags, isJSDocTypeTag)) {
24998
- parseErrorAt(tagName.pos, scanner.getTokenPos(), Diagnostics._0_tag_already_specified, tagName.escapedText);
24198
+ parseErrorAt(tagName.pos, scanner.getTokenStart(), Diagnostics._0_tag_already_specified, tagName.escapedText);
24999
24199
  }
25000
24200
  const typeExpression = parseJSDocTypeExpression(
25001
24201
  /*mayOmitBraces*/
@@ -25018,10 +24218,10 @@ var Parser;
25018
24218
  function parseAuthorTag(start2, tagName, indent2, indentText) {
25019
24219
  const commentStart = getNodePos();
25020
24220
  const textOnly = parseAuthorNameAndEmail();
25021
- let commentEnd = scanner.getStartPos();
24221
+ let commentEnd = scanner.getTokenFullStart();
25022
24222
  const comments2 = parseTrailingTagComments(start2, commentEnd, indent2, indentText);
25023
24223
  if (!comments2) {
25024
- commentEnd = scanner.getStartPos();
24224
+ commentEnd = scanner.getTokenFullStart();
25025
24225
  }
25026
24226
  const allParts = typeof comments2 !== "string" ? createNodeArray(concatenate([finishNode(textOnly, commentStart, commentEnd)], comments2), commentStart) : textOnly.text + comments2;
25027
24227
  return finishNode(factory2.createJSDocAuthorTag(tagName, allParts), start2);
@@ -25037,7 +24237,7 @@ var Parser;
25037
24237
  break;
25038
24238
  } else if (token2 === 31 /* GreaterThanToken */ && inEmail) {
25039
24239
  comments2.push(scanner.getTokenText());
25040
- scanner.setTextPos(scanner.getTokenPos() + 1);
24240
+ scanner.resetTokenState(scanner.getTokenEnd());
25041
24241
  break;
25042
24242
  }
25043
24243
  comments2.push(scanner.getTokenText());
@@ -25145,7 +24345,7 @@ var Parser;
25145
24345
  return finishNode(typedefTag, start2, end2);
25146
24346
  }
25147
24347
  function parseJSDocTypeNameWithNamespace(nested) {
25148
- const pos = scanner.getTokenPos();
24348
+ const start2 = scanner.getTokenStart();
25149
24349
  if (!tokenIsIdentifierOrKeyword(token())) {
25150
24350
  return void 0;
25151
24351
  }
@@ -25162,7 +24362,7 @@ var Parser;
25162
24362
  body,
25163
24363
  nested ? 4 /* NestedNamespace */ : void 0
25164
24364
  );
25165
- return finishNode(jsDocNamespaceNode, pos);
24365
+ return finishNode(jsDocNamespaceNode, start2);
25166
24366
  }
25167
24367
  if (nested) {
25168
24368
  typeNameOrNamespaceName.flags |= 2048 /* IdentifierIsInJSDocNamespace */;
@@ -25265,7 +24465,7 @@ var Parser;
25265
24465
  }
25266
24466
  function tryParseChildTag(target, indent2) {
25267
24467
  Debug.assert(token() === 59 /* AtToken */);
25268
- const start2 = scanner.getStartPos();
24468
+ const start2 = scanner.getTokenFullStart();
25269
24469
  nextTokenJSDoc();
25270
24470
  const tagName = parseJSDocIdentifierName();
25271
24471
  skipWhitespace();
@@ -25365,11 +24565,11 @@ var Parser;
25365
24565
  );
25366
24566
  }
25367
24567
  identifierCount++;
25368
- const pos = scanner.getTokenPos();
25369
- const end2 = scanner.getTextPos();
24568
+ const start2 = scanner.getTokenStart();
24569
+ const end2 = scanner.getTokenEnd();
25370
24570
  const originalKeywordKind = token();
25371
24571
  const text = internIdentifier(scanner.getTokenValue());
25372
- const result = finishNode(factoryCreateIdentifier(text, originalKeywordKind), pos, end2);
24572
+ const result = finishNode(factoryCreateIdentifier(text, originalKeywordKind), start2, end2);
25373
24573
  nextTokenJSDoc();
25374
24574
  return result;
25375
24575
  }
@@ -29633,2870 +28833,7 @@ function traceIfEnabled(state, diagnostic, ...args) {
29633
28833
  }
29634
28834
  }
29635
28835
 
29636
- // src/compiler/binder.ts
29637
- function getModuleInstanceState(node, visited) {
29638
- if (node.body && !node.body.parent) {
29639
- setParent(node.body, node);
29640
- setParentRecursive(
29641
- node.body,
29642
- /*incremental*/
29643
- false
29644
- );
29645
- }
29646
- return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */;
29647
- }
29648
- function getModuleInstanceStateCached(node, visited = /* @__PURE__ */ new Map()) {
29649
- const nodeId = getNodeId(node);
29650
- if (visited.has(nodeId)) {
29651
- return visited.get(nodeId) || 0 /* NonInstantiated */;
29652
- }
29653
- visited.set(nodeId, void 0);
29654
- const result = getModuleInstanceStateWorker(node, visited);
29655
- visited.set(nodeId, result);
29656
- return result;
29657
- }
29658
- function getModuleInstanceStateWorker(node, visited) {
29659
- switch (node.kind) {
29660
- case 261 /* InterfaceDeclaration */:
29661
- case 262 /* TypeAliasDeclaration */:
29662
- return 0 /* NonInstantiated */;
29663
- case 263 /* EnumDeclaration */:
29664
- if (isEnumConst(node)) {
29665
- return 2 /* ConstEnumOnly */;
29666
- }
29667
- break;
29668
- case 269 /* ImportDeclaration */:
29669
- case 268 /* ImportEqualsDeclaration */:
29670
- if (!hasSyntacticModifier(node, 1 /* Export */)) {
29671
- return 0 /* NonInstantiated */;
29672
- }
29673
- break;
29674
- case 275 /* ExportDeclaration */:
29675
- const exportDeclaration = node;
29676
- if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 276 /* NamedExports */) {
29677
- let state = 0 /* NonInstantiated */;
29678
- for (const specifier of exportDeclaration.exportClause.elements) {
29679
- const specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
29680
- if (specifierState > state) {
29681
- state = specifierState;
29682
- }
29683
- if (state === 1 /* Instantiated */) {
29684
- return state;
29685
- }
29686
- }
29687
- return state;
29688
- }
29689
- break;
29690
- case 265 /* ModuleBlock */: {
29691
- let state = 0 /* NonInstantiated */;
29692
- forEachChild(node, (n) => {
29693
- const childState = getModuleInstanceStateCached(n, visited);
29694
- switch (childState) {
29695
- case 0 /* NonInstantiated */:
29696
- return;
29697
- case 2 /* ConstEnumOnly */:
29698
- state = 2 /* ConstEnumOnly */;
29699
- return;
29700
- case 1 /* Instantiated */:
29701
- state = 1 /* Instantiated */;
29702
- return true;
29703
- default:
29704
- Debug.assertNever(childState);
29705
- }
29706
- });
29707
- return state;
29708
- }
29709
- case 264 /* ModuleDeclaration */:
29710
- return getModuleInstanceState(node, visited);
29711
- case 79 /* Identifier */:
29712
- if (node.flags & 2048 /* IdentifierIsInJSDocNamespace */) {
29713
- return 0 /* NonInstantiated */;
29714
- }
29715
- }
29716
- return 1 /* Instantiated */;
29717
- }
29718
- function getModuleInstanceStateForAliasTarget(specifier, visited) {
29719
- const name = specifier.propertyName || specifier.name;
29720
- let p = specifier.parent;
29721
- while (p) {
29722
- if (isBlock(p) || isModuleBlock(p) || isSourceFile(p)) {
29723
- const statements = p.statements;
29724
- let found;
29725
- for (const statement of statements) {
29726
- if (nodeHasName(statement, name)) {
29727
- if (!statement.parent) {
29728
- setParent(statement, p);
29729
- setParentRecursive(
29730
- statement,
29731
- /*incremental*/
29732
- false
29733
- );
29734
- }
29735
- const state = getModuleInstanceStateCached(statement, visited);
29736
- if (found === void 0 || state > found) {
29737
- found = state;
29738
- }
29739
- if (found === 1 /* Instantiated */) {
29740
- return found;
29741
- }
29742
- }
29743
- }
29744
- if (found !== void 0) {
29745
- return found;
29746
- }
29747
- }
29748
- p = p.parent;
29749
- }
29750
- return 1 /* Instantiated */;
29751
- }
29752
- function initFlowNode(node) {
29753
- Debug.attachFlowNodeDebugInfo(node);
29754
- return node;
29755
- }
29756
- var binder = createBinder();
29757
- function createBinder() {
29758
- var file;
29759
- var options;
29760
- var languageVersion;
29761
- var parent;
29762
- var container;
29763
- var thisParentContainer;
29764
- var blockScopeContainer;
29765
- var lastContainer;
29766
- var delayedTypeAliases;
29767
- var seenThisKeyword;
29768
- var currentFlow;
29769
- var currentBreakTarget;
29770
- var currentContinueTarget;
29771
- var currentReturnTarget;
29772
- var currentTrueTarget;
29773
- var currentFalseTarget;
29774
- var currentExceptionTarget;
29775
- var preSwitchCaseFlow;
29776
- var activeLabelList;
29777
- var hasExplicitReturn;
29778
- var emitFlags;
29779
- var inStrictMode;
29780
- var inAssignmentPattern = false;
29781
- var symbolCount = 0;
29782
- var Symbol12;
29783
- var classifiableNames;
29784
- var unreachableFlow = { flags: 1 /* Unreachable */ };
29785
- var reportedUnreachableFlow = { flags: 1 /* Unreachable */ };
29786
- var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
29787
- return bindSourceFile2;
29788
- function createDiagnosticForNode2(node, message, arg0, arg1, arg2) {
29789
- return createDiagnosticForNodeInSourceFile(getSourceFileOfNode(node) || file, node, message, arg0, arg1, arg2);
29790
- }
29791
- function bindSourceFile2(f, opts) {
29792
- var _a2, _b;
29793
- file = f;
29794
- options = opts;
29795
- languageVersion = getEmitScriptTarget(options);
29796
- inStrictMode = bindInStrictMode(file, opts);
29797
- classifiableNames = /* @__PURE__ */ new Set();
29798
- symbolCount = 0;
29799
- Symbol12 = objectAllocator.getSymbolConstructor();
29800
- Debug.attachFlowNodeDebugInfo(unreachableFlow);
29801
- Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
29802
- if (!file.locals) {
29803
- (_a2 = tracing) == null ? void 0 : _a2.push(
29804
- tracing.Phase.Bind,
29805
- "bindSourceFile",
29806
- { path: file.path },
29807
- /*separateBeginAndEnd*/
29808
- true
29809
- );
29810
- bind(file);
29811
- (_b = tracing) == null ? void 0 : _b.pop();
29812
- file.symbolCount = symbolCount;
29813
- file.classifiableNames = classifiableNames;
29814
- delayedBindJSDocTypedefTag();
29815
- }
29816
- file = void 0;
29817
- options = void 0;
29818
- languageVersion = void 0;
29819
- parent = void 0;
29820
- container = void 0;
29821
- thisParentContainer = void 0;
29822
- blockScopeContainer = void 0;
29823
- lastContainer = void 0;
29824
- delayedTypeAliases = void 0;
29825
- seenThisKeyword = false;
29826
- currentFlow = void 0;
29827
- currentBreakTarget = void 0;
29828
- currentContinueTarget = void 0;
29829
- currentReturnTarget = void 0;
29830
- currentTrueTarget = void 0;
29831
- currentFalseTarget = void 0;
29832
- currentExceptionTarget = void 0;
29833
- activeLabelList = void 0;
29834
- hasExplicitReturn = false;
29835
- inAssignmentPattern = false;
29836
- emitFlags = 0 /* None */;
29837
- }
29838
- function bindInStrictMode(file2, opts) {
29839
- if (getStrictOptionValue(opts, "alwaysStrict") && !file2.isDeclarationFile) {
29840
- return true;
29841
- } else {
29842
- return !!file2.externalModuleIndicator;
29843
- }
29844
- }
29845
- function createSymbol(flags, name) {
29846
- symbolCount++;
29847
- return new Symbol12(flags, name);
29848
- }
29849
- function addDeclarationToSymbol(symbol, node, symbolFlags) {
29850
- symbol.flags |= symbolFlags;
29851
- node.symbol = symbol;
29852
- symbol.declarations = appendIfUnique(symbol.declarations, node);
29853
- if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) {
29854
- symbol.exports = createSymbolTable();
29855
- }
29856
- if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) {
29857
- symbol.members = createSymbolTable();
29858
- }
29859
- if (symbol.constEnumOnlyModule && symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) {
29860
- symbol.constEnumOnlyModule = false;
29861
- }
29862
- if (symbolFlags & 111551 /* Value */) {
29863
- setValueDeclaration(symbol, node);
29864
- }
29865
- }
29866
- function getDeclarationName(node) {
29867
- if (node.kind === 274 /* ExportAssignment */) {
29868
- return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */;
29869
- }
29870
- const name = getNameOfDeclaration(node);
29871
- if (name) {
29872
- if (isAmbientModule(node)) {
29873
- const moduleName = getTextOfIdentifierOrLiteral(name);
29874
- return isGlobalScopeAugmentation(node) ? "__global" : `"${moduleName}"`;
29875
- }
29876
- if (name.kind === 164 /* ComputedPropertyName */) {
29877
- const nameExpression = name.expression;
29878
- if (isStringOrNumericLiteralLike(nameExpression)) {
29879
- return escapeLeadingUnderscores(nameExpression.text);
29880
- }
29881
- if (isSignedNumericLiteral(nameExpression)) {
29882
- return tokenToString(nameExpression.operator) + nameExpression.operand.text;
29883
- } else {
29884
- Debug.fail("Only computed properties with literal names have declaration names");
29885
- }
29886
- }
29887
- if (isPrivateIdentifier(name)) {
29888
- const containingClass = getContainingClass(node);
29889
- if (!containingClass) {
29890
- return void 0;
29891
- }
29892
- const containingClassSymbol = containingClass.symbol;
29893
- return getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
29894
- }
29895
- return isPropertyNameLiteral(name) ? getEscapedTextOfIdentifierOrLiteral(name) : void 0;
29896
- }
29897
- switch (node.kind) {
29898
- case 173 /* Constructor */:
29899
- return "__constructor" /* Constructor */;
29900
- case 181 /* FunctionType */:
29901
- case 176 /* CallSignature */:
29902
- case 326 /* JSDocSignature */:
29903
- return "__call" /* Call */;
29904
- case 182 /* ConstructorType */:
29905
- case 177 /* ConstructSignature */:
29906
- return "__new" /* New */;
29907
- case 178 /* IndexSignature */:
29908
- return "__index" /* Index */;
29909
- case 275 /* ExportDeclaration */:
29910
- return "__export" /* ExportStar */;
29911
- case 308 /* SourceFile */:
29912
- return "export=" /* ExportEquals */;
29913
- case 223 /* BinaryExpression */:
29914
- if (getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) {
29915
- return "export=" /* ExportEquals */;
29916
- }
29917
- Debug.fail("Unknown binary declaration kind");
29918
- break;
29919
- case 320 /* JSDocFunctionType */:
29920
- return isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */;
29921
- case 166 /* Parameter */:
29922
- Debug.assert(node.parent.kind === 320 /* JSDocFunctionType */, "Impossible parameter parent kind", () => `parent is: ${Debug.formatSyntaxKind(node.parent.kind)}, expected JSDocFunctionType`);
29923
- const functionType = node.parent;
29924
- const index = functionType.parameters.indexOf(node);
29925
- return "arg" + index;
29926
- }
29927
- }
29928
- function getDisplayName(node) {
29929
- return isNamedDeclaration(node) ? declarationNameToString(node.name) : unescapeLeadingUnderscores(Debug.checkDefined(getDeclarationName(node)));
29930
- }
29931
- function declareSymbol(symbolTable, parent2, node, includes, excludes, isReplaceableByMethod, isComputedName) {
29932
- Debug.assert(isComputedName || !hasDynamicName(node));
29933
- const isDefaultExport = hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node) && node.name.escapedText === "default";
29934
- const name = isComputedName ? "__computed" /* Computed */ : isDefaultExport && parent2 ? "default" /* Default */ : getDeclarationName(node);
29935
- let symbol;
29936
- if (name === void 0) {
29937
- symbol = createSymbol(0 /* None */, "__missing" /* Missing */);
29938
- } else {
29939
- symbol = symbolTable.get(name);
29940
- if (includes & 2885600 /* Classifiable */) {
29941
- classifiableNames.add(name);
29942
- }
29943
- if (!symbol) {
29944
- symbolTable.set(name, symbol = createSymbol(0 /* None */, name));
29945
- if (isReplaceableByMethod)
29946
- symbol.isReplaceableByMethod = true;
29947
- } else if (isReplaceableByMethod && !symbol.isReplaceableByMethod) {
29948
- return symbol;
29949
- } else if (symbol.flags & excludes) {
29950
- if (symbol.isReplaceableByMethod) {
29951
- symbolTable.set(name, symbol = createSymbol(0 /* None */, name));
29952
- } else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) {
29953
- if (isNamedDeclaration(node)) {
29954
- setParent(node.name, node);
29955
- }
29956
- let message = symbol.flags & 2 /* BlockScopedVariable */ ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;
29957
- let messageNeedsName = true;
29958
- if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) {
29959
- message = Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
29960
- messageNeedsName = false;
29961
- }
29962
- let multipleDefaultExports = false;
29963
- if (length(symbol.declarations)) {
29964
- if (isDefaultExport) {
29965
- message = Diagnostics.A_module_cannot_have_multiple_default_exports;
29966
- messageNeedsName = false;
29967
- multipleDefaultExports = true;
29968
- } else {
29969
- if (symbol.declarations && symbol.declarations.length && (node.kind === 274 /* ExportAssignment */ && !node.isExportEquals)) {
29970
- message = Diagnostics.A_module_cannot_have_multiple_default_exports;
29971
- messageNeedsName = false;
29972
- multipleDefaultExports = true;
29973
- }
29974
- }
29975
- }
29976
- const relatedInformation = [];
29977
- if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) {
29978
- relatedInformation.push(createDiagnosticForNode2(node, Diagnostics.Did_you_mean_0, `export type { ${unescapeLeadingUnderscores(node.name.escapedText)} }`));
29979
- }
29980
- const declarationName = getNameOfDeclaration(node) || node;
29981
- forEach(symbol.declarations, (declaration, index) => {
29982
- const decl = getNameOfDeclaration(declaration) || declaration;
29983
- const diag3 = createDiagnosticForNode2(decl, message, messageNeedsName ? getDisplayName(declaration) : void 0);
29984
- file.bindDiagnostics.push(
29985
- multipleDefaultExports ? addRelatedInfo(diag3, createDiagnosticForNode2(declarationName, index === 0 ? Diagnostics.Another_export_default_is_here : Diagnostics.and_here)) : diag3
29986
- );
29987
- if (multipleDefaultExports) {
29988
- relatedInformation.push(createDiagnosticForNode2(decl, Diagnostics.The_first_export_default_is_here));
29989
- }
29990
- });
29991
- const diag2 = createDiagnosticForNode2(declarationName, message, messageNeedsName ? getDisplayName(node) : void 0);
29992
- file.bindDiagnostics.push(addRelatedInfo(diag2, ...relatedInformation));
29993
- symbol = createSymbol(0 /* None */, name);
29994
- }
29995
- }
29996
- }
29997
- addDeclarationToSymbol(symbol, node, includes);
29998
- if (symbol.parent) {
29999
- Debug.assert(symbol.parent === parent2, "Existing symbol parent should match new one");
30000
- } else {
30001
- symbol.parent = parent2;
30002
- }
30003
- return symbol;
30004
- }
30005
- function declareModuleMember(node, symbolFlags, symbolExcludes) {
30006
- const hasExportModifier = !!(getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node);
30007
- if (symbolFlags & 2097152 /* Alias */) {
30008
- if (node.kind === 278 /* ExportSpecifier */ || node.kind === 268 /* ImportEqualsDeclaration */ && hasExportModifier) {
30009
- return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
30010
- } else {
30011
- Debug.assertNode(container, canHaveLocals);
30012
- return declareSymbol(
30013
- container.locals,
30014
- /*parent*/
30015
- void 0,
30016
- node,
30017
- symbolFlags,
30018
- symbolExcludes
30019
- );
30020
- }
30021
- } else {
30022
- if (isJSDocTypeAlias(node))
30023
- Debug.assert(isInJSFile(node));
30024
- if (!isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) {
30025
- if (!canHaveLocals(container) || !container.locals || hasSyntacticModifier(node, 1024 /* Default */) && !getDeclarationName(node)) {
30026
- return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
30027
- }
30028
- const exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0;
30029
- const local = declareSymbol(
30030
- container.locals,
30031
- /*parent*/
30032
- void 0,
30033
- node,
30034
- exportKind,
30035
- symbolExcludes
30036
- );
30037
- local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
30038
- node.localSymbol = local;
30039
- return local;
30040
- } else {
30041
- Debug.assertNode(container, canHaveLocals);
30042
- return declareSymbol(
30043
- container.locals,
30044
- /*parent*/
30045
- void 0,
30046
- node,
30047
- symbolFlags,
30048
- symbolExcludes
30049
- );
30050
- }
30051
- }
30052
- }
30053
- function jsdocTreatAsExported(node) {
30054
- if (node.parent && isModuleDeclaration(node)) {
30055
- node = node.parent;
30056
- }
30057
- if (!isJSDocTypeAlias(node))
30058
- return false;
30059
- if (!isJSDocEnumTag(node) && !!node.fullName)
30060
- return true;
30061
- const declName = getNameOfDeclaration(node);
30062
- if (!declName)
30063
- return false;
30064
- if (isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent))
30065
- return true;
30066
- if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & 1 /* Export */)
30067
- return true;
30068
- return false;
30069
- }
30070
- function bindContainer(node, containerFlags) {
30071
- const saveContainer = container;
30072
- const saveThisParentContainer = thisParentContainer;
30073
- const savedBlockScopeContainer = blockScopeContainer;
30074
- if (containerFlags & 1 /* IsContainer */) {
30075
- if (node.kind !== 216 /* ArrowFunction */) {
30076
- thisParentContainer = container;
30077
- }
30078
- container = blockScopeContainer = node;
30079
- if (containerFlags & 32 /* HasLocals */) {
30080
- container.locals = createSymbolTable();
30081
- addToContainerChain(container);
30082
- }
30083
- } else if (containerFlags & 2 /* IsBlockScopedContainer */) {
30084
- blockScopeContainer = node;
30085
- if (containerFlags & 32 /* HasLocals */) {
30086
- blockScopeContainer.locals = void 0;
30087
- }
30088
- }
30089
- if (containerFlags & 4 /* IsControlFlowContainer */) {
30090
- const saveCurrentFlow = currentFlow;
30091
- const saveBreakTarget = currentBreakTarget;
30092
- const saveContinueTarget = currentContinueTarget;
30093
- const saveReturnTarget = currentReturnTarget;
30094
- const saveExceptionTarget = currentExceptionTarget;
30095
- const saveActiveLabelList = activeLabelList;
30096
- const saveHasExplicitReturn = hasExplicitReturn;
30097
- const isImmediatelyInvoked = containerFlags & 16 /* IsFunctionExpression */ && !hasSyntacticModifier(node, 512 /* Async */) && !node.asteriskToken && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === 172 /* ClassStaticBlockDeclaration */;
30098
- if (!isImmediatelyInvoked) {
30099
- currentFlow = initFlowNode({ flags: 2 /* Start */ });
30100
- if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) {
30101
- currentFlow.node = node;
30102
- }
30103
- }
30104
- currentReturnTarget = isImmediatelyInvoked || node.kind === 173 /* Constructor */ || isInJSFile(node) && (node.kind === 259 /* FunctionDeclaration */ || node.kind === 215 /* FunctionExpression */) ? createBranchLabel() : void 0;
30105
- currentExceptionTarget = void 0;
30106
- currentBreakTarget = void 0;
30107
- currentContinueTarget = void 0;
30108
- activeLabelList = void 0;
30109
- hasExplicitReturn = false;
30110
- bindChildren(node);
30111
- node.flags &= ~2816 /* ReachabilityAndEmitFlags */;
30112
- if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && nodeIsPresent(node.body)) {
30113
- node.flags |= 256 /* HasImplicitReturn */;
30114
- if (hasExplicitReturn)
30115
- node.flags |= 512 /* HasExplicitReturn */;
30116
- node.endFlowNode = currentFlow;
30117
- }
30118
- if (node.kind === 308 /* SourceFile */) {
30119
- node.flags |= emitFlags;
30120
- node.endFlowNode = currentFlow;
30121
- }
30122
- if (currentReturnTarget) {
30123
- addAntecedent(currentReturnTarget, currentFlow);
30124
- currentFlow = finishFlowLabel(currentReturnTarget);
30125
- if (node.kind === 173 /* Constructor */ || node.kind === 172 /* ClassStaticBlockDeclaration */ || isInJSFile(node) && (node.kind === 259 /* FunctionDeclaration */ || node.kind === 215 /* FunctionExpression */)) {
30126
- node.returnFlowNode = currentFlow;
30127
- }
30128
- }
30129
- if (!isImmediatelyInvoked) {
30130
- currentFlow = saveCurrentFlow;
30131
- }
30132
- currentBreakTarget = saveBreakTarget;
30133
- currentContinueTarget = saveContinueTarget;
30134
- currentReturnTarget = saveReturnTarget;
30135
- currentExceptionTarget = saveExceptionTarget;
30136
- activeLabelList = saveActiveLabelList;
30137
- hasExplicitReturn = saveHasExplicitReturn;
30138
- } else if (containerFlags & 64 /* IsInterface */) {
30139
- seenThisKeyword = false;
30140
- bindChildren(node);
30141
- Debug.assertNotNode(node, isIdentifier);
30142
- node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */;
30143
- } else {
30144
- bindChildren(node);
30145
- }
30146
- container = saveContainer;
30147
- thisParentContainer = saveThisParentContainer;
30148
- blockScopeContainer = savedBlockScopeContainer;
30149
- }
30150
- function bindEachFunctionsFirst(nodes) {
30151
- bindEach(nodes, (n) => n.kind === 259 /* FunctionDeclaration */ ? bind(n) : void 0);
30152
- bindEach(nodes, (n) => n.kind !== 259 /* FunctionDeclaration */ ? bind(n) : void 0);
30153
- }
30154
- function bindEach(nodes, bindFunction = bind) {
30155
- if (nodes === void 0) {
30156
- return;
30157
- }
30158
- forEach(nodes, bindFunction);
30159
- }
30160
- function bindEachChild(node) {
30161
- forEachChild(node, bind, bindEach);
30162
- }
30163
- function bindChildren(node) {
30164
- const saveInAssignmentPattern = inAssignmentPattern;
30165
- inAssignmentPattern = false;
30166
- if (checkUnreachable(node)) {
30167
- bindEachChild(node);
30168
- bindJSDoc(node);
30169
- inAssignmentPattern = saveInAssignmentPattern;
30170
- return;
30171
- }
30172
- if (node.kind >= 240 /* FirstStatement */ && node.kind <= 256 /* LastStatement */ && !options.allowUnreachableCode) {
30173
- node.flowNode = currentFlow;
30174
- }
30175
- switch (node.kind) {
30176
- case 244 /* WhileStatement */:
30177
- bindWhileStatement(node);
30178
- break;
30179
- case 243 /* DoStatement */:
30180
- bindDoStatement(node);
30181
- break;
30182
- case 245 /* ForStatement */:
30183
- bindForStatement(node);
30184
- break;
30185
- case 246 /* ForInStatement */:
30186
- case 247 /* ForOfStatement */:
30187
- bindForInOrForOfStatement(node);
30188
- break;
30189
- case 242 /* IfStatement */:
30190
- bindIfStatement(node);
30191
- break;
30192
- case 250 /* ReturnStatement */:
30193
- case 254 /* ThrowStatement */:
30194
- bindReturnOrThrow(node);
30195
- break;
30196
- case 249 /* BreakStatement */:
30197
- case 248 /* ContinueStatement */:
30198
- bindBreakOrContinueStatement(node);
30199
- break;
30200
- case 255 /* TryStatement */:
30201
- bindTryStatement(node);
30202
- break;
30203
- case 252 /* SwitchStatement */:
30204
- bindSwitchStatement(node);
30205
- break;
30206
- case 266 /* CaseBlock */:
30207
- bindCaseBlock(node);
30208
- break;
30209
- case 292 /* CaseClause */:
30210
- bindCaseClause(node);
30211
- break;
30212
- case 241 /* ExpressionStatement */:
30213
- bindExpressionStatement(node);
30214
- break;
30215
- case 253 /* LabeledStatement */:
30216
- bindLabeledStatement(node);
30217
- break;
30218
- case 221 /* PrefixUnaryExpression */:
30219
- bindPrefixUnaryExpressionFlow(node);
30220
- break;
30221
- case 222 /* PostfixUnaryExpression */:
30222
- bindPostfixUnaryExpressionFlow(node);
30223
- break;
30224
- case 223 /* BinaryExpression */:
30225
- if (isDestructuringAssignment(node)) {
30226
- inAssignmentPattern = saveInAssignmentPattern;
30227
- bindDestructuringAssignmentFlow(node);
30228
- return;
30229
- }
30230
- bindBinaryExpressionFlow(node);
30231
- break;
30232
- case 217 /* DeleteExpression */:
30233
- bindDeleteExpressionFlow(node);
30234
- break;
30235
- case 224 /* ConditionalExpression */:
30236
- bindConditionalExpressionFlow(node);
30237
- break;
30238
- case 257 /* VariableDeclaration */:
30239
- bindVariableDeclarationFlow(node);
30240
- break;
30241
- case 208 /* PropertyAccessExpression */:
30242
- case 209 /* ElementAccessExpression */:
30243
- bindAccessExpressionFlow(node);
30244
- break;
30245
- case 210 /* CallExpression */:
30246
- bindCallExpressionFlow(node);
30247
- break;
30248
- case 232 /* NonNullExpression */:
30249
- bindNonNullExpressionFlow(node);
30250
- break;
30251
- case 349 /* JSDocTypedefTag */:
30252
- case 341 /* JSDocCallbackTag */:
30253
- case 343 /* JSDocEnumTag */:
30254
- bindJSDocTypeAlias(node);
30255
- break;
30256
- case 308 /* SourceFile */: {
30257
- bindEachFunctionsFirst(node.statements);
30258
- bind(node.endOfFileToken);
30259
- break;
30260
- }
30261
- case 238 /* Block */:
30262
- case 265 /* ModuleBlock */:
30263
- bindEachFunctionsFirst(node.statements);
30264
- break;
30265
- case 205 /* BindingElement */:
30266
- bindBindingElementFlow(node);
30267
- break;
30268
- case 166 /* Parameter */:
30269
- bindParameterFlow(node);
30270
- break;
30271
- case 207 /* ObjectLiteralExpression */:
30272
- case 206 /* ArrayLiteralExpression */:
30273
- case 299 /* PropertyAssignment */:
30274
- case 227 /* SpreadElement */:
30275
- inAssignmentPattern = saveInAssignmentPattern;
30276
- default:
30277
- bindEachChild(node);
30278
- break;
30279
- }
30280
- bindJSDoc(node);
30281
- inAssignmentPattern = saveInAssignmentPattern;
30282
- }
30283
- function isNarrowingExpression(expr) {
30284
- switch (expr.kind) {
30285
- case 79 /* Identifier */:
30286
- case 80 /* PrivateIdentifier */:
30287
- case 108 /* ThisKeyword */:
30288
- case 208 /* PropertyAccessExpression */:
30289
- case 209 /* ElementAccessExpression */:
30290
- return containsNarrowableReference(expr);
30291
- case 210 /* CallExpression */:
30292
- return hasNarrowableArgument(expr);
30293
- case 214 /* ParenthesizedExpression */:
30294
- case 232 /* NonNullExpression */:
30295
- return isNarrowingExpression(expr.expression);
30296
- case 223 /* BinaryExpression */:
30297
- return isNarrowingBinaryExpression(expr);
30298
- case 221 /* PrefixUnaryExpression */:
30299
- return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand);
30300
- case 218 /* TypeOfExpression */:
30301
- return isNarrowingExpression(expr.expression);
30302
- }
30303
- return false;
30304
- }
30305
- function isNarrowableReference(expr) {
30306
- return isDottedName(expr) || (isPropertyAccessExpression(expr) || isNonNullExpression(expr) || isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) || isElementAccessExpression(expr) && (isStringOrNumericLiteralLike(expr.argumentExpression) || isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || isAssignmentExpression(expr) && isNarrowableReference(expr.left);
30307
- }
30308
- function containsNarrowableReference(expr) {
30309
- return isNarrowableReference(expr) || isOptionalChain(expr) && containsNarrowableReference(expr.expression);
30310
- }
30311
- function hasNarrowableArgument(expr) {
30312
- if (expr.arguments) {
30313
- for (const argument of expr.arguments) {
30314
- if (containsNarrowableReference(argument)) {
30315
- return true;
30316
- }
30317
- }
30318
- }
30319
- if (expr.expression.kind === 208 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) {
30320
- return true;
30321
- }
30322
- return false;
30323
- }
30324
- function isNarrowingTypeofOperands(expr1, expr2) {
30325
- return isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && isStringLiteralLike(expr2);
30326
- }
30327
- function isNarrowingBinaryExpression(expr) {
30328
- switch (expr.operatorToken.kind) {
30329
- case 63 /* EqualsToken */:
30330
- case 75 /* BarBarEqualsToken */:
30331
- case 76 /* AmpersandAmpersandEqualsToken */:
30332
- case 77 /* QuestionQuestionEqualsToken */:
30333
- return containsNarrowableReference(expr.left);
30334
- case 34 /* EqualsEqualsToken */:
30335
- case 35 /* ExclamationEqualsToken */:
30336
- case 36 /* EqualsEqualsEqualsToken */:
30337
- case 37 /* ExclamationEqualsEqualsToken */:
30338
- return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
30339
- case 102 /* InstanceOfKeyword */:
30340
- return isNarrowableOperand(expr.left);
30341
- case 101 /* InKeyword */:
30342
- return isNarrowingExpression(expr.right);
30343
- case 27 /* CommaToken */:
30344
- return isNarrowingExpression(expr.right);
30345
- }
30346
- return false;
30347
- }
30348
- function isNarrowableOperand(expr) {
30349
- switch (expr.kind) {
30350
- case 214 /* ParenthesizedExpression */:
30351
- return isNarrowableOperand(expr.expression);
30352
- case 223 /* BinaryExpression */:
30353
- switch (expr.operatorToken.kind) {
30354
- case 63 /* EqualsToken */:
30355
- return isNarrowableOperand(expr.left);
30356
- case 27 /* CommaToken */:
30357
- return isNarrowableOperand(expr.right);
30358
- }
30359
- }
30360
- return containsNarrowableReference(expr);
30361
- }
30362
- function createBranchLabel() {
30363
- return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: void 0 });
30364
- }
30365
- function createLoopLabel() {
30366
- return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: void 0 });
30367
- }
30368
- function createReduceLabel(target, antecedents, antecedent) {
30369
- return initFlowNode({ flags: 1024 /* ReduceLabel */, target, antecedents, antecedent });
30370
- }
30371
- function setFlowNodeReferenced(flow) {
30372
- flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */;
30373
- }
30374
- function addAntecedent(label, antecedent) {
30375
- if (!(antecedent.flags & 1 /* Unreachable */) && !contains(label.antecedents, antecedent)) {
30376
- (label.antecedents || (label.antecedents = [])).push(antecedent);
30377
- setFlowNodeReferenced(antecedent);
30378
- }
30379
- }
30380
- function createFlowCondition(flags, antecedent, expression) {
30381
- if (antecedent.flags & 1 /* Unreachable */) {
30382
- return antecedent;
30383
- }
30384
- if (!expression) {
30385
- return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow;
30386
- }
30387
- if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && !isExpressionOfOptionalChainRoot(expression) && !isNullishCoalesce(expression.parent)) {
30388
- return unreachableFlow;
30389
- }
30390
- if (!isNarrowingExpression(expression)) {
30391
- return antecedent;
30392
- }
30393
- setFlowNodeReferenced(antecedent);
30394
- return initFlowNode({ flags, antecedent, node: expression });
30395
- }
30396
- function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
30397
- setFlowNodeReferenced(antecedent);
30398
- return initFlowNode({ flags: 128 /* SwitchClause */, antecedent, switchStatement, clauseStart, clauseEnd });
30399
- }
30400
- function createFlowMutation(flags, antecedent, node) {
30401
- setFlowNodeReferenced(antecedent);
30402
- const result = initFlowNode({ flags, antecedent, node });
30403
- if (currentExceptionTarget) {
30404
- addAntecedent(currentExceptionTarget, result);
30405
- }
30406
- return result;
30407
- }
30408
- function createFlowCall(antecedent, node) {
30409
- setFlowNodeReferenced(antecedent);
30410
- return initFlowNode({ flags: 512 /* Call */, antecedent, node });
30411
- }
30412
- function finishFlowLabel(flow) {
30413
- const antecedents = flow.antecedents;
30414
- if (!antecedents) {
30415
- return unreachableFlow;
30416
- }
30417
- if (antecedents.length === 1) {
30418
- return antecedents[0];
30419
- }
30420
- return flow;
30421
- }
30422
- function isStatementCondition(node) {
30423
- const parent2 = node.parent;
30424
- switch (parent2.kind) {
30425
- case 242 /* IfStatement */:
30426
- case 244 /* WhileStatement */:
30427
- case 243 /* DoStatement */:
30428
- return parent2.expression === node;
30429
- case 245 /* ForStatement */:
30430
- case 224 /* ConditionalExpression */:
30431
- return parent2.condition === node;
30432
- }
30433
- return false;
30434
- }
30435
- function isLogicalExpression(node) {
30436
- while (true) {
30437
- if (node.kind === 214 /* ParenthesizedExpression */) {
30438
- node = node.expression;
30439
- } else if (node.kind === 221 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) {
30440
- node = node.operand;
30441
- } else {
30442
- return isLogicalOrCoalescingBinaryExpression(node);
30443
- }
30444
- }
30445
- }
30446
- function isLogicalAssignmentExpression(node) {
30447
- return isLogicalOrCoalescingAssignmentExpression(skipParentheses(node));
30448
- }
30449
- function isTopLevelLogicalExpression(node) {
30450
- while (isParenthesizedExpression(node.parent) || isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) {
30451
- node = node.parent;
30452
- }
30453
- return !isStatementCondition(node) && !isLogicalExpression(node.parent) && !(isOptionalChain(node.parent) && node.parent.expression === node);
30454
- }
30455
- function doWithConditionalBranches(action, value, trueTarget, falseTarget) {
30456
- const savedTrueTarget = currentTrueTarget;
30457
- const savedFalseTarget = currentFalseTarget;
30458
- currentTrueTarget = trueTarget;
30459
- currentFalseTarget = falseTarget;
30460
- action(value);
30461
- currentTrueTarget = savedTrueTarget;
30462
- currentFalseTarget = savedFalseTarget;
30463
- }
30464
- function bindCondition(node, trueTarget, falseTarget) {
30465
- doWithConditionalBranches(bind, node, trueTarget, falseTarget);
30466
- if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(isOptionalChain(node) && isOutermostOptionalChain(node))) {
30467
- addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
30468
- addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
30469
- }
30470
- }
30471
- function bindIterativeStatement(node, breakTarget, continueTarget) {
30472
- const saveBreakTarget = currentBreakTarget;
30473
- const saveContinueTarget = currentContinueTarget;
30474
- currentBreakTarget = breakTarget;
30475
- currentContinueTarget = continueTarget;
30476
- bind(node);
30477
- currentBreakTarget = saveBreakTarget;
30478
- currentContinueTarget = saveContinueTarget;
30479
- }
30480
- function setContinueTarget(node, target) {
30481
- let label = activeLabelList;
30482
- while (label && node.parent.kind === 253 /* LabeledStatement */) {
30483
- label.continueTarget = target;
30484
- label = label.next;
30485
- node = node.parent;
30486
- }
30487
- return target;
30488
- }
30489
- function bindWhileStatement(node) {
30490
- const preWhileLabel = setContinueTarget(node, createLoopLabel());
30491
- const preBodyLabel = createBranchLabel();
30492
- const postWhileLabel = createBranchLabel();
30493
- addAntecedent(preWhileLabel, currentFlow);
30494
- currentFlow = preWhileLabel;
30495
- bindCondition(node.expression, preBodyLabel, postWhileLabel);
30496
- currentFlow = finishFlowLabel(preBodyLabel);
30497
- bindIterativeStatement(node.statement, postWhileLabel, preWhileLabel);
30498
- addAntecedent(preWhileLabel, currentFlow);
30499
- currentFlow = finishFlowLabel(postWhileLabel);
30500
- }
30501
- function bindDoStatement(node) {
30502
- const preDoLabel = createLoopLabel();
30503
- const preConditionLabel = setContinueTarget(node, createBranchLabel());
30504
- const postDoLabel = createBranchLabel();
30505
- addAntecedent(preDoLabel, currentFlow);
30506
- currentFlow = preDoLabel;
30507
- bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
30508
- addAntecedent(preConditionLabel, currentFlow);
30509
- currentFlow = finishFlowLabel(preConditionLabel);
30510
- bindCondition(node.expression, preDoLabel, postDoLabel);
30511
- currentFlow = finishFlowLabel(postDoLabel);
30512
- }
30513
- function bindForStatement(node) {
30514
- const preLoopLabel = setContinueTarget(node, createLoopLabel());
30515
- const preBodyLabel = createBranchLabel();
30516
- const postLoopLabel = createBranchLabel();
30517
- bind(node.initializer);
30518
- addAntecedent(preLoopLabel, currentFlow);
30519
- currentFlow = preLoopLabel;
30520
- bindCondition(node.condition, preBodyLabel, postLoopLabel);
30521
- currentFlow = finishFlowLabel(preBodyLabel);
30522
- bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
30523
- bind(node.incrementor);
30524
- addAntecedent(preLoopLabel, currentFlow);
30525
- currentFlow = finishFlowLabel(postLoopLabel);
30526
- }
30527
- function bindForInOrForOfStatement(node) {
30528
- const preLoopLabel = setContinueTarget(node, createLoopLabel());
30529
- const postLoopLabel = createBranchLabel();
30530
- bind(node.expression);
30531
- addAntecedent(preLoopLabel, currentFlow);
30532
- currentFlow = preLoopLabel;
30533
- if (node.kind === 247 /* ForOfStatement */) {
30534
- bind(node.awaitModifier);
30535
- }
30536
- addAntecedent(postLoopLabel, currentFlow);
30537
- bind(node.initializer);
30538
- if (node.initializer.kind !== 258 /* VariableDeclarationList */) {
30539
- bindAssignmentTargetFlow(node.initializer);
30540
- }
30541
- bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
30542
- addAntecedent(preLoopLabel, currentFlow);
30543
- currentFlow = finishFlowLabel(postLoopLabel);
30544
- }
30545
- function bindIfStatement(node) {
30546
- const thenLabel = createBranchLabel();
30547
- const elseLabel = createBranchLabel();
30548
- const postIfLabel = createBranchLabel();
30549
- bindCondition(node.expression, thenLabel, elseLabel);
30550
- currentFlow = finishFlowLabel(thenLabel);
30551
- bind(node.thenStatement);
30552
- addAntecedent(postIfLabel, currentFlow);
30553
- currentFlow = finishFlowLabel(elseLabel);
30554
- bind(node.elseStatement);
30555
- addAntecedent(postIfLabel, currentFlow);
30556
- currentFlow = finishFlowLabel(postIfLabel);
30557
- }
30558
- function bindReturnOrThrow(node) {
30559
- bind(node.expression);
30560
- if (node.kind === 250 /* ReturnStatement */) {
30561
- hasExplicitReturn = true;
30562
- if (currentReturnTarget) {
30563
- addAntecedent(currentReturnTarget, currentFlow);
30564
- }
30565
- }
30566
- currentFlow = unreachableFlow;
30567
- }
30568
- function findActiveLabel(name) {
30569
- for (let label = activeLabelList; label; label = label.next) {
30570
- if (label.name === name) {
30571
- return label;
30572
- }
30573
- }
30574
- return void 0;
30575
- }
30576
- function bindBreakOrContinueFlow(node, breakTarget, continueTarget) {
30577
- const flowLabel = node.kind === 249 /* BreakStatement */ ? breakTarget : continueTarget;
30578
- if (flowLabel) {
30579
- addAntecedent(flowLabel, currentFlow);
30580
- currentFlow = unreachableFlow;
30581
- }
30582
- }
30583
- function bindBreakOrContinueStatement(node) {
30584
- bind(node.label);
30585
- if (node.label) {
30586
- const activeLabel = findActiveLabel(node.label.escapedText);
30587
- if (activeLabel) {
30588
- activeLabel.referenced = true;
30589
- bindBreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget);
30590
- }
30591
- } else {
30592
- bindBreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget);
30593
- }
30594
- }
30595
- function bindTryStatement(node) {
30596
- const saveReturnTarget = currentReturnTarget;
30597
- const saveExceptionTarget = currentExceptionTarget;
30598
- const normalExitLabel = createBranchLabel();
30599
- const returnLabel = createBranchLabel();
30600
- let exceptionLabel = createBranchLabel();
30601
- if (node.finallyBlock) {
30602
- currentReturnTarget = returnLabel;
30603
- }
30604
- addAntecedent(exceptionLabel, currentFlow);
30605
- currentExceptionTarget = exceptionLabel;
30606
- bind(node.tryBlock);
30607
- addAntecedent(normalExitLabel, currentFlow);
30608
- if (node.catchClause) {
30609
- currentFlow = finishFlowLabel(exceptionLabel);
30610
- exceptionLabel = createBranchLabel();
30611
- addAntecedent(exceptionLabel, currentFlow);
30612
- currentExceptionTarget = exceptionLabel;
30613
- bind(node.catchClause);
30614
- addAntecedent(normalExitLabel, currentFlow);
30615
- }
30616
- currentReturnTarget = saveReturnTarget;
30617
- currentExceptionTarget = saveExceptionTarget;
30618
- if (node.finallyBlock) {
30619
- const finallyLabel = createBranchLabel();
30620
- finallyLabel.antecedents = concatenate(concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
30621
- currentFlow = finallyLabel;
30622
- bind(node.finallyBlock);
30623
- if (currentFlow.flags & 1 /* Unreachable */) {
30624
- currentFlow = unreachableFlow;
30625
- } else {
30626
- if (currentReturnTarget && returnLabel.antecedents) {
30627
- addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
30628
- }
30629
- if (currentExceptionTarget && exceptionLabel.antecedents) {
30630
- addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedents, currentFlow));
30631
- }
30632
- currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
30633
- }
30634
- } else {
30635
- currentFlow = finishFlowLabel(normalExitLabel);
30636
- }
30637
- }
30638
- function bindSwitchStatement(node) {
30639
- const postSwitchLabel = createBranchLabel();
30640
- bind(node.expression);
30641
- const saveBreakTarget = currentBreakTarget;
30642
- const savePreSwitchCaseFlow = preSwitchCaseFlow;
30643
- currentBreakTarget = postSwitchLabel;
30644
- preSwitchCaseFlow = currentFlow;
30645
- bind(node.caseBlock);
30646
- addAntecedent(postSwitchLabel, currentFlow);
30647
- const hasDefault = forEach(node.caseBlock.clauses, (c) => c.kind === 293 /* DefaultClause */);
30648
- node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
30649
- if (!hasDefault) {
30650
- addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
30651
- }
30652
- currentBreakTarget = saveBreakTarget;
30653
- preSwitchCaseFlow = savePreSwitchCaseFlow;
30654
- currentFlow = finishFlowLabel(postSwitchLabel);
30655
- }
30656
- function bindCaseBlock(node) {
30657
- const clauses = node.clauses;
30658
- const isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
30659
- let fallthroughFlow = unreachableFlow;
30660
- for (let i = 0; i < clauses.length; i++) {
30661
- const clauseStart = i;
30662
- while (!clauses[i].statements.length && i + 1 < clauses.length) {
30663
- bind(clauses[i]);
30664
- i++;
30665
- }
30666
- const preCaseLabel = createBranchLabel();
30667
- addAntecedent(preCaseLabel, isNarrowingSwitch ? createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1) : preSwitchCaseFlow);
30668
- addAntecedent(preCaseLabel, fallthroughFlow);
30669
- currentFlow = finishFlowLabel(preCaseLabel);
30670
- const clause = clauses[i];
30671
- bind(clause);
30672
- fallthroughFlow = currentFlow;
30673
- if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
30674
- clause.fallthroughFlowNode = currentFlow;
30675
- }
30676
- }
30677
- }
30678
- function bindCaseClause(node) {
30679
- const saveCurrentFlow = currentFlow;
30680
- currentFlow = preSwitchCaseFlow;
30681
- bind(node.expression);
30682
- currentFlow = saveCurrentFlow;
30683
- bindEach(node.statements);
30684
- }
30685
- function bindExpressionStatement(node) {
30686
- bind(node.expression);
30687
- maybeBindExpressionFlowIfCall(node.expression);
30688
- }
30689
- function maybeBindExpressionFlowIfCall(node) {
30690
- if (node.kind === 210 /* CallExpression */) {
30691
- const call = node;
30692
- if (call.expression.kind !== 106 /* SuperKeyword */ && isDottedName(call.expression)) {
30693
- currentFlow = createFlowCall(currentFlow, call);
30694
- }
30695
- }
30696
- }
30697
- function bindLabeledStatement(node) {
30698
- const postStatementLabel = createBranchLabel();
30699
- activeLabelList = {
30700
- next: activeLabelList,
30701
- name: node.label.escapedText,
30702
- breakTarget: postStatementLabel,
30703
- continueTarget: void 0,
30704
- referenced: false
30705
- };
30706
- bind(node.label);
30707
- bind(node.statement);
30708
- if (!activeLabelList.referenced && !options.allowUnusedLabels) {
30709
- errorOrSuggestionOnNode(unusedLabelIsError(options), node.label, Diagnostics.Unused_label);
30710
- }
30711
- activeLabelList = activeLabelList.next;
30712
- addAntecedent(postStatementLabel, currentFlow);
30713
- currentFlow = finishFlowLabel(postStatementLabel);
30714
- }
30715
- function bindDestructuringTargetFlow(node) {
30716
- if (node.kind === 223 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) {
30717
- bindAssignmentTargetFlow(node.left);
30718
- } else {
30719
- bindAssignmentTargetFlow(node);
30720
- }
30721
- }
30722
- function bindAssignmentTargetFlow(node) {
30723
- if (isNarrowableReference(node)) {
30724
- currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node);
30725
- } else if (node.kind === 206 /* ArrayLiteralExpression */) {
30726
- for (const e of node.elements) {
30727
- if (e.kind === 227 /* SpreadElement */) {
30728
- bindAssignmentTargetFlow(e.expression);
30729
- } else {
30730
- bindDestructuringTargetFlow(e);
30731
- }
30732
- }
30733
- } else if (node.kind === 207 /* ObjectLiteralExpression */) {
30734
- for (const p of node.properties) {
30735
- if (p.kind === 299 /* PropertyAssignment */) {
30736
- bindDestructuringTargetFlow(p.initializer);
30737
- } else if (p.kind === 300 /* ShorthandPropertyAssignment */) {
30738
- bindAssignmentTargetFlow(p.name);
30739
- } else if (p.kind === 301 /* SpreadAssignment */) {
30740
- bindAssignmentTargetFlow(p.expression);
30741
- }
30742
- }
30743
- }
30744
- }
30745
- function bindLogicalLikeExpression(node, trueTarget, falseTarget) {
30746
- const preRightLabel = createBranchLabel();
30747
- if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) {
30748
- bindCondition(node.left, preRightLabel, falseTarget);
30749
- } else {
30750
- bindCondition(node.left, trueTarget, preRightLabel);
30751
- }
30752
- currentFlow = finishFlowLabel(preRightLabel);
30753
- bind(node.operatorToken);
30754
- if (isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) {
30755
- doWithConditionalBranches(bind, node.right, trueTarget, falseTarget);
30756
- bindAssignmentTargetFlow(node.left);
30757
- addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
30758
- addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
30759
- } else {
30760
- bindCondition(node.right, trueTarget, falseTarget);
30761
- }
30762
- }
30763
- function bindPrefixUnaryExpressionFlow(node) {
30764
- if (node.operator === 53 /* ExclamationToken */) {
30765
- const saveTrueTarget = currentTrueTarget;
30766
- currentTrueTarget = currentFalseTarget;
30767
- currentFalseTarget = saveTrueTarget;
30768
- bindEachChild(node);
30769
- currentFalseTarget = currentTrueTarget;
30770
- currentTrueTarget = saveTrueTarget;
30771
- } else {
30772
- bindEachChild(node);
30773
- if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
30774
- bindAssignmentTargetFlow(node.operand);
30775
- }
30776
- }
30777
- }
30778
- function bindPostfixUnaryExpressionFlow(node) {
30779
- bindEachChild(node);
30780
- if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
30781
- bindAssignmentTargetFlow(node.operand);
30782
- }
30783
- }
30784
- function bindDestructuringAssignmentFlow(node) {
30785
- if (inAssignmentPattern) {
30786
- inAssignmentPattern = false;
30787
- bind(node.operatorToken);
30788
- bind(node.right);
30789
- inAssignmentPattern = true;
30790
- bind(node.left);
30791
- } else {
30792
- inAssignmentPattern = true;
30793
- bind(node.left);
30794
- inAssignmentPattern = false;
30795
- bind(node.operatorToken);
30796
- bind(node.right);
30797
- }
30798
- bindAssignmentTargetFlow(node.left);
30799
- }
30800
- function createBindBinaryExpressionFlow() {
30801
- return createBinaryExpressionTrampoline(
30802
- onEnter,
30803
- onLeft,
30804
- onOperator,
30805
- onRight,
30806
- onExit,
30807
- /*foldState*/
30808
- void 0
30809
- );
30810
- function onEnter(node, state) {
30811
- if (state) {
30812
- state.stackIndex++;
30813
- setParent(node, parent);
30814
- const saveInStrictMode = inStrictMode;
30815
- bindWorker(node);
30816
- const saveParent = parent;
30817
- parent = node;
30818
- state.skip = false;
30819
- state.inStrictModeStack[state.stackIndex] = saveInStrictMode;
30820
- state.parentStack[state.stackIndex] = saveParent;
30821
- } else {
30822
- state = {
30823
- stackIndex: 0,
30824
- skip: false,
30825
- inStrictModeStack: [void 0],
30826
- parentStack: [void 0]
30827
- };
30828
- }
30829
- const operator = node.operatorToken.kind;
30830
- if (isLogicalOrCoalescingBinaryOperator(operator) || isLogicalOrCoalescingAssignmentOperator(operator)) {
30831
- if (isTopLevelLogicalExpression(node)) {
30832
- const postExpressionLabel = createBranchLabel();
30833
- bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel);
30834
- currentFlow = finishFlowLabel(postExpressionLabel);
30835
- } else {
30836
- bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget);
30837
- }
30838
- state.skip = true;
30839
- }
30840
- return state;
30841
- }
30842
- function onLeft(left, state, node) {
30843
- if (!state.skip) {
30844
- const maybeBound = maybeBind2(left);
30845
- if (node.operatorToken.kind === 27 /* CommaToken */) {
30846
- maybeBindExpressionFlowIfCall(left);
30847
- }
30848
- return maybeBound;
30849
- }
30850
- }
30851
- function onOperator(operatorToken, state, _node) {
30852
- if (!state.skip) {
30853
- bind(operatorToken);
30854
- }
30855
- }
30856
- function onRight(right, state, node) {
30857
- if (!state.skip) {
30858
- const maybeBound = maybeBind2(right);
30859
- if (node.operatorToken.kind === 27 /* CommaToken */) {
30860
- maybeBindExpressionFlowIfCall(right);
30861
- }
30862
- return maybeBound;
30863
- }
30864
- }
30865
- function onExit(node, state) {
30866
- if (!state.skip) {
30867
- const operator = node.operatorToken.kind;
30868
- if (isAssignmentOperator(operator) && !isAssignmentTarget(node)) {
30869
- bindAssignmentTargetFlow(node.left);
30870
- if (operator === 63 /* EqualsToken */ && node.left.kind === 209 /* ElementAccessExpression */) {
30871
- const elementAccess = node.left;
30872
- if (isNarrowableOperand(elementAccess.expression)) {
30873
- currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node);
30874
- }
30875
- }
30876
- }
30877
- }
30878
- const savedInStrictMode = state.inStrictModeStack[state.stackIndex];
30879
- const savedParent = state.parentStack[state.stackIndex];
30880
- if (savedInStrictMode !== void 0) {
30881
- inStrictMode = savedInStrictMode;
30882
- }
30883
- if (savedParent !== void 0) {
30884
- parent = savedParent;
30885
- }
30886
- state.skip = false;
30887
- state.stackIndex--;
30888
- }
30889
- function maybeBind2(node) {
30890
- if (node && isBinaryExpression(node) && !isDestructuringAssignment(node)) {
30891
- return node;
30892
- }
30893
- bind(node);
30894
- }
30895
- }
30896
- function bindDeleteExpressionFlow(node) {
30897
- bindEachChild(node);
30898
- if (node.expression.kind === 208 /* PropertyAccessExpression */) {
30899
- bindAssignmentTargetFlow(node.expression);
30900
- }
30901
- }
30902
- function bindConditionalExpressionFlow(node) {
30903
- const trueLabel = createBranchLabel();
30904
- const falseLabel = createBranchLabel();
30905
- const postExpressionLabel = createBranchLabel();
30906
- bindCondition(node.condition, trueLabel, falseLabel);
30907
- currentFlow = finishFlowLabel(trueLabel);
30908
- bind(node.questionToken);
30909
- bind(node.whenTrue);
30910
- addAntecedent(postExpressionLabel, currentFlow);
30911
- currentFlow = finishFlowLabel(falseLabel);
30912
- bind(node.colonToken);
30913
- bind(node.whenFalse);
30914
- addAntecedent(postExpressionLabel, currentFlow);
30915
- currentFlow = finishFlowLabel(postExpressionLabel);
30916
- }
30917
- function bindInitializedVariableFlow(node) {
30918
- const name = !isOmittedExpression(node) ? node.name : void 0;
30919
- if (isBindingPattern(name)) {
30920
- for (const child of name.elements) {
30921
- bindInitializedVariableFlow(child);
30922
- }
30923
- } else {
30924
- currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node);
30925
- }
30926
- }
30927
- function bindVariableDeclarationFlow(node) {
30928
- bindEachChild(node);
30929
- if (node.initializer || isForInOrOfStatement(node.parent.parent)) {
30930
- bindInitializedVariableFlow(node);
30931
- }
30932
- }
30933
- function bindBindingElementFlow(node) {
30934
- bind(node.dotDotDotToken);
30935
- bind(node.propertyName);
30936
- bindInitializer(node.initializer);
30937
- bind(node.name);
30938
- }
30939
- function bindParameterFlow(node) {
30940
- bindEach(node.modifiers);
30941
- bind(node.dotDotDotToken);
30942
- bind(node.questionToken);
30943
- bind(node.type);
30944
- bindInitializer(node.initializer);
30945
- bind(node.name);
30946
- }
30947
- function bindInitializer(node) {
30948
- if (!node) {
30949
- return;
30950
- }
30951
- const entryFlow = currentFlow;
30952
- bind(node);
30953
- if (entryFlow === unreachableFlow || entryFlow === currentFlow) {
30954
- return;
30955
- }
30956
- const exitFlow = createBranchLabel();
30957
- addAntecedent(exitFlow, entryFlow);
30958
- addAntecedent(exitFlow, currentFlow);
30959
- currentFlow = finishFlowLabel(exitFlow);
30960
- }
30961
- function bindJSDocTypeAlias(node) {
30962
- bind(node.tagName);
30963
- if (node.kind !== 343 /* JSDocEnumTag */ && node.fullName) {
30964
- setParent(node.fullName, node);
30965
- setParentRecursive(
30966
- node.fullName,
30967
- /*incremental*/
30968
- false
30969
- );
30970
- }
30971
- if (typeof node.comment !== "string") {
30972
- bindEach(node.comment);
30973
- }
30974
- }
30975
- function bindJSDocClassTag(node) {
30976
- bindEachChild(node);
30977
- const host = getHostSignatureFromJSDoc(node);
30978
- if (host && host.kind !== 171 /* MethodDeclaration */) {
30979
- addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
30980
- }
30981
- }
30982
- function bindOptionalExpression(node, trueTarget, falseTarget) {
30983
- doWithConditionalBranches(bind, node, trueTarget, falseTarget);
30984
- if (!isOptionalChain(node) || isOutermostOptionalChain(node)) {
30985
- addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
30986
- addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
30987
- }
30988
- }
30989
- function bindOptionalChainRest(node) {
30990
- switch (node.kind) {
30991
- case 208 /* PropertyAccessExpression */:
30992
- bind(node.questionDotToken);
30993
- bind(node.name);
30994
- break;
30995
- case 209 /* ElementAccessExpression */:
30996
- bind(node.questionDotToken);
30997
- bind(node.argumentExpression);
30998
- break;
30999
- case 210 /* CallExpression */:
31000
- bind(node.questionDotToken);
31001
- bindEach(node.typeArguments);
31002
- bindEach(node.arguments);
31003
- break;
31004
- }
31005
- }
31006
- function bindOptionalChain(node, trueTarget, falseTarget) {
31007
- const preChainLabel = isOptionalChainRoot(node) ? createBranchLabel() : void 0;
31008
- bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget);
31009
- if (preChainLabel) {
31010
- currentFlow = finishFlowLabel(preChainLabel);
31011
- }
31012
- doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
31013
- if (isOutermostOptionalChain(node)) {
31014
- addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
31015
- addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
31016
- }
31017
- }
31018
- function bindOptionalChainFlow(node) {
31019
- if (isTopLevelLogicalExpression(node)) {
31020
- const postExpressionLabel = createBranchLabel();
31021
- bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
31022
- currentFlow = finishFlowLabel(postExpressionLabel);
31023
- } else {
31024
- bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
31025
- }
31026
- }
31027
- function bindNonNullExpressionFlow(node) {
31028
- if (isOptionalChain(node)) {
31029
- bindOptionalChainFlow(node);
31030
- } else {
31031
- bindEachChild(node);
31032
- }
31033
- }
31034
- function bindAccessExpressionFlow(node) {
31035
- if (isOptionalChain(node)) {
31036
- bindOptionalChainFlow(node);
31037
- } else {
31038
- bindEachChild(node);
31039
- }
31040
- }
31041
- function bindCallExpressionFlow(node) {
31042
- if (isOptionalChain(node)) {
31043
- bindOptionalChainFlow(node);
31044
- } else {
31045
- const expr = skipParentheses(node.expression);
31046
- if (expr.kind === 215 /* FunctionExpression */ || expr.kind === 216 /* ArrowFunction */) {
31047
- bindEach(node.typeArguments);
31048
- bindEach(node.arguments);
31049
- bind(node.expression);
31050
- } else {
31051
- bindEachChild(node);
31052
- if (node.expression.kind === 106 /* SuperKeyword */) {
31053
- currentFlow = createFlowCall(currentFlow, node);
31054
- }
31055
- }
31056
- }
31057
- if (node.expression.kind === 208 /* PropertyAccessExpression */) {
31058
- const propertyAccess = node.expression;
31059
- if (isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && isPushOrUnshiftIdentifier(propertyAccess.name)) {
31060
- currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node);
31061
- }
31062
- }
31063
- }
31064
- function addToContainerChain(next) {
31065
- if (lastContainer) {
31066
- lastContainer.nextContainer = next;
31067
- }
31068
- lastContainer = next;
31069
- }
31070
- function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) {
31071
- switch (container.kind) {
31072
- case 264 /* ModuleDeclaration */:
31073
- return declareModuleMember(node, symbolFlags, symbolExcludes);
31074
- case 308 /* SourceFile */:
31075
- return declareSourceFileMember(node, symbolFlags, symbolExcludes);
31076
- case 228 /* ClassExpression */:
31077
- case 260 /* ClassDeclaration */:
31078
- return declareClassMember(node, symbolFlags, symbolExcludes);
31079
- case 263 /* EnumDeclaration */:
31080
- return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
31081
- case 184 /* TypeLiteral */:
31082
- case 325 /* JSDocTypeLiteral */:
31083
- case 207 /* ObjectLiteralExpression */:
31084
- case 261 /* InterfaceDeclaration */:
31085
- case 289 /* JsxAttributes */:
31086
- return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
31087
- case 181 /* FunctionType */:
31088
- case 182 /* ConstructorType */:
31089
- case 176 /* CallSignature */:
31090
- case 177 /* ConstructSignature */:
31091
- case 326 /* JSDocSignature */:
31092
- case 178 /* IndexSignature */:
31093
- case 171 /* MethodDeclaration */:
31094
- case 170 /* MethodSignature */:
31095
- case 173 /* Constructor */:
31096
- case 174 /* GetAccessor */:
31097
- case 175 /* SetAccessor */:
31098
- case 259 /* FunctionDeclaration */:
31099
- case 215 /* FunctionExpression */:
31100
- case 216 /* ArrowFunction */:
31101
- case 320 /* JSDocFunctionType */:
31102
- case 172 /* ClassStaticBlockDeclaration */:
31103
- case 262 /* TypeAliasDeclaration */:
31104
- case 197 /* MappedType */:
31105
- if (container.locals)
31106
- Debug.assertNode(container, canHaveLocals);
31107
- return declareSymbol(
31108
- container.locals,
31109
- /*parent*/
31110
- void 0,
31111
- node,
31112
- symbolFlags,
31113
- symbolExcludes
31114
- );
31115
- }
31116
- }
31117
- function declareClassMember(node, symbolFlags, symbolExcludes) {
31118
- return isStatic(node) ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
31119
- }
31120
- function declareSourceFileMember(node, symbolFlags, symbolExcludes) {
31121
- return isExternalModule(file) ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(
31122
- file.locals,
31123
- /*parent*/
31124
- void 0,
31125
- node,
31126
- symbolFlags,
31127
- symbolExcludes
31128
- );
31129
- }
31130
- function hasExportDeclarations(node) {
31131
- const body = isSourceFile(node) ? node : tryCast(node.body, isModuleBlock);
31132
- return !!body && body.statements.some((s) => isExportDeclaration(s) || isExportAssignment(s));
31133
- }
31134
- function setExportContextFlag(node) {
31135
- if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
31136
- node.flags |= 64 /* ExportContext */;
31137
- } else {
31138
- node.flags &= ~64 /* ExportContext */;
31139
- }
31140
- }
31141
- function bindModuleDeclaration(node) {
31142
- setExportContextFlag(node);
31143
- if (isAmbientModule(node)) {
31144
- if (hasSyntacticModifier(node, 1 /* Export */)) {
31145
- errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
31146
- }
31147
- if (isModuleAugmentationExternal(node)) {
31148
- declareModuleSymbol(node);
31149
- } else {
31150
- let pattern;
31151
- if (node.name.kind === 10 /* StringLiteral */) {
31152
- const { text } = node.name;
31153
- pattern = tryParsePattern(text);
31154
- if (pattern === void 0) {
31155
- errorOnFirstToken(node.name, Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text);
31156
- }
31157
- }
31158
- const symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */);
31159
- file.patternAmbientModules = append(file.patternAmbientModules, pattern && !isString(pattern) ? { pattern, symbol } : void 0);
31160
- }
31161
- } else {
31162
- const state = declareModuleSymbol(node);
31163
- if (state !== 0 /* NonInstantiated */) {
31164
- const { symbol } = node;
31165
- symbol.constEnumOnlyModule = !(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) && state === 2 /* ConstEnumOnly */ && symbol.constEnumOnlyModule !== false;
31166
- }
31167
- }
31168
- }
31169
- function declareModuleSymbol(node) {
31170
- const state = getModuleInstanceState(node);
31171
- const instantiated = state !== 0 /* NonInstantiated */;
31172
- declareSymbolAndAddToSymbolTable(
31173
- node,
31174
- instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */,
31175
- instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */
31176
- );
31177
- return state;
31178
- }
31179
- function bindFunctionOrConstructorType(node) {
31180
- const symbol = createSymbol(131072 /* Signature */, getDeclarationName(node));
31181
- addDeclarationToSymbol(symbol, node, 131072 /* Signature */);
31182
- const typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
31183
- addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */);
31184
- typeLiteralSymbol.members = createSymbolTable();
31185
- typeLiteralSymbol.members.set(symbol.escapedName, symbol);
31186
- }
31187
- function bindObjectLiteralExpression(node) {
31188
- return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */);
31189
- }
31190
- function bindJsxAttributes(node) {
31191
- return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */);
31192
- }
31193
- function bindJsxAttribute(node, symbolFlags, symbolExcludes) {
31194
- return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
31195
- }
31196
- function bindAnonymousDeclaration(node, symbolFlags, name) {
31197
- const symbol = createSymbol(symbolFlags, name);
31198
- if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) {
31199
- symbol.parent = container.symbol;
31200
- }
31201
- addDeclarationToSymbol(symbol, node, symbolFlags);
31202
- return symbol;
31203
- }
31204
- function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
31205
- switch (blockScopeContainer.kind) {
31206
- case 264 /* ModuleDeclaration */:
31207
- declareModuleMember(node, symbolFlags, symbolExcludes);
31208
- break;
31209
- case 308 /* SourceFile */:
31210
- if (isExternalOrCommonJsModule(container)) {
31211
- declareModuleMember(node, symbolFlags, symbolExcludes);
31212
- break;
31213
- }
31214
- default:
31215
- Debug.assertNode(blockScopeContainer, canHaveLocals);
31216
- if (!blockScopeContainer.locals) {
31217
- blockScopeContainer.locals = createSymbolTable();
31218
- addToContainerChain(blockScopeContainer);
31219
- }
31220
- declareSymbol(
31221
- blockScopeContainer.locals,
31222
- /*parent*/
31223
- void 0,
31224
- node,
31225
- symbolFlags,
31226
- symbolExcludes
31227
- );
31228
- }
31229
- }
31230
- function delayedBindJSDocTypedefTag() {
31231
- if (!delayedTypeAliases) {
31232
- return;
31233
- }
31234
- const saveContainer = container;
31235
- const saveLastContainer = lastContainer;
31236
- const saveBlockScopeContainer = blockScopeContainer;
31237
- const saveParent = parent;
31238
- const saveCurrentFlow = currentFlow;
31239
- for (const typeAlias of delayedTypeAliases) {
31240
- const host = typeAlias.parent.parent;
31241
- container = findAncestor(host.parent, (n) => !!(getContainerFlags(n) & 1 /* IsContainer */)) || file;
31242
- blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
31243
- currentFlow = initFlowNode({ flags: 2 /* Start */ });
31244
- parent = typeAlias;
31245
- bind(typeAlias.typeExpression);
31246
- const declName = getNameOfDeclaration(typeAlias);
31247
- if ((isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && isPropertyAccessEntityNameExpression(declName.parent)) {
31248
- const isTopLevel = isTopLevelNamespaceAssignment(declName.parent);
31249
- if (isTopLevel) {
31250
- bindPotentiallyMissingNamespaces(
31251
- file.symbol,
31252
- declName.parent,
31253
- isTopLevel,
31254
- !!findAncestor(declName, (d) => isPropertyAccessExpression(d) && d.name.escapedText === "prototype"),
31255
- /*containerIsClass*/
31256
- false
31257
- );
31258
- const oldContainer = container;
31259
- switch (getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
31260
- case 1 /* ExportsProperty */:
31261
- case 2 /* ModuleExports */:
31262
- if (!isExternalOrCommonJsModule(file)) {
31263
- container = void 0;
31264
- } else {
31265
- container = file;
31266
- }
31267
- break;
31268
- case 4 /* ThisProperty */:
31269
- container = declName.parent.expression;
31270
- break;
31271
- case 3 /* PrototypeProperty */:
31272
- container = declName.parent.expression.name;
31273
- break;
31274
- case 5 /* Property */:
31275
- container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression;
31276
- break;
31277
- case 0 /* None */:
31278
- return Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
31279
- }
31280
- if (container) {
31281
- declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */);
31282
- }
31283
- container = oldContainer;
31284
- }
31285
- } else if (isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) {
31286
- parent = typeAlias.parent;
31287
- bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */);
31288
- } else {
31289
- bind(typeAlias.fullName);
31290
- }
31291
- }
31292
- container = saveContainer;
31293
- lastContainer = saveLastContainer;
31294
- blockScopeContainer = saveBlockScopeContainer;
31295
- parent = saveParent;
31296
- currentFlow = saveCurrentFlow;
31297
- }
31298
- function checkContextualIdentifier(node) {
31299
- if (!file.parseDiagnostics.length && !(node.flags & 16777216 /* Ambient */) && !(node.flags & 8388608 /* JSDoc */) && !isIdentifierName(node)) {
31300
- const originalKeywordKind = identifierToKeywordKind(node);
31301
- if (originalKeywordKind === void 0) {
31302
- return;
31303
- }
31304
- if (inStrictMode && originalKeywordKind >= 117 /* FirstFutureReservedWord */ && originalKeywordKind <= 125 /* LastFutureReservedWord */) {
31305
- file.bindDiagnostics.push(createDiagnosticForNode2(
31306
- node,
31307
- getStrictModeIdentifierMessage(node),
31308
- declarationNameToString(node)
31309
- ));
31310
- } else if (originalKeywordKind === 133 /* AwaitKeyword */) {
31311
- if (isExternalModule(file) && isInTopLevelContext(node)) {
31312
- file.bindDiagnostics.push(createDiagnosticForNode2(
31313
- node,
31314
- Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module,
31315
- declarationNameToString(node)
31316
- ));
31317
- } else if (node.flags & 32768 /* AwaitContext */) {
31318
- file.bindDiagnostics.push(createDiagnosticForNode2(
31319
- node,
31320
- Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here,
31321
- declarationNameToString(node)
31322
- ));
31323
- }
31324
- } else if (originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) {
31325
- file.bindDiagnostics.push(createDiagnosticForNode2(
31326
- node,
31327
- Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here,
31328
- declarationNameToString(node)
31329
- ));
31330
- }
31331
- }
31332
- }
31333
- function getStrictModeIdentifierMessage(node) {
31334
- if (getContainingClass(node)) {
31335
- return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
31336
- }
31337
- if (file.externalModuleIndicator) {
31338
- return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode;
31339
- }
31340
- return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode;
31341
- }
31342
- function checkPrivateIdentifier(node) {
31343
- if (node.escapedText === "#constructor") {
31344
- if (!file.parseDiagnostics.length) {
31345
- file.bindDiagnostics.push(createDiagnosticForNode2(
31346
- node,
31347
- Diagnostics.constructor_is_a_reserved_word,
31348
- declarationNameToString(node)
31349
- ));
31350
- }
31351
- }
31352
- }
31353
- function checkStrictModeBinaryExpression(node) {
31354
- if (inStrictMode && isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operatorToken.kind)) {
31355
- checkStrictModeEvalOrArguments(node, node.left);
31356
- }
31357
- }
31358
- function checkStrictModeCatchClause(node) {
31359
- if (inStrictMode && node.variableDeclaration) {
31360
- checkStrictModeEvalOrArguments(node, node.variableDeclaration.name);
31361
- }
31362
- }
31363
- function checkStrictModeDeleteExpression(node) {
31364
- if (inStrictMode && node.expression.kind === 79 /* Identifier */) {
31365
- const span = getErrorSpanForNode(file, node.expression);
31366
- file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode));
31367
- }
31368
- }
31369
- function isEvalOrArgumentsIdentifier(node) {
31370
- return isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments");
31371
- }
31372
- function checkStrictModeEvalOrArguments(contextNode, name) {
31373
- if (name && name.kind === 79 /* Identifier */) {
31374
- const identifier = name;
31375
- if (isEvalOrArgumentsIdentifier(identifier)) {
31376
- const span = getErrorSpanForNode(file, name);
31377
- file.bindDiagnostics.push(createFileDiagnostic(
31378
- file,
31379
- span.start,
31380
- span.length,
31381
- getStrictModeEvalOrArgumentsMessage(contextNode),
31382
- idText(identifier)
31383
- ));
31384
- }
31385
- }
31386
- }
31387
- function getStrictModeEvalOrArgumentsMessage(node) {
31388
- if (getContainingClass(node)) {
31389
- return Diagnostics.Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode;
31390
- }
31391
- if (file.externalModuleIndicator) {
31392
- return Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode;
31393
- }
31394
- return Diagnostics.Invalid_use_of_0_in_strict_mode;
31395
- }
31396
- function checkStrictModeFunctionName(node) {
31397
- if (inStrictMode) {
31398
- checkStrictModeEvalOrArguments(node, node.name);
31399
- }
31400
- }
31401
- function getStrictModeBlockScopeFunctionDeclarationMessage(node) {
31402
- if (getContainingClass(node)) {
31403
- return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode;
31404
- }
31405
- if (file.externalModuleIndicator) {
31406
- return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode;
31407
- }
31408
- return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
31409
- }
31410
- function checkStrictModeFunctionDeclaration(node) {
31411
- if (languageVersion < 2 /* ES2015 */) {
31412
- if (blockScopeContainer.kind !== 308 /* SourceFile */ && blockScopeContainer.kind !== 264 /* ModuleDeclaration */ && !isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) {
31413
- const errorSpan = getErrorSpanForNode(file, node);
31414
- file.bindDiagnostics.push(createFileDiagnostic(
31415
- file,
31416
- errorSpan.start,
31417
- errorSpan.length,
31418
- getStrictModeBlockScopeFunctionDeclarationMessage(node)
31419
- ));
31420
- }
31421
- }
31422
- }
31423
- function checkStrictModeNumericLiteral(node) {
31424
- if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) {
31425
- file.bindDiagnostics.push(createDiagnosticForNode2(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
31426
- }
31427
- }
31428
- function checkStrictModePostfixUnaryExpression(node) {
31429
- if (inStrictMode) {
31430
- checkStrictModeEvalOrArguments(node, node.operand);
31431
- }
31432
- }
31433
- function checkStrictModePrefixUnaryExpression(node) {
31434
- if (inStrictMode) {
31435
- if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
31436
- checkStrictModeEvalOrArguments(node, node.operand);
31437
- }
31438
- }
31439
- }
31440
- function checkStrictModeWithStatement(node) {
31441
- if (inStrictMode) {
31442
- errorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode);
31443
- }
31444
- }
31445
- function checkStrictModeLabeledStatement(node) {
31446
- if (inStrictMode && getEmitScriptTarget(options) >= 2 /* ES2015 */) {
31447
- if (isDeclarationStatement(node.statement) || isVariableStatement(node.statement)) {
31448
- errorOnFirstToken(node.label, Diagnostics.A_label_is_not_allowed_here);
31449
- }
31450
- }
31451
- }
31452
- function errorOnFirstToken(node, message, arg0, arg1, arg2) {
31453
- const span = getSpanOfTokenAtPosition(file, node.pos);
31454
- file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2));
31455
- }
31456
- function errorOrSuggestionOnNode(isError, node, message) {
31457
- errorOrSuggestionOnRange(isError, node, node, message);
31458
- }
31459
- function errorOrSuggestionOnRange(isError, startNode, endNode, message) {
31460
- addErrorOrSuggestionDiagnostic(isError, { pos: getTokenPosOfNode(startNode, file), end: endNode.end }, message);
31461
- }
31462
- function addErrorOrSuggestionDiagnostic(isError, range, message) {
31463
- const diag2 = createFileDiagnostic(file, range.pos, range.end - range.pos, message);
31464
- if (isError) {
31465
- file.bindDiagnostics.push(diag2);
31466
- } else {
31467
- file.bindSuggestionDiagnostics = append(file.bindSuggestionDiagnostics, { ...diag2, category: 2 /* Suggestion */ });
31468
- }
31469
- }
31470
- function bind(node) {
31471
- if (!node) {
31472
- return;
31473
- }
31474
- setParent(node, parent);
31475
- if (tracing)
31476
- node.tracingPath = file.path;
31477
- const saveInStrictMode = inStrictMode;
31478
- bindWorker(node);
31479
- if (node.kind > 162 /* LastToken */) {
31480
- const saveParent = parent;
31481
- parent = node;
31482
- const containerFlags = getContainerFlags(node);
31483
- if (containerFlags === 0 /* None */) {
31484
- bindChildren(node);
31485
- } else {
31486
- bindContainer(node, containerFlags);
31487
- }
31488
- parent = saveParent;
31489
- } else {
31490
- const saveParent = parent;
31491
- if (node.kind === 1 /* EndOfFileToken */)
31492
- parent = node;
31493
- bindJSDoc(node);
31494
- parent = saveParent;
31495
- }
31496
- inStrictMode = saveInStrictMode;
31497
- }
31498
- function bindJSDoc(node) {
31499
- if (hasJSDocNodes(node)) {
31500
- if (isInJSFile(node)) {
31501
- for (const j of node.jsDoc) {
31502
- bind(j);
31503
- }
31504
- } else {
31505
- for (const j of node.jsDoc) {
31506
- setParent(j, node);
31507
- setParentRecursive(
31508
- j,
31509
- /*incremental*/
31510
- false
31511
- );
31512
- }
31513
- }
31514
- }
31515
- }
31516
- function updateStrictModeStatementList(statements) {
31517
- if (!inStrictMode) {
31518
- for (const statement of statements) {
31519
- if (!isPrologueDirective(statement)) {
31520
- return;
31521
- }
31522
- if (isUseStrictPrologueDirective(statement)) {
31523
- inStrictMode = true;
31524
- return;
31525
- }
31526
- }
31527
- }
31528
- }
31529
- function isUseStrictPrologueDirective(node) {
31530
- const nodeText = getSourceTextOfNodeFromSourceFile(file, node.expression);
31531
- return nodeText === '"use strict"' || nodeText === "'use strict'";
31532
- }
31533
- function bindWorker(node) {
31534
- switch (node.kind) {
31535
- case 79 /* Identifier */:
31536
- if (node.flags & 2048 /* IdentifierIsInJSDocNamespace */) {
31537
- let parentNode = node.parent;
31538
- while (parentNode && !isJSDocTypeAlias(parentNode)) {
31539
- parentNode = parentNode.parent;
31540
- }
31541
- bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */);
31542
- break;
31543
- }
31544
- case 108 /* ThisKeyword */:
31545
- if (currentFlow && (isExpression(node) || parent.kind === 300 /* ShorthandPropertyAssignment */)) {
31546
- node.flowNode = currentFlow;
31547
- }
31548
- return checkContextualIdentifier(node);
31549
- case 163 /* QualifiedName */:
31550
- if (currentFlow && isPartOfTypeQuery(node)) {
31551
- node.flowNode = currentFlow;
31552
- }
31553
- break;
31554
- case 233 /* MetaProperty */:
31555
- case 106 /* SuperKeyword */:
31556
- node.flowNode = currentFlow;
31557
- break;
31558
- case 80 /* PrivateIdentifier */:
31559
- return checkPrivateIdentifier(node);
31560
- case 208 /* PropertyAccessExpression */:
31561
- case 209 /* ElementAccessExpression */:
31562
- const expr = node;
31563
- if (currentFlow && isNarrowableReference(expr)) {
31564
- expr.flowNode = currentFlow;
31565
- }
31566
- if (isSpecialPropertyDeclaration(expr)) {
31567
- bindSpecialPropertyDeclaration(expr);
31568
- }
31569
- if (isInJSFile(expr) && file.commonJsModuleIndicator && isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) {
31570
- declareSymbol(
31571
- file.locals,
31572
- /*parent*/
31573
- void 0,
31574
- expr.expression,
31575
- 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */,
31576
- 111550 /* FunctionScopedVariableExcludes */
31577
- );
31578
- }
31579
- break;
31580
- case 223 /* BinaryExpression */:
31581
- const specialKind = getAssignmentDeclarationKind(node);
31582
- switch (specialKind) {
31583
- case 1 /* ExportsProperty */:
31584
- bindExportsPropertyAssignment(node);
31585
- break;
31586
- case 2 /* ModuleExports */:
31587
- bindModuleExportsAssignment(node);
31588
- break;
31589
- case 3 /* PrototypeProperty */:
31590
- bindPrototypePropertyAssignment(node.left, node);
31591
- break;
31592
- case 6 /* Prototype */:
31593
- bindPrototypeAssignment(node);
31594
- break;
31595
- case 4 /* ThisProperty */:
31596
- bindThisPropertyAssignment(node);
31597
- break;
31598
- case 5 /* Property */:
31599
- const expression = node.left.expression;
31600
- if (isInJSFile(node) && isIdentifier(expression)) {
31601
- const symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText);
31602
- if (isThisInitializedDeclaration(symbol == null ? void 0 : symbol.valueDeclaration)) {
31603
- bindThisPropertyAssignment(node);
31604
- break;
31605
- }
31606
- }
31607
- bindSpecialPropertyAssignment(node);
31608
- break;
31609
- case 0 /* None */:
31610
- break;
31611
- default:
31612
- Debug.fail("Unknown binary expression special property assignment kind");
31613
- }
31614
- return checkStrictModeBinaryExpression(node);
31615
- case 295 /* CatchClause */:
31616
- return checkStrictModeCatchClause(node);
31617
- case 217 /* DeleteExpression */:
31618
- return checkStrictModeDeleteExpression(node);
31619
- case 8 /* NumericLiteral */:
31620
- return checkStrictModeNumericLiteral(node);
31621
- case 222 /* PostfixUnaryExpression */:
31622
- return checkStrictModePostfixUnaryExpression(node);
31623
- case 221 /* PrefixUnaryExpression */:
31624
- return checkStrictModePrefixUnaryExpression(node);
31625
- case 251 /* WithStatement */:
31626
- return checkStrictModeWithStatement(node);
31627
- case 253 /* LabeledStatement */:
31628
- return checkStrictModeLabeledStatement(node);
31629
- case 194 /* ThisType */:
31630
- seenThisKeyword = true;
31631
- return;
31632
- case 179 /* TypePredicate */:
31633
- break;
31634
- case 165 /* TypeParameter */:
31635
- return bindTypeParameter(node);
31636
- case 166 /* Parameter */:
31637
- return bindParameter(node);
31638
- case 257 /* VariableDeclaration */:
31639
- return bindVariableDeclarationOrBindingElement(node);
31640
- case 205 /* BindingElement */:
31641
- node.flowNode = currentFlow;
31642
- return bindVariableDeclarationOrBindingElement(node);
31643
- case 169 /* PropertyDeclaration */:
31644
- case 168 /* PropertySignature */:
31645
- return bindPropertyWorker(node);
31646
- case 299 /* PropertyAssignment */:
31647
- case 300 /* ShorthandPropertyAssignment */:
31648
- return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */);
31649
- case 302 /* EnumMember */:
31650
- return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */);
31651
- case 176 /* CallSignature */:
31652
- case 177 /* ConstructSignature */:
31653
- case 178 /* IndexSignature */:
31654
- return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */);
31655
- case 171 /* MethodDeclaration */:
31656
- case 170 /* MethodSignature */:
31657
- return bindPropertyOrMethodOrAccessor(
31658
- node,
31659
- 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */),
31660
- isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */
31661
- );
31662
- case 259 /* FunctionDeclaration */:
31663
- return bindFunctionDeclaration(node);
31664
- case 173 /* Constructor */:
31665
- return declareSymbolAndAddToSymbolTable(
31666
- node,
31667
- 16384 /* Constructor */,
31668
- /*symbolExcludes:*/
31669
- 0 /* None */
31670
- );
31671
- case 174 /* GetAccessor */:
31672
- return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */);
31673
- case 175 /* SetAccessor */:
31674
- return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */);
31675
- case 181 /* FunctionType */:
31676
- case 320 /* JSDocFunctionType */:
31677
- case 326 /* JSDocSignature */:
31678
- case 182 /* ConstructorType */:
31679
- return bindFunctionOrConstructorType(node);
31680
- case 184 /* TypeLiteral */:
31681
- case 325 /* JSDocTypeLiteral */:
31682
- case 197 /* MappedType */:
31683
- return bindAnonymousTypeWorker(node);
31684
- case 335 /* JSDocClassTag */:
31685
- return bindJSDocClassTag(node);
31686
- case 207 /* ObjectLiteralExpression */:
31687
- return bindObjectLiteralExpression(node);
31688
- case 215 /* FunctionExpression */:
31689
- case 216 /* ArrowFunction */:
31690
- return bindFunctionExpression(node);
31691
- case 210 /* CallExpression */:
31692
- const assignmentKind = getAssignmentDeclarationKind(node);
31693
- switch (assignmentKind) {
31694
- case 7 /* ObjectDefinePropertyValue */:
31695
- return bindObjectDefinePropertyAssignment(node);
31696
- case 8 /* ObjectDefinePropertyExports */:
31697
- return bindObjectDefinePropertyExport(node);
31698
- case 9 /* ObjectDefinePrototypeProperty */:
31699
- return bindObjectDefinePrototypeProperty(node);
31700
- case 0 /* None */:
31701
- break;
31702
- default:
31703
- return Debug.fail("Unknown call expression assignment declaration kind");
31704
- }
31705
- if (isInJSFile(node)) {
31706
- bindCallExpression(node);
31707
- }
31708
- break;
31709
- case 228 /* ClassExpression */:
31710
- case 260 /* ClassDeclaration */:
31711
- inStrictMode = true;
31712
- return bindClassLikeDeclaration(node);
31713
- case 261 /* InterfaceDeclaration */:
31714
- return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */);
31715
- case 262 /* TypeAliasDeclaration */:
31716
- return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */);
31717
- case 263 /* EnumDeclaration */:
31718
- return bindEnumDeclaration(node);
31719
- case 264 /* ModuleDeclaration */:
31720
- return bindModuleDeclaration(node);
31721
- case 289 /* JsxAttributes */:
31722
- return bindJsxAttributes(node);
31723
- case 288 /* JsxAttribute */:
31724
- return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */);
31725
- case 268 /* ImportEqualsDeclaration */:
31726
- case 271 /* NamespaceImport */:
31727
- case 273 /* ImportSpecifier */:
31728
- case 278 /* ExportSpecifier */:
31729
- return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
31730
- case 267 /* NamespaceExportDeclaration */:
31731
- return bindNamespaceExportDeclaration(node);
31732
- case 270 /* ImportClause */:
31733
- return bindImportClause(node);
31734
- case 275 /* ExportDeclaration */:
31735
- return bindExportDeclaration(node);
31736
- case 274 /* ExportAssignment */:
31737
- return bindExportAssignment(node);
31738
- case 308 /* SourceFile */:
31739
- updateStrictModeStatementList(node.statements);
31740
- return bindSourceFileIfExternalModule();
31741
- case 238 /* Block */:
31742
- if (!isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) {
31743
- return;
31744
- }
31745
- case 265 /* ModuleBlock */:
31746
- return updateStrictModeStatementList(node.statements);
31747
- case 344 /* JSDocParameterTag */:
31748
- if (node.parent.kind === 326 /* JSDocSignature */) {
31749
- return bindParameter(node);
31750
- }
31751
- if (node.parent.kind !== 325 /* JSDocTypeLiteral */) {
31752
- break;
31753
- }
31754
- case 351 /* JSDocPropertyTag */:
31755
- const propTag = node;
31756
- const flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 319 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */;
31757
- return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */);
31758
- case 349 /* JSDocTypedefTag */:
31759
- case 341 /* JSDocCallbackTag */:
31760
- case 343 /* JSDocEnumTag */:
31761
- return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
31762
- case 342 /* JSDocOverloadTag */:
31763
- return bind(node.typeExpression);
31764
- }
31765
- }
31766
- function bindPropertyWorker(node) {
31767
- const isAutoAccessor = isAutoAccessorPropertyDeclaration(node);
31768
- const includes = isAutoAccessor ? 98304 /* Accessor */ : 4 /* Property */;
31769
- const excludes = isAutoAccessor ? 13247 /* AccessorExcludes */ : 0 /* PropertyExcludes */;
31770
- return bindPropertyOrMethodOrAccessor(node, includes | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), excludes);
31771
- }
31772
- function bindAnonymousTypeWorker(node) {
31773
- return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */);
31774
- }
31775
- function bindSourceFileIfExternalModule() {
31776
- setExportContextFlag(file);
31777
- if (isExternalModule(file)) {
31778
- bindSourceFileAsExternalModule();
31779
- } else if (isJsonSourceFile(file)) {
31780
- bindSourceFileAsExternalModule();
31781
- const originalSymbol = file.symbol;
31782
- declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */);
31783
- file.symbol = originalSymbol;
31784
- }
31785
- }
31786
- function bindSourceFileAsExternalModule() {
31787
- bindAnonymousDeclaration(file, 512 /* ValueModule */, `"${removeFileExtension(file.fileName)}"`);
31788
- }
31789
- function bindExportAssignment(node) {
31790
- if (!container.symbol || !container.symbol.exports) {
31791
- bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node));
31792
- } else {
31793
- const flags = exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */;
31794
- const symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */);
31795
- if (node.isExportEquals) {
31796
- setValueDeclaration(symbol, node);
31797
- }
31798
- }
31799
- }
31800
- function bindNamespaceExportDeclaration(node) {
31801
- if (some(node.modifiers)) {
31802
- file.bindDiagnostics.push(createDiagnosticForNode2(node, Diagnostics.Modifiers_cannot_appear_here));
31803
- }
31804
- const diag2 = !isSourceFile(node.parent) ? Diagnostics.Global_module_exports_may_only_appear_at_top_level : !isExternalModule(node.parent) ? Diagnostics.Global_module_exports_may_only_appear_in_module_files : !node.parent.isDeclarationFile ? Diagnostics.Global_module_exports_may_only_appear_in_declaration_files : void 0;
31805
- if (diag2) {
31806
- file.bindDiagnostics.push(createDiagnosticForNode2(node, diag2));
31807
- } else {
31808
- file.symbol.globalExports = file.symbol.globalExports || createSymbolTable();
31809
- declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
31810
- }
31811
- }
31812
- function bindExportDeclaration(node) {
31813
- if (!container.symbol || !container.symbol.exports) {
31814
- bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node));
31815
- } else if (!node.exportClause) {
31816
- declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */);
31817
- } else if (isNamespaceExport(node.exportClause)) {
31818
- setParent(node.exportClause, node);
31819
- declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
31820
- }
31821
- }
31822
- function bindImportClause(node) {
31823
- if (node.name) {
31824
- declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
31825
- }
31826
- }
31827
- function setCommonJsModuleIndicator(node) {
31828
- if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
31829
- return false;
31830
- }
31831
- if (!file.commonJsModuleIndicator) {
31832
- file.commonJsModuleIndicator = node;
31833
- if (!file.externalModuleIndicator) {
31834
- bindSourceFileAsExternalModule();
31835
- }
31836
- }
31837
- return true;
31838
- }
31839
- function bindObjectDefinePropertyExport(node) {
31840
- if (!setCommonJsModuleIndicator(node)) {
31841
- return;
31842
- }
31843
- const symbol = forEachIdentifierInEntityName(
31844
- node.arguments[0],
31845
- /*parent*/
31846
- void 0,
31847
- (id, symbol2) => {
31848
- if (symbol2) {
31849
- addDeclarationToSymbol(symbol2, id, 1536 /* Module */ | 67108864 /* Assignment */);
31850
- }
31851
- return symbol2;
31852
- }
31853
- );
31854
- if (symbol) {
31855
- const flags = 4 /* Property */ | 1048576 /* ExportValue */;
31856
- declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */);
31857
- }
31858
- }
31859
- function bindExportsPropertyAssignment(node) {
31860
- if (!setCommonJsModuleIndicator(node)) {
31861
- return;
31862
- }
31863
- const symbol = forEachIdentifierInEntityName(
31864
- node.left.expression,
31865
- /*parent*/
31866
- void 0,
31867
- (id, symbol2) => {
31868
- if (symbol2) {
31869
- addDeclarationToSymbol(symbol2, id, 1536 /* Module */ | 67108864 /* Assignment */);
31870
- }
31871
- return symbol2;
31872
- }
31873
- );
31874
- if (symbol) {
31875
- const isAlias = isAliasableExpression(node.right) && (isExportsIdentifier(node.left.expression) || isModuleExportsAccessExpression(node.left.expression));
31876
- const flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */;
31877
- setParent(node.left, node);
31878
- declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */);
31879
- }
31880
- }
31881
- function bindModuleExportsAssignment(node) {
31882
- if (!setCommonJsModuleIndicator(node)) {
31883
- return;
31884
- }
31885
- const assignedExpression = getRightMostAssignedExpression(node.right);
31886
- if (isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) {
31887
- return;
31888
- }
31889
- if (isObjectLiteralExpression(assignedExpression) && every(assignedExpression.properties, isShorthandPropertyAssignment)) {
31890
- forEach(assignedExpression.properties, bindExportAssignedObjectMemberAlias);
31891
- return;
31892
- }
31893
- const flags = exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */;
31894
- const symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */);
31895
- setValueDeclaration(symbol, node);
31896
- }
31897
- function bindExportAssignedObjectMemberAlias(node) {
31898
- declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */);
31899
- }
31900
- function bindThisPropertyAssignment(node) {
31901
- Debug.assert(isInJSFile(node));
31902
- const hasPrivateIdentifier = isBinaryExpression(node) && isPropertyAccessExpression(node.left) && isPrivateIdentifier(node.left.name) || isPropertyAccessExpression(node) && isPrivateIdentifier(node.name);
31903
- if (hasPrivateIdentifier) {
31904
- return;
31905
- }
31906
- const thisContainer = getThisContainer(
31907
- node,
31908
- /*includeArrowFunctions*/
31909
- false,
31910
- /*includeClassComputedPropertyName*/
31911
- false
31912
- );
31913
- switch (thisContainer.kind) {
31914
- case 259 /* FunctionDeclaration */:
31915
- case 215 /* FunctionExpression */:
31916
- let constructorSymbol = thisContainer.symbol;
31917
- if (isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) {
31918
- const l = thisContainer.parent.left;
31919
- if (isBindableStaticAccessExpression(l) && isPrototypeAccess(l.expression)) {
31920
- constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer);
31921
- }
31922
- }
31923
- if (constructorSymbol && constructorSymbol.valueDeclaration) {
31924
- constructorSymbol.members = constructorSymbol.members || createSymbolTable();
31925
- if (hasDynamicName(node)) {
31926
- bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members);
31927
- } else {
31928
- declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */);
31929
- }
31930
- addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */);
31931
- }
31932
- break;
31933
- case 173 /* Constructor */:
31934
- case 169 /* PropertyDeclaration */:
31935
- case 171 /* MethodDeclaration */:
31936
- case 174 /* GetAccessor */:
31937
- case 175 /* SetAccessor */:
31938
- case 172 /* ClassStaticBlockDeclaration */:
31939
- const containingClass = thisContainer.parent;
31940
- const symbolTable = isStatic(thisContainer) ? containingClass.symbol.exports : containingClass.symbol.members;
31941
- if (hasDynamicName(node)) {
31942
- bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable);
31943
- } else {
31944
- declareSymbol(
31945
- symbolTable,
31946
- containingClass.symbol,
31947
- node,
31948
- 4 /* Property */ | 67108864 /* Assignment */,
31949
- 0 /* None */,
31950
- /*isReplaceableByMethod*/
31951
- true
31952
- );
31953
- }
31954
- break;
31955
- case 308 /* SourceFile */:
31956
- if (hasDynamicName(node)) {
31957
- break;
31958
- } else if (thisContainer.commonJsModuleIndicator) {
31959
- declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */);
31960
- } else {
31961
- declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */);
31962
- }
31963
- break;
31964
- default:
31965
- Debug.failBadSyntaxKind(thisContainer);
31966
- }
31967
- }
31968
- function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) {
31969
- declareSymbol(
31970
- symbolTable,
31971
- symbol,
31972
- node,
31973
- 4 /* Property */,
31974
- 0 /* None */,
31975
- /*isReplaceableByMethod*/
31976
- true,
31977
- /*isComputedName*/
31978
- true
31979
- );
31980
- addLateBoundAssignmentDeclarationToSymbol(node, symbol);
31981
- }
31982
- function addLateBoundAssignmentDeclarationToSymbol(node, symbol) {
31983
- if (symbol) {
31984
- (symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = /* @__PURE__ */ new Map())).set(getNodeId(node), node);
31985
- }
31986
- }
31987
- function bindSpecialPropertyDeclaration(node) {
31988
- if (node.expression.kind === 108 /* ThisKeyword */) {
31989
- bindThisPropertyAssignment(node);
31990
- } else if (isBindableStaticAccessExpression(node) && node.parent.parent.kind === 308 /* SourceFile */) {
31991
- if (isPrototypeAccess(node.expression)) {
31992
- bindPrototypePropertyAssignment(node, node.parent);
31993
- } else {
31994
- bindStaticPropertyAssignment(node);
31995
- }
31996
- }
31997
- }
31998
- function bindPrototypeAssignment(node) {
31999
- setParent(node.left, node);
32000
- setParent(node.right, node);
32001
- bindPropertyAssignment(
32002
- node.left.expression,
32003
- node.left,
32004
- /*isPrototypeProperty*/
32005
- false,
32006
- /*containerIsClass*/
32007
- true
32008
- );
32009
- }
32010
- function bindObjectDefinePrototypeProperty(node) {
32011
- const namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
32012
- if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
32013
- addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
32014
- }
32015
- bindPotentiallyNewExpandoMemberToNamespace(
32016
- node,
32017
- namespaceSymbol,
32018
- /*isPrototypeProperty*/
32019
- true
32020
- );
32021
- }
32022
- function bindPrototypePropertyAssignment(lhs, parent2) {
32023
- const classPrototype = lhs.expression;
32024
- const constructorFunction = classPrototype.expression;
32025
- setParent(constructorFunction, classPrototype);
32026
- setParent(classPrototype, lhs);
32027
- setParent(lhs, parent2);
32028
- bindPropertyAssignment(
32029
- constructorFunction,
32030
- lhs,
32031
- /*isPrototypeProperty*/
32032
- true,
32033
- /*containerIsClass*/
32034
- true
32035
- );
32036
- }
32037
- function bindObjectDefinePropertyAssignment(node) {
32038
- let namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]);
32039
- const isToplevel = node.parent.parent.kind === 308 /* SourceFile */;
32040
- namespaceSymbol = bindPotentiallyMissingNamespaces(
32041
- namespaceSymbol,
32042
- node.arguments[0],
32043
- isToplevel,
32044
- /*isPrototypeProperty*/
32045
- false,
32046
- /*containerIsClass*/
32047
- false
32048
- );
32049
- bindPotentiallyNewExpandoMemberToNamespace(
32050
- node,
32051
- namespaceSymbol,
32052
- /*isPrototypeProperty*/
32053
- false
32054
- );
32055
- }
32056
- function bindSpecialPropertyAssignment(node) {
32057
- var _a2;
32058
- const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer);
32059
- if (!isInJSFile(node) && !isFunctionSymbol(parentSymbol)) {
32060
- return;
32061
- }
32062
- const rootExpr = getLeftmostAccessExpression(node.left);
32063
- if (isIdentifier(rootExpr) && ((_a2 = lookupSymbolForName(container, rootExpr.escapedText)) == null ? void 0 : _a2.flags) & 2097152 /* Alias */) {
32064
- return;
32065
- }
32066
- setParent(node.left, node);
32067
- setParent(node.right, node);
32068
- if (isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) {
32069
- bindExportsPropertyAssignment(node);
32070
- } else if (hasDynamicName(node)) {
32071
- bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */);
32072
- const sym = bindPotentiallyMissingNamespaces(
32073
- parentSymbol,
32074
- node.left.expression,
32075
- isTopLevelNamespaceAssignment(node.left),
32076
- /*isPrototype*/
32077
- false,
32078
- /*containerIsClass*/
32079
- false
32080
- );
32081
- addLateBoundAssignmentDeclarationToSymbol(node, sym);
32082
- } else {
32083
- bindStaticPropertyAssignment(cast(node.left, isBindableStaticNameExpression));
32084
- }
32085
- }
32086
- function bindStaticPropertyAssignment(node) {
32087
- Debug.assert(!isIdentifier(node));
32088
- setParent(node.expression, node);
32089
- bindPropertyAssignment(
32090
- node.expression,
32091
- node,
32092
- /*isPrototypeProperty*/
32093
- false,
32094
- /*containerIsClass*/
32095
- false
32096
- );
32097
- }
32098
- function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) {
32099
- if ((namespaceSymbol == null ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) {
32100
- return namespaceSymbol;
32101
- }
32102
- if (isToplevel && !isPrototypeProperty) {
32103
- const flags = 1536 /* Module */ | 67108864 /* Assignment */;
32104
- const excludeFlags = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */;
32105
- namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, (id, symbol, parent2) => {
32106
- if (symbol) {
32107
- addDeclarationToSymbol(symbol, id, flags);
32108
- return symbol;
32109
- } else {
32110
- const table = parent2 ? parent2.exports : file.jsGlobalAugmentations || (file.jsGlobalAugmentations = createSymbolTable());
32111
- return declareSymbol(table, parent2, id, flags, excludeFlags);
32112
- }
32113
- });
32114
- }
32115
- if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
32116
- addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
32117
- }
32118
- return namespaceSymbol;
32119
- }
32120
- function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) {
32121
- if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) {
32122
- return;
32123
- }
32124
- const symbolTable = isPrototypeProperty ? namespaceSymbol.members || (namespaceSymbol.members = createSymbolTable()) : namespaceSymbol.exports || (namespaceSymbol.exports = createSymbolTable());
32125
- let includes = 0 /* None */;
32126
- let excludes = 0 /* None */;
32127
- if (isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration))) {
32128
- includes = 8192 /* Method */;
32129
- excludes = 103359 /* MethodExcludes */;
32130
- } else if (isCallExpression(declaration) && isBindableObjectDefinePropertyCall(declaration)) {
32131
- if (some(declaration.arguments[2].properties, (p) => {
32132
- const id = getNameOfDeclaration(p);
32133
- return !!id && isIdentifier(id) && idText(id) === "set";
32134
- })) {
32135
- includes |= 65536 /* SetAccessor */ | 4 /* Property */;
32136
- excludes |= 78783 /* SetAccessorExcludes */;
32137
- }
32138
- if (some(declaration.arguments[2].properties, (p) => {
32139
- const id = getNameOfDeclaration(p);
32140
- return !!id && isIdentifier(id) && idText(id) === "get";
32141
- })) {
32142
- includes |= 32768 /* GetAccessor */ | 4 /* Property */;
32143
- excludes |= 46015 /* GetAccessorExcludes */;
32144
- }
32145
- }
32146
- if (includes === 0 /* None */) {
32147
- includes = 4 /* Property */;
32148
- excludes = 0 /* PropertyExcludes */;
32149
- }
32150
- declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */);
32151
- }
32152
- function isTopLevelNamespaceAssignment(propertyAccess) {
32153
- return isBinaryExpression(propertyAccess.parent) ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 308 /* SourceFile */ : propertyAccess.parent.parent.kind === 308 /* SourceFile */;
32154
- }
32155
- function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
32156
- let namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer);
32157
- const isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
32158
- namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
32159
- bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
32160
- }
32161
- function isExpandoSymbol(symbol) {
32162
- if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) {
32163
- return true;
32164
- }
32165
- const node = symbol.valueDeclaration;
32166
- if (node && isCallExpression(node)) {
32167
- return !!getAssignedExpandoInitializer(node);
32168
- }
32169
- let init = !node ? void 0 : isVariableDeclaration(node) ? node.initializer : isBinaryExpression(node) ? node.right : isPropertyAccessExpression(node) && isBinaryExpression(node.parent) ? node.parent.right : void 0;
32170
- init = init && getRightMostAssignedExpression(init);
32171
- if (init) {
32172
- const isPrototypeAssignment = isPrototypeAccess(isVariableDeclaration(node) ? node.name : isBinaryExpression(node) ? node.left : node);
32173
- return !!getExpandoInitializer(isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment);
32174
- }
32175
- return false;
32176
- }
32177
- function getParentOfBinaryExpression(expr) {
32178
- while (isBinaryExpression(expr.parent)) {
32179
- expr = expr.parent;
32180
- }
32181
- return expr.parent;
32182
- }
32183
- function lookupSymbolForPropertyAccess(node, lookupContainer = container) {
32184
- if (isIdentifier(node)) {
32185
- return lookupSymbolForName(lookupContainer, node.escapedText);
32186
- } else {
32187
- const symbol = lookupSymbolForPropertyAccess(node.expression);
32188
- return symbol && symbol.exports && symbol.exports.get(getElementOrPropertyAccessName(node));
32189
- }
32190
- }
32191
- function forEachIdentifierInEntityName(e, parent2, action) {
32192
- if (isExportsOrModuleExportsOrAlias(file, e)) {
32193
- return file.symbol;
32194
- } else if (isIdentifier(e)) {
32195
- return action(e, lookupSymbolForPropertyAccess(e), parent2);
32196
- } else {
32197
- const s = forEachIdentifierInEntityName(e.expression, parent2, action);
32198
- const name = getNameOrArgument(e);
32199
- if (isPrivateIdentifier(name)) {
32200
- Debug.fail("unexpected PrivateIdentifier");
32201
- }
32202
- return action(name, s && s.exports && s.exports.get(getElementOrPropertyAccessName(e)), s);
32203
- }
32204
- }
32205
- function bindCallExpression(node) {
32206
- if (!file.commonJsModuleIndicator && isRequireCall(
32207
- node,
32208
- /*checkArgumentIsStringLiteralLike*/
32209
- false
32210
- )) {
32211
- setCommonJsModuleIndicator(node);
32212
- }
32213
- }
32214
- function bindClassLikeDeclaration(node) {
32215
- if (node.kind === 260 /* ClassDeclaration */) {
32216
- bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */);
32217
- } else {
32218
- const bindingName = node.name ? node.name.escapedText : "__class" /* Class */;
32219
- bindAnonymousDeclaration(node, 32 /* Class */, bindingName);
32220
- if (node.name) {
32221
- classifiableNames.add(node.name.escapedText);
32222
- }
32223
- }
32224
- const { symbol } = node;
32225
- const prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype");
32226
- const symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
32227
- if (symbolExport) {
32228
- if (node.name) {
32229
- setParent(node.name, node);
32230
- }
32231
- file.bindDiagnostics.push(createDiagnosticForNode2(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, symbolName(prototypeSymbol)));
32232
- }
32233
- symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
32234
- prototypeSymbol.parent = symbol;
32235
- }
32236
- function bindEnumDeclaration(node) {
32237
- return isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */);
32238
- }
32239
- function bindVariableDeclarationOrBindingElement(node) {
32240
- if (inStrictMode) {
32241
- checkStrictModeEvalOrArguments(node, node.name);
32242
- }
32243
- if (!isBindingPattern(node.name)) {
32244
- const possibleVariableDecl = node.kind === 257 /* VariableDeclaration */ ? node : node.parent.parent;
32245
- if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
32246
- declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
32247
- } else if (isBlockOrCatchScoped(node)) {
32248
- bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
32249
- } else if (isParameterDeclaration(node)) {
32250
- declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */);
32251
- } else {
32252
- declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */);
32253
- }
32254
- }
32255
- }
32256
- function bindParameter(node) {
32257
- if (node.kind === 344 /* JSDocParameterTag */ && container.kind !== 326 /* JSDocSignature */) {
32258
- return;
32259
- }
32260
- if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
32261
- checkStrictModeEvalOrArguments(node, node.name);
32262
- }
32263
- if (isBindingPattern(node.name)) {
32264
- bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node));
32265
- } else {
32266
- declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */);
32267
- }
32268
- if (isParameterPropertyDeclaration(node, node.parent)) {
32269
- const classDeclaration = node.parent.parent;
32270
- declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */);
32271
- }
32272
- }
32273
- function bindFunctionDeclaration(node) {
32274
- if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
32275
- if (isAsyncFunction(node)) {
32276
- emitFlags |= 2048 /* HasAsyncFunctions */;
32277
- }
32278
- }
32279
- checkStrictModeFunctionName(node);
32280
- if (inStrictMode) {
32281
- checkStrictModeFunctionDeclaration(node);
32282
- bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */);
32283
- } else {
32284
- declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */);
32285
- }
32286
- }
32287
- function bindFunctionExpression(node) {
32288
- if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
32289
- if (isAsyncFunction(node)) {
32290
- emitFlags |= 2048 /* HasAsyncFunctions */;
32291
- }
32292
- }
32293
- if (currentFlow) {
32294
- node.flowNode = currentFlow;
32295
- }
32296
- checkStrictModeFunctionName(node);
32297
- const bindingName = node.name ? node.name.escapedText : "__function" /* Function */;
32298
- return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
32299
- }
32300
- function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
32301
- if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && isAsyncFunction(node)) {
32302
- emitFlags |= 2048 /* HasAsyncFunctions */;
32303
- }
32304
- if (currentFlow && isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
32305
- node.flowNode = currentFlow;
32306
- }
32307
- return hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
32308
- }
32309
- function getInferTypeContainer(node) {
32310
- const extendsType = findAncestor(node, (n) => n.parent && isConditionalTypeNode(n.parent) && n.parent.extendsType === n);
32311
- return extendsType && extendsType.parent;
32312
- }
32313
- function bindTypeParameter(node) {
32314
- var _a2, _b;
32315
- if (isJSDocTemplateTag(node.parent)) {
32316
- const container2 = getEffectiveContainerForJSDocTemplateTag(node.parent);
32317
- if (container2) {
32318
- Debug.assertNode(container2, canHaveLocals);
32319
- (_a2 = container2.locals) != null ? _a2 : container2.locals = createSymbolTable();
32320
- declareSymbol(
32321
- container2.locals,
32322
- /*parent*/
32323
- void 0,
32324
- node,
32325
- 262144 /* TypeParameter */,
32326
- 526824 /* TypeParameterExcludes */
32327
- );
32328
- } else {
32329
- declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */);
32330
- }
32331
- } else if (node.parent.kind === 192 /* InferType */) {
32332
- const container2 = getInferTypeContainer(node.parent);
32333
- if (container2) {
32334
- Debug.assertNode(container2, canHaveLocals);
32335
- (_b = container2.locals) != null ? _b : container2.locals = createSymbolTable();
32336
- declareSymbol(
32337
- container2.locals,
32338
- /*parent*/
32339
- void 0,
32340
- node,
32341
- 262144 /* TypeParameter */,
32342
- 526824 /* TypeParameterExcludes */
32343
- );
32344
- } else {
32345
- bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node));
32346
- }
32347
- } else {
32348
- declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */);
32349
- }
32350
- }
32351
- function shouldReportErrorOnModuleDeclaration(node) {
32352
- const instanceState = getModuleInstanceState(node);
32353
- return instanceState === 1 /* Instantiated */ || instanceState === 2 /* ConstEnumOnly */ && shouldPreserveConstEnums(options);
32354
- }
32355
- function checkUnreachable(node) {
32356
- if (!(currentFlow.flags & 1 /* Unreachable */)) {
32357
- return false;
32358
- }
32359
- if (currentFlow === unreachableFlow) {
32360
- const reportError = (
32361
- // report error on all statements except empty ones
32362
- isStatementButNotDeclaration(node) && node.kind !== 239 /* EmptyStatement */ || // report error on class declarations
32363
- node.kind === 260 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
32364
- node.kind === 264 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
32365
- );
32366
- if (reportError) {
32367
- currentFlow = reportedUnreachableFlow;
32368
- if (!options.allowUnreachableCode) {
32369
- const isError = unreachableCodeIsError(options) && !(node.flags & 16777216 /* Ambient */) && (!isVariableStatement(node) || !!(getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some((d) => !!d.initializer));
32370
- eachUnreachableRange(node, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
32371
- }
32372
- }
32373
- }
32374
- return true;
32375
- }
32376
- }
32377
- function eachUnreachableRange(node, cb) {
32378
- if (isStatement(node) && isExecutableStatement(node) && isBlock(node.parent)) {
32379
- const { statements } = node.parent;
32380
- const slice = sliceAfter(statements, node);
32381
- getRangesWhere(slice, isExecutableStatement, (start, afterEnd) => cb(slice[start], slice[afterEnd - 1]));
32382
- } else {
32383
- cb(node, node);
32384
- }
32385
- }
32386
- function isExecutableStatement(s) {
32387
- return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !isEnumDeclaration(s) && // `var x;` may declare a variable used above
32388
- !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some((d) => !d.initializer));
32389
- }
32390
- function isPurelyTypeDeclaration(s) {
32391
- switch (s.kind) {
32392
- case 261 /* InterfaceDeclaration */:
32393
- case 262 /* TypeAliasDeclaration */:
32394
- return true;
32395
- case 264 /* ModuleDeclaration */:
32396
- return getModuleInstanceState(s) !== 1 /* Instantiated */;
32397
- case 263 /* EnumDeclaration */:
32398
- return hasSyntacticModifier(s, 2048 /* Const */);
32399
- default:
32400
- return false;
32401
- }
32402
- }
32403
- function isExportsOrModuleExportsOrAlias(sourceFile, node) {
32404
- let i = 0;
32405
- const q = createQueue();
32406
- q.enqueue(node);
32407
- while (!q.isEmpty() && i < 100) {
32408
- i++;
32409
- node = q.dequeue();
32410
- if (isExportsIdentifier(node) || isModuleExportsAccessExpression(node)) {
32411
- return true;
32412
- } else if (isIdentifier(node)) {
32413
- const symbol = lookupSymbolForName(sourceFile, node.escapedText);
32414
- if (!!symbol && !!symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
32415
- const init = symbol.valueDeclaration.initializer;
32416
- q.enqueue(init);
32417
- if (isAssignmentExpression(
32418
- init,
32419
- /*excludeCompoundAssignment*/
32420
- true
32421
- )) {
32422
- q.enqueue(init.left);
32423
- q.enqueue(init.right);
32424
- }
32425
- }
32426
- }
32427
- }
32428
- return false;
32429
- }
32430
- function getContainerFlags(node) {
32431
- switch (node.kind) {
32432
- case 228 /* ClassExpression */:
32433
- case 260 /* ClassDeclaration */:
32434
- case 263 /* EnumDeclaration */:
32435
- case 207 /* ObjectLiteralExpression */:
32436
- case 184 /* TypeLiteral */:
32437
- case 325 /* JSDocTypeLiteral */:
32438
- case 289 /* JsxAttributes */:
32439
- return 1 /* IsContainer */;
32440
- case 261 /* InterfaceDeclaration */:
32441
- return 1 /* IsContainer */ | 64 /* IsInterface */;
32442
- case 264 /* ModuleDeclaration */:
32443
- case 262 /* TypeAliasDeclaration */:
32444
- case 197 /* MappedType */:
32445
- case 178 /* IndexSignature */:
32446
- return 1 /* IsContainer */ | 32 /* HasLocals */;
32447
- case 308 /* SourceFile */:
32448
- return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
32449
- case 174 /* GetAccessor */:
32450
- case 175 /* SetAccessor */:
32451
- case 171 /* MethodDeclaration */:
32452
- if (isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
32453
- return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */;
32454
- }
32455
- case 173 /* Constructor */:
32456
- case 259 /* FunctionDeclaration */:
32457
- case 170 /* MethodSignature */:
32458
- case 176 /* CallSignature */:
32459
- case 326 /* JSDocSignature */:
32460
- case 320 /* JSDocFunctionType */:
32461
- case 181 /* FunctionType */:
32462
- case 177 /* ConstructSignature */:
32463
- case 182 /* ConstructorType */:
32464
- case 172 /* ClassStaticBlockDeclaration */:
32465
- return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
32466
- case 215 /* FunctionExpression */:
32467
- case 216 /* ArrowFunction */:
32468
- return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */;
32469
- case 265 /* ModuleBlock */:
32470
- return 4 /* IsControlFlowContainer */;
32471
- case 169 /* PropertyDeclaration */:
32472
- return node.initializer ? 4 /* IsControlFlowContainer */ : 0;
32473
- case 295 /* CatchClause */:
32474
- case 245 /* ForStatement */:
32475
- case 246 /* ForInStatement */:
32476
- case 247 /* ForOfStatement */:
32477
- case 266 /* CaseBlock */:
32478
- return 2 /* IsBlockScopedContainer */ | 32 /* HasLocals */;
32479
- case 238 /* Block */:
32480
- return isFunctionLike(node.parent) || isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */ | 32 /* HasLocals */;
32481
- }
32482
- return 0 /* None */;
32483
- }
32484
- function lookupSymbolForName(container, name) {
32485
- var _a2, _b, _c, _d, _e;
32486
- const local = (_b = (_a2 = tryCast(container, canHaveLocals)) == null ? void 0 : _a2.locals) == null ? void 0 : _b.get(name);
32487
- if (local) {
32488
- return (_c = local.exportSymbol) != null ? _c : local;
32489
- }
32490
- if (isSourceFile(container) && container.jsGlobalAugmentations && container.jsGlobalAugmentations.has(name)) {
32491
- return container.jsGlobalAugmentations.get(name);
32492
- }
32493
- if (canHaveSymbol(container)) {
32494
- return (_e = (_d = container.symbol) == null ? void 0 : _d.exports) == null ? void 0 : _e.get(name);
32495
- }
32496
- }
32497
-
32498
28836
  // src/compiler/checker.ts
32499
- var nextSymbolId = 1;
32500
28837
  var nextNodeId = 1;
32501
28838
  var TypeFacts = /* @__PURE__ */ ((TypeFacts3) => {
32502
28839
  TypeFacts3[TypeFacts3["None"] = 0] = "None";
@@ -32622,13 +28959,6 @@ function getNodeId(node) {
32622
28959
  }
32623
28960
  return node.id;
32624
28961
  }
32625
- function getSymbolId(symbol) {
32626
- if (!symbol.id) {
32627
- symbol.id = nextSymbolId;
32628
- nextSymbolId++;
32629
- }
32630
- return symbol.id;
32631
- }
32632
28962
  function isNotAccessor(declaration) {
32633
28963
  return !isAccessor(declaration);
32634
28964
  }