typescript 5.5.0-dev.20240523 → 5.5.0-dev.20240525

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.
Files changed (3) hide show
  1. package/lib/tsc.js +305 -188
  2. package/lib/typescript.js +320 -195
  3. package/package.json +2 -2
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-dev.20240523`;
21
+ var version = `${versionMajorMinor}.0-dev.20240525`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -3561,6 +3561,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3561
3561
  TypeFlags2[TypeFlags2["TemplateLiteral"] = 134217728] = "TemplateLiteral";
3562
3562
  TypeFlags2[TypeFlags2["StringMapping"] = 268435456] = "StringMapping";
3563
3563
  TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1";
3564
+ TypeFlags2[TypeFlags2["Reserved2"] = 1073741824] = "Reserved2";
3564
3565
  TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown";
3565
3566
  TypeFlags2[TypeFlags2["Nullable"] = 98304] = "Nullable";
3566
3567
  TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal";
@@ -3599,6 +3600,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3599
3600
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
3600
3601
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
3601
3602
  TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable";
3603
+ TypeFlags2[TypeFlags2["IncludesError"] = 1073741824 /* Reserved2 */] = "IncludesError";
3602
3604
  TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
3603
3605
  return TypeFlags2;
3604
3606
  })(TypeFlags || {});
@@ -9691,25 +9693,19 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9691
9693
  }
9692
9694
  function reScanSlashToken(reportErrors2) {
9693
9695
  if (token === 44 /* SlashToken */ || token === 69 /* SlashEqualsToken */) {
9694
- let p = tokenStart + 1;
9696
+ const startOfRegExpBody = tokenStart + 1;
9697
+ pos = startOfRegExpBody;
9695
9698
  let inEscape = false;
9696
9699
  let inCharacterClass = false;
9697
9700
  while (true) {
9698
- if (p >= end) {
9699
- tokenFlags |= 4 /* Unterminated */;
9700
- error(Diagnostics.Unterminated_regular_expression_literal);
9701
- break;
9702
- }
9703
- const ch = charCodeUnchecked(p);
9704
- if (isLineBreak(ch)) {
9701
+ const ch = charCodeChecked(pos);
9702
+ if (ch === -1 /* EOF */ || isLineBreak(ch)) {
9705
9703
  tokenFlags |= 4 /* Unterminated */;
9706
- error(Diagnostics.Unterminated_regular_expression_literal);
9707
9704
  break;
9708
9705
  }
9709
9706
  if (inEscape) {
9710
9707
  inEscape = false;
9711
9708
  } else if (ch === 47 /* slash */ && !inCharacterClass) {
9712
- p++;
9713
9709
  break;
9714
9710
  } else if (ch === 91 /* openBracket */) {
9715
9711
  inCharacterClass = true;
@@ -9718,59 +9714,86 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9718
9714
  } else if (ch === 93 /* closeBracket */) {
9719
9715
  inCharacterClass = false;
9720
9716
  }
9721
- p++;
9717
+ pos++;
9722
9718
  }
9723
- const isUnterminated = !!(tokenFlags & 4 /* Unterminated */);
9724
- const endOfBody = p - (isUnterminated ? 0 : 1);
9725
- let regExpFlags = 0 /* None */;
9726
- while (p < end) {
9727
- const ch = charCodeUnchecked(p);
9728
- if (!isIdentifierPart(ch, languageVersion)) {
9729
- break;
9719
+ const endOfRegExpBody = pos;
9720
+ if (tokenFlags & 4 /* Unterminated */) {
9721
+ pos = startOfRegExpBody;
9722
+ inEscape = false;
9723
+ let characterClassDepth = 0;
9724
+ let inDecimalQuantifier = false;
9725
+ let groupDepth = 0;
9726
+ while (pos < endOfRegExpBody) {
9727
+ const ch = charCodeUnchecked(pos);
9728
+ if (inEscape) {
9729
+ inEscape = false;
9730
+ } else if (ch === 92 /* backslash */) {
9731
+ inEscape = true;
9732
+ } else if (ch === 91 /* openBracket */) {
9733
+ characterClassDepth++;
9734
+ } else if (ch === 93 /* closeBracket */ && characterClassDepth) {
9735
+ characterClassDepth--;
9736
+ } else if (!characterClassDepth) {
9737
+ if (ch === 123 /* openBrace */) {
9738
+ inDecimalQuantifier = true;
9739
+ } else if (ch === 125 /* closeBrace */ && inDecimalQuantifier) {
9740
+ inDecimalQuantifier = false;
9741
+ } else if (!inDecimalQuantifier) {
9742
+ if (ch === 40 /* openParen */) {
9743
+ groupDepth++;
9744
+ } else if (ch === 41 /* closeParen */ && groupDepth) {
9745
+ groupDepth--;
9746
+ } else if (ch === 41 /* closeParen */ || ch === 93 /* closeBracket */ || ch === 125 /* closeBrace */) {
9747
+ break;
9748
+ }
9749
+ }
9750
+ }
9751
+ pos++;
9730
9752
  }
9731
- if (reportErrors2) {
9732
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
9733
- if (flag === void 0) {
9734
- error(Diagnostics.Unknown_regular_expression_flag, p, 1);
9735
- } else if (regExpFlags & flag) {
9736
- error(Diagnostics.Duplicate_regular_expression_flag, p, 1);
9737
- } else if (((regExpFlags | flag) & 96 /* UnicodeMode */) === 96 /* UnicodeMode */) {
9738
- error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
9739
- } else {
9740
- regExpFlags |= flag;
9741
- checkRegularExpressionFlagAvailable(flag, p);
9753
+ while (isWhiteSpaceLike(charCodeChecked(pos - 1)) || charCodeChecked(pos - 1) === 59 /* semicolon */) pos--;
9754
+ error(Diagnostics.Unterminated_regular_expression_literal, tokenStart, pos - tokenStart);
9755
+ } else {
9756
+ pos++;
9757
+ let regExpFlags = 0 /* None */;
9758
+ while (true) {
9759
+ const ch = codePointChecked(pos);
9760
+ if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
9761
+ break;
9762
+ }
9763
+ if (reportErrors2) {
9764
+ const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
9765
+ if (flag === void 0) {
9766
+ error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
9767
+ } else if (regExpFlags & flag) {
9768
+ error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
9769
+ } else if (((regExpFlags | flag) & 96 /* AnyUnicodeMode */) === 96 /* AnyUnicodeMode */) {
9770
+ error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, pos, 1);
9771
+ } else {
9772
+ regExpFlags |= flag;
9773
+ checkRegularExpressionFlagAvailable(flag, pos);
9774
+ }
9742
9775
  }
9776
+ pos++;
9777
+ }
9778
+ if (reportErrors2) {
9779
+ scanRange(startOfRegExpBody, endOfRegExpBody - startOfRegExpBody, () => {
9780
+ scanRegularExpressionWorker(
9781
+ regExpFlags,
9782
+ /*annexB*/
9783
+ true
9784
+ );
9785
+ });
9743
9786
  }
9744
- p++;
9745
- }
9746
- pos = p;
9747
- if (reportErrors2) {
9748
- const saveTokenStart = tokenStart;
9749
- const saveTokenFlags = tokenFlags;
9750
- const savePos = pos;
9751
- const saveEnd = end;
9752
- pos = tokenStart + 1;
9753
- end = endOfBody;
9754
- scanRegularExpressionWorker(
9755
- regExpFlags,
9756
- isUnterminated,
9757
- /*annexB*/
9758
- true
9759
- );
9760
- tokenStart = saveTokenStart;
9761
- tokenFlags = saveTokenFlags;
9762
- pos = savePos;
9763
- end = saveEnd;
9764
9787
  }
9765
9788
  tokenValue = text.substring(tokenStart, pos);
9766
9789
  token = 14 /* RegularExpressionLiteral */;
9767
9790
  }
9768
9791
  return token;
9769
9792
  }
9770
- function scanRegularExpressionWorker(regExpFlags, isUnterminated, annexB) {
9793
+ function scanRegularExpressionWorker(regExpFlags, annexB) {
9771
9794
  var unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
9772
- var unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
9773
- if (unicodeMode) {
9795
+ var anyUnicodeMode = !!(regExpFlags & 96 /* AnyUnicodeMode */);
9796
+ if (anyUnicodeMode) {
9774
9797
  annexB = false;
9775
9798
  }
9776
9799
  var mayContainStrings = false;
@@ -9889,7 +9912,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9889
9912
  if (max || charCodeChecked(pos) === 125 /* closeBrace */) {
9890
9913
  error(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
9891
9914
  } else {
9892
- if (unicodeMode) {
9915
+ if (anyUnicodeMode) {
9893
9916
  error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
9894
9917
  }
9895
9918
  isPreviousTermQuantifiable = true;
@@ -9900,7 +9923,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9900
9923
  error(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
9901
9924
  }
9902
9925
  } else if (!min2) {
9903
- if (unicodeMode) {
9926
+ if (anyUnicodeMode) {
9904
9927
  error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
9905
9928
  }
9906
9929
  isPreviousTermQuantifiable = true;
@@ -9940,10 +9963,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9940
9963
  }
9941
9964
  case 93 /* closeBracket */:
9942
9965
  case 125 /* closeBrace */:
9943
- if (isUnterminated && !isInGroup) {
9944
- return;
9945
- }
9946
- if (unicodeMode || ch === 41 /* closeParen */) {
9966
+ if (anyUnicodeMode || ch === 41 /* closeParen */) {
9947
9967
  error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
9948
9968
  }
9949
9969
  pos++;
@@ -9992,7 +10012,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9992
10012
  true
9993
10013
  );
9994
10014
  scanExpectedChar(62 /* greaterThan */);
9995
- } else if (unicodeMode) {
10015
+ } else if (anyUnicodeMode) {
9996
10016
  error(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
9997
10017
  }
9998
10018
  break;
@@ -10025,6 +10045,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10025
10045
  Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
10026
10046
  let ch = charCodeChecked(pos);
10027
10047
  switch (ch) {
10048
+ case -1 /* EOF */:
10049
+ error(Diagnostics.Undetermined_character_escape, pos - 1, 1);
10050
+ return "\\";
10028
10051
  case 99 /* c */:
10029
10052
  pos++;
10030
10053
  ch = charCodeChecked(pos);
@@ -10032,7 +10055,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10032
10055
  pos++;
10033
10056
  return String.fromCharCode(ch & 31);
10034
10057
  }
10035
- if (unicodeMode) {
10058
+ if (anyUnicodeMode) {
10036
10059
  error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
10037
10060
  } else if (atomEscape && annexB) {
10038
10061
  pos--;
@@ -10057,14 +10080,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10057
10080
  pos++;
10058
10081
  return String.fromCharCode(ch);
10059
10082
  default:
10060
- if (pos >= end) {
10061
- error(Diagnostics.Undetermined_character_escape, pos - 1, 1);
10062
- return "\\";
10063
- }
10064
10083
  pos--;
10065
10084
  return scanEscapeSequence(
10066
10085
  /*shouldEmitInvalidEscapeError*/
10067
- unicodeMode,
10086
+ anyUnicodeMode,
10068
10087
  /*isRegularExpression*/
10069
10088
  annexB ? "annex-b" : true
10070
10089
  );
@@ -10540,10 +10559,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10540
10559
  }
10541
10560
  }
10542
10561
  scanExpectedChar(125 /* closeBrace */);
10543
- if (!unicodeMode) {
10562
+ if (!anyUnicodeMode) {
10544
10563
  error(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
10545
10564
  }
10546
- } else if (unicodeMode) {
10565
+ } else if (anyUnicodeMode) {
10547
10566
  error(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
10548
10567
  }
10549
10568
  return true;
@@ -10563,7 +10582,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10563
10582
  return value;
10564
10583
  }
10565
10584
  function scanSourceCharacter() {
10566
- const size = unicodeMode ? charSize(charCodeChecked(pos)) : 1;
10585
+ const size = anyUnicodeMode ? charSize(charCodeChecked(pos)) : 1;
10567
10586
  pos += size;
10568
10587
  return size > 0 ? text.substring(pos - size, pos) : "";
10569
10588
  }
@@ -28413,10 +28432,7 @@ var Parser;
28413
28432
  function parseErrorAtPosition(start, length2, message, ...args) {
28414
28433
  const lastError = lastOrUndefined(parseDiagnostics);
28415
28434
  let result;
28416
- if (message.category === 3 /* Message */ && lastError && start === lastError.start && length2 === lastError.length) {
28417
- result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
28418
- addRelatedInfo(lastError, result);
28419
- } else if (!lastError || start !== lastError.start) {
28435
+ if (!lastError || start !== lastError.start) {
28420
28436
  result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
28421
28437
  parseDiagnostics.push(result);
28422
28438
  }
@@ -46240,7 +46256,12 @@ function createTypeChecker(host) {
46240
46256
  if (resolvedTarget === unknownSymbol) {
46241
46257
  return source;
46242
46258
  }
46243
- target = cloneSymbol(resolvedTarget);
46259
+ if (!(resolvedTarget.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | resolvedTarget.flags) & 67108864 /* Assignment */) {
46260
+ target = cloneSymbol(resolvedTarget);
46261
+ } else {
46262
+ reportMergeSymbolError(target, source);
46263
+ return source;
46264
+ }
46244
46265
  }
46245
46266
  if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
46246
46267
  target.constEnumOnlyModule = false;
@@ -46270,27 +46291,30 @@ function createTypeChecker(host) {
46270
46291
  );
46271
46292
  }
46272
46293
  } else {
46273
- const isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
46274
- const isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
46294
+ reportMergeSymbolError(target, source);
46295
+ }
46296
+ return target;
46297
+ function reportMergeSymbolError(target2, source2) {
46298
+ const isEitherEnum = !!(target2.flags & 384 /* Enum */ || source2.flags & 384 /* Enum */);
46299
+ const isEitherBlockScoped = !!(target2.flags & 2 /* BlockScopedVariable */ || source2.flags & 2 /* BlockScopedVariable */);
46275
46300
  const message = isEitherEnum ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;
46276
- const sourceSymbolFile = source.declarations && getSourceFileOfNode(source.declarations[0]);
46277
- const targetSymbolFile = target.declarations && getSourceFileOfNode(target.declarations[0]);
46301
+ const sourceSymbolFile = source2.declarations && getSourceFileOfNode(source2.declarations[0]);
46302
+ const targetSymbolFile = target2.declarations && getSourceFileOfNode(target2.declarations[0]);
46278
46303
  const isSourcePlainJs = isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
46279
46304
  const isTargetPlainJs = isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
46280
- const symbolName2 = symbolToString(source);
46305
+ const symbolName2 = symbolToString(source2);
46281
46306
  if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
46282
46307
  const firstFile = comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile;
46283
46308
  const secondFile = firstFile === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
46284
46309
  const filesDuplicates = getOrUpdate(amalgamatedDuplicates, `${firstFile.path}|${secondFile.path}`, () => ({ firstFile, secondFile, conflictingSymbols: /* @__PURE__ */ new Map() }));
46285
46310
  const conflictingSymbolInfo = getOrUpdate(filesDuplicates.conflictingSymbols, symbolName2, () => ({ isBlockScoped: isEitherBlockScoped, firstFileLocations: [], secondFileLocations: [] }));
46286
- if (!isSourcePlainJs) addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
46287
- if (!isTargetPlainJs) addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
46311
+ if (!isSourcePlainJs) addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source2);
46312
+ if (!isTargetPlainJs) addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target2);
46288
46313
  } else {
46289
- if (!isSourcePlainJs) addDuplicateDeclarationErrorsForSymbols(source, message, symbolName2, target);
46290
- if (!isTargetPlainJs) addDuplicateDeclarationErrorsForSymbols(target, message, symbolName2, source);
46314
+ if (!isSourcePlainJs) addDuplicateDeclarationErrorsForSymbols(source2, message, symbolName2, target2);
46315
+ if (!isTargetPlainJs) addDuplicateDeclarationErrorsForSymbols(target2, message, symbolName2, source2);
46291
46316
  }
46292
46317
  }
46293
- return target;
46294
46318
  function addDuplicateLocations(locs, symbol) {
46295
46319
  if (symbol.declarations) {
46296
46320
  for (const decl of symbol.declarations) {
@@ -49136,6 +49160,9 @@ function createTypeChecker(host) {
49136
49160
  function isClassInstanceSide(type) {
49137
49161
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(type.flags & 524288 /* Object */) && !!(getObjectFlags(type) & 16777216 /* IsClassInstanceClone */));
49138
49162
  }
49163
+ function getTypeFromTypeNodeWithoutContext(node) {
49164
+ return getTypeFromTypeNode(node);
49165
+ }
49139
49166
  function createNodeBuilder() {
49140
49167
  return {
49141
49168
  typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
@@ -49164,6 +49191,12 @@ function createTypeChecker(host) {
49164
49191
  symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
49165
49192
  symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
49166
49193
  };
49194
+ function getTypeFromTypeNode2(context, node, noMappedTypes) {
49195
+ const type = getTypeFromTypeNodeWithoutContext(node);
49196
+ if (!context.mapper) return type;
49197
+ const mappedType = instantiateType(type, context.mapper);
49198
+ return noMappedTypes && mappedType !== type ? void 0 : mappedType;
49199
+ }
49167
49200
  function setTextRange2(context, range, location) {
49168
49201
  if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
49169
49202
  range = factory.cloneNode(range);
@@ -49209,7 +49242,7 @@ function createTypeChecker(host) {
49209
49242
  }
49210
49243
  const clone = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
49211
49244
  if (clone) {
49212
- if (addUndefined && !someType(getTypeFromTypeNode(typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
49245
+ if (addUndefined && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
49213
49246
  return factory.createUnionTypeNode([clone, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
49214
49247
  }
49215
49248
  return clone;
@@ -49222,14 +49255,18 @@ function createTypeChecker(host) {
49222
49255
  }
49223
49256
  return void 0;
49224
49257
  }
49225
- function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, annotationType) {
49226
- if (typeNodeIsEquivalentToType(existing, host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
49258
+ function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, annotationType = getTypeFromTypeNode2(
49259
+ context,
49260
+ existing,
49261
+ /*noMappedTypes*/
49262
+ true
49263
+ )) {
49264
+ if (annotationType && typeNodeIsEquivalentToType(host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
49227
49265
  const result = tryReuseExistingTypeNodeHelper(context, existing);
49228
49266
  if (result) {
49229
49267
  return result;
49230
49268
  }
49231
49269
  }
49232
- context.tracker.reportInferenceFallback(existing);
49233
49270
  return void 0;
49234
49271
  }
49235
49272
  function symbolToNode(symbol, context, meaning) {
@@ -49271,7 +49308,8 @@ function createTypeChecker(host) {
49271
49308
  mustCreateTypeParametersNamesLookups: true,
49272
49309
  typeParameterNames: void 0,
49273
49310
  typeParameterNamesByText: void 0,
49274
- typeParameterNamesByTextNextNameCount: void 0
49311
+ typeParameterNamesByTextNextNameCount: void 0,
49312
+ mapper: void 0
49275
49313
  };
49276
49314
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
49277
49315
  const resultingNode = cb(context);
@@ -49562,8 +49600,8 @@ function createTypeChecker(host) {
49562
49600
  context.inferTypeParameters = type2.root.inferTypeParameters;
49563
49601
  const extendsTypeNode2 = typeToTypeNodeHelper(instantiateType(type2.root.extendsType, newMapper), context);
49564
49602
  context.inferTypeParameters = saveInferTypeParameters2;
49565
- const trueTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type2.root.node.trueType), newMapper));
49566
- const falseTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type2.root.node.falseType), newMapper));
49603
+ const trueTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode2(context, type2.root.node.trueType), newMapper));
49604
+ const falseTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode2(context, type2.root.node.falseType), newMapper));
49567
49605
  return factory.createConditionalTypeNode(
49568
49606
  checkTypeNode,
49569
49607
  factory.createInferTypeNode(factory.createTypeParameterDeclaration(
@@ -49646,7 +49684,7 @@ function createTypeChecker(host) {
49646
49684
  context.approximateLength += 10;
49647
49685
  const result = setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
49648
49686
  if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type2) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
49649
- const originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type2.declaration.typeParameter.constraint.type)) || unknownType, type2.mapper);
49687
+ const originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode2(context, type2.declaration.typeParameter.constraint.type)) || unknownType, type2.mapper);
49650
49688
  return factory.createConditionalTypeNode(
49651
49689
  typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context),
49652
49690
  factory.createInferTypeNode(factory.createTypeParameterDeclaration(
@@ -50273,7 +50311,7 @@ function createTypeChecker(host) {
50273
50311
  /*skipUnionExpanding*/
50274
50312
  true
50275
50313
  )[0];
50276
- const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters, signature.parameters);
50314
+ const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters, signature.parameters, signature.mapper);
50277
50315
  context.approximateLength += 3;
50278
50316
  if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) {
50279
50317
  typeArguments = signature.target.typeParameters.map((parameter) => typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context));
@@ -50381,11 +50419,15 @@ function createTypeChecker(host) {
50381
50419
  function getParametersInScope(node) {
50382
50420
  return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).parameters : void 0;
50383
50421
  }
50384
- function enterNewScope(context, declaration, expandedParams, typeParameters, originalParameters) {
50422
+ function enterNewScope(context, declaration, expandedParams, typeParameters, originalParameters, mapper) {
50385
50423
  const cleanupContext = cloneNodeBuilderContext(context);
50386
50424
  let cleanupParams;
50387
50425
  let cleanupTypeParams;
50388
50426
  const oldEnclosingDecl = context.enclosingDeclaration;
50427
+ const oldMapper = context.mapper;
50428
+ if (mapper) {
50429
+ context.mapper = mapper;
50430
+ }
50389
50431
  if (context.enclosingDeclaration && declaration) {
50390
50432
  let pushFakeScope2 = function(kind, addAll) {
50391
50433
  Debug.assert(context.enclosingDeclaration);
@@ -50484,6 +50526,7 @@ function createTypeChecker(host) {
50484
50526
  cleanupTypeParams == null ? void 0 : cleanupTypeParams();
50485
50527
  cleanupContext();
50486
50528
  context.enclosingDeclaration = oldEnclosingDecl;
50529
+ context.mapper = oldMapper;
50487
50530
  };
50488
50531
  }
50489
50532
  function tryGetThisParameterDeclaration(signature, context) {
@@ -50501,7 +50544,7 @@ function createTypeChecker(host) {
50501
50544
  "this",
50502
50545
  /*questionToken*/
50503
50546
  void 0,
50504
- typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context)
50547
+ typeToTypeNodeHelper(getTypeFromTypeNode2(context, thisTag.typeExpression), context)
50505
50548
  );
50506
50549
  }
50507
50550
  }
@@ -51139,31 +51182,32 @@ function createTypeChecker(host) {
51139
51182
  var _a;
51140
51183
  const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
51141
51184
  const enclosingDeclaration = context.enclosingDeclaration;
51185
+ const oldFlags = context.flags;
51186
+ if (declaration && hasInferredType(declaration) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
51187
+ syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, context);
51188
+ }
51189
+ context.flags |= -2147483648 /* NoSyntacticPrinter */;
51142
51190
  if (enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */)) {
51143
- const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
51191
+ const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol);
51144
51192
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
51145
51193
  const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
51146
- const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
51194
+ const result2 = !isTypePredicateNode(existing) && tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
51147
51195
  if (result2) {
51196
+ context.flags = oldFlags;
51148
51197
  return result2;
51149
51198
  }
51150
51199
  }
51151
51200
  }
51152
- const oldFlags = context.flags;
51153
51201
  if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
51154
51202
  context.flags |= 1048576 /* AllowUniqueESSymbolType */;
51155
51203
  }
51156
51204
  const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
51157
51205
  const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
51158
- if (decl && hasInferredType(decl) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
51159
- syntacticNodeBuilder.serializeTypeOfDeclaration(decl, context);
51160
- }
51161
- context.flags |= -2147483648 /* NoSyntacticPrinter */;
51162
51206
  const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
51163
51207
  context.flags = oldFlags;
51164
51208
  return result;
51165
51209
  }
51166
- function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type, typeFromTypeNode = getTypeFromTypeNode(typeNode)) {
51210
+ function typeNodeIsEquivalentToType(annotatedDeclaration, type, typeFromTypeNode) {
51167
51211
  if (typeFromTypeNode === type) {
51168
51212
  return true;
51169
51213
  }
@@ -51193,13 +51237,10 @@ function createTypeChecker(host) {
51193
51237
  function serializeReturnTypeForSignatureWorker(context, signature) {
51194
51238
  const typePredicate = getTypePredicateOfSignature(signature);
51195
51239
  const type = getReturnTypeOfSignature(signature);
51196
- if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */)) {
51240
+ if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */) && signature.declaration && !nodeIsSynthesized(signature.declaration)) {
51197
51241
  const annotation = signature.declaration && getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
51198
- const enclosingDeclarationIgnoringFakeScope = getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
51199
- if (!!findAncestor(annotation, (n) => n === enclosingDeclarationIgnoringFakeScope) && annotation) {
51200
- const annotated = getTypeFromTypeNode(annotation);
51201
- const thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
51202
- const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration, thisInstantiated);
51242
+ if (annotation && getTypeFromTypeNode2(context, annotation) === type) {
51243
+ const result = tryReuseExistingTypeNodeHelper(context, annotation);
51203
51244
  if (result) {
51204
51245
  return result;
51205
51246
  }
@@ -51342,13 +51383,26 @@ function createTypeChecker(host) {
51342
51383
  !(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
51343
51384
  }
51344
51385
  }
51386
+ if (isThisTypeNode(existing)) {
51387
+ if (context.mapper === void 0) return true;
51388
+ const type = getTypeFromTypeNode2(
51389
+ context,
51390
+ existing,
51391
+ /*noMappedTypes*/
51392
+ true
51393
+ );
51394
+ return !!type;
51395
+ }
51345
51396
  if (isTypeReferenceNode(existing)) {
51346
51397
  if (isConstTypeReference(existing)) return false;
51347
51398
  const type = getTypeFromTypeReference(existing);
51348
51399
  const symbol = getNodeLinks(existing).resolvedSymbol;
51349
51400
  if (!symbol) return false;
51350
51401
  if (symbol.flags & 262144 /* TypeParameter */) {
51351
- return true;
51402
+ const type2 = getDeclaredTypeOfSymbol(symbol);
51403
+ if (context.mapper && getMappedType(type2, context.mapper) !== type2) {
51404
+ return false;
51405
+ }
51352
51406
  }
51353
51407
  if (isInJSDoc(existing)) {
51354
51408
  return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
@@ -51361,7 +51415,7 @@ function createTypeChecker(host) {
51361
51415
  return true;
51362
51416
  }
51363
51417
  function serializeExistingTypeNode(context, typeNode) {
51364
- const type = getTypeFromTypeNode(typeNode);
51418
+ const type = getTypeFromTypeNode2(context, typeNode);
51365
51419
  return typeToTypeNodeHelper(type, context);
51366
51420
  }
51367
51421
  function tryReuseExistingTypeNodeHelper(context, existing) {
@@ -51409,8 +51463,8 @@ function createTypeChecker(host) {
51409
51463
  if (isJSDocTypeLiteral(node)) {
51410
51464
  return factory.createTypeLiteralNode(map(node.jsDocPropertyTags, (t) => {
51411
51465
  const name = isIdentifier(t.name) ? t.name : t.name.right;
51412
- const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
51413
- const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
51466
+ const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode2(context, node), name.escapedText);
51467
+ const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode2(context, t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
51414
51468
  return factory.createPropertySignature(
51415
51469
  /*modifiers*/
51416
51470
  void 0,
@@ -51451,7 +51505,7 @@ function createTypeChecker(host) {
51451
51505
  /*modifiers*/
51452
51506
  void 0,
51453
51507
  getEffectiveDotDotDotForParameter(p),
51454
- getNameForJSDocFunctionParameter(p, i),
51508
+ setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
51455
51509
  p.questionToken,
51456
51510
  visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
51457
51511
  /*initializer*/
@@ -51466,7 +51520,7 @@ function createTypeChecker(host) {
51466
51520
  /*modifiers*/
51467
51521
  void 0,
51468
51522
  getEffectiveDotDotDotForParameter(p),
51469
- getNameForJSDocFunctionParameter(p, i),
51523
+ setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
51470
51524
  p.questionToken,
51471
51525
  visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
51472
51526
  /*initializer*/
@@ -51476,6 +51530,21 @@ function createTypeChecker(host) {
51476
51530
  );
51477
51531
  }
51478
51532
  }
51533
+ if (isThisTypeNode(node)) {
51534
+ if (canReuseTypeNode(context, node)) {
51535
+ return node;
51536
+ }
51537
+ return serializeExistingTypeNode(context, node);
51538
+ }
51539
+ if (isTypeParameterDeclaration(node)) {
51540
+ return factory.updateTypeParameterDeclaration(
51541
+ node,
51542
+ node.modifiers,
51543
+ setTextRange2(context, typeParameterToName(getDeclaredTypeOfSymbol(getSymbolOfDeclaration(node)), context), node),
51544
+ visitNode(node.constraint, visitExistingNodeTreeSymbols, isTypeNode),
51545
+ visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
51546
+ );
51547
+ }
51479
51548
  if (isTypeReferenceNode(node)) {
51480
51549
  if (canReuseTypeNode(context, node)) {
51481
51550
  const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
@@ -51507,7 +51576,7 @@ function createTypeChecker(host) {
51507
51576
  if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
51508
51577
  (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
51509
51578
  !(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
51510
- return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
51579
+ return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode2(context, node), context), node);
51511
51580
  }
51512
51581
  return factory.updateImportTypeNode(
51513
51582
  node,
@@ -51577,10 +51646,16 @@ function createTypeChecker(host) {
51577
51646
  return factory.updateComputedPropertyName(node, literal);
51578
51647
  }
51579
51648
  }
51580
- if (isTypePredicateNode(node) && isIdentifier(node.parameterName)) {
51581
- const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
51582
- hadError = hadError || introducesError;
51583
- return factory.updateTypePredicateNode(node, node.assertsModifier, result, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
51649
+ if (isTypePredicateNode(node)) {
51650
+ let parameterName;
51651
+ if (isIdentifier(node.parameterName)) {
51652
+ const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
51653
+ hadError = hadError || introducesError;
51654
+ parameterName = result;
51655
+ } else {
51656
+ parameterName = node.parameterName;
51657
+ }
51658
+ return factory.updateTypePredicateNode(node, node.assertsModifier, parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
51584
51659
  }
51585
51660
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
51586
51661
  const visited = visitEachChild(
@@ -52356,7 +52431,7 @@ function createTypeChecker(host) {
52356
52431
  }
52357
52432
  return cleanup(factory.createExpressionWithTypeArguments(
52358
52433
  expr,
52359
- map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(context, a, getTypeFromTypeNode(a)) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
52434
+ map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(context, a, getTypeFromTypeNode2(context, a)) || typeToTypeNodeHelper(getTypeFromTypeNode2(context, a), context))
52360
52435
  ));
52361
52436
  function cleanup(result2) {
52362
52437
  context.enclosingDeclaration = oldEnclosing;
@@ -58900,6 +58975,7 @@ function createTypeChecker(host) {
58900
58975
  if (flags & 465829888 /* Instantiable */) includes |= 33554432 /* IncludesInstantiable */;
58901
58976
  if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) includes |= 536870912 /* IncludesConstrainedTypeVariable */;
58902
58977
  if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
58978
+ if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
58903
58979
  if (!strictNullChecks && flags & 98304 /* Nullable */) {
58904
58980
  if (!(getObjectFlags(type) & 65536 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */;
58905
58981
  } else {
@@ -59091,7 +59167,7 @@ function createTypeChecker(host) {
59091
59167
  const includes = addTypesToUnion(typeSet, 0, types);
59092
59168
  if (unionReduction !== 0 /* None */) {
59093
59169
  if (includes & 3 /* AnyOrUnknown */) {
59094
- return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType;
59170
+ return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType : unknownType;
59095
59171
  }
59096
59172
  if (includes & 32768 /* Undefined */) {
59097
59173
  if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
@@ -59217,6 +59293,7 @@ function createTypeChecker(host) {
59217
59293
  } else {
59218
59294
  if (flags & 3 /* AnyOrUnknown */) {
59219
59295
  if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
59296
+ if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
59220
59297
  } else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
59221
59298
  if (type === missingType) {
59222
59299
  includes |= 262144 /* IncludesMissingType */;
@@ -59344,7 +59421,7 @@ function createTypeChecker(host) {
59344
59421
  return neverType;
59345
59422
  }
59346
59423
  if (includes & 1 /* Any */) {
59347
- return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType;
59424
+ return includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType;
59348
59425
  }
59349
59426
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
59350
59427
  return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes & 32768 /* Undefined */ ? undefinedType : nullType;
@@ -84847,6 +84924,7 @@ function createTypeChecker(host) {
84847
84924
  function getSingleReturnExpression(declaration) {
84848
84925
  let candidateExpr;
84849
84926
  if (declaration && !nodeIsMissing(declaration.body)) {
84927
+ if (getFunctionFlags(declaration) & 3 /* AsyncGenerator */) return void 0;
84850
84928
  const body = declaration.body;
84851
84929
  if (body && isBlock(body)) {
84852
84930
  forEachReturnStatement(body, (s) => {
@@ -92248,10 +92326,9 @@ function transformClassFields(context) {
92248
92326
  }
92249
92327
  }
92250
92328
  }
92251
- function getClassThis() {
92329
+ function tryGetClassThis() {
92252
92330
  const lex = getClassLexicalEnvironment();
92253
- const classThis = lex.classThis ?? lex.classConstructor ?? (currentClassContainer == null ? void 0 : currentClassContainer.name);
92254
- return Debug.checkDefined(classThis);
92331
+ return lex.classThis ?? lex.classConstructor ?? (currentClassContainer == null ? void 0 : currentClassContainer.name);
92255
92332
  }
92256
92333
  function transformAutoAccessor(node) {
92257
92334
  const commentRange = getCommentRange(node);
@@ -92279,7 +92356,7 @@ function transformClassFields(context) {
92279
92356
  setOriginalNode(backingField, node);
92280
92357
  setEmitFlags(backingField, 3072 /* NoComments */);
92281
92358
  setSourceMapRange(backingField, sourceMapRange);
92282
- const receiver = isStatic(node) ? getClassThis() : factory2.createThis();
92359
+ const receiver = isStatic(node) ? tryGetClassThis() ?? factory2.createThis() : factory2.createThis();
92283
92360
  const getter = createAccessorPropertyGetRedirector(factory2, node, modifiers, getterName, receiver);
92284
92361
  setOriginalNode(getter, node);
92285
92362
  setCommentRange(getter, commentRange);
@@ -92845,7 +92922,7 @@ function transformClassFields(context) {
92845
92922
  var _a;
92846
92923
  let facts = 0 /* None */;
92847
92924
  const original = getOriginalNode(node);
92848
- if (isClassDeclaration(original) && classOrConstructorParameterIsDecorated(legacyDecorators, original)) {
92925
+ if (isClassLike(original) && classOrConstructorParameterIsDecorated(legacyDecorators, original)) {
92849
92926
  facts |= 1 /* ClassWasDecorated */;
92850
92927
  }
92851
92928
  if (shouldTransformPrivateElementsOrClassStaticBlocks && (classHasClassThisAssignment(node) || classHasExplicitlyAssignedName(node))) {
@@ -110890,13 +110967,18 @@ function transformDeclarations(context) {
110890
110967
  if (isDeclaration(input)) {
110891
110968
  if (isDeclarationAndNotVisible(input)) return;
110892
110969
  if (hasDynamicName(input)) {
110893
- if (isolatedDeclarations && (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent))) {
110894
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
110895
- }
110896
- if (isolatedDeclarations && (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)) {
110897
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
110898
- }
110899
- if (!isEntityNameExpression(input.name.expression)) {
110970
+ if (isolatedDeclarations) {
110971
+ if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
110972
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
110973
+ return;
110974
+ } else if (
110975
+ // Type declarations just need to double-check that the input computed name is an entity name expression
110976
+ (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
110977
+ ) {
110978
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
110979
+ return;
110980
+ }
110981
+ } else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
110900
110982
  return;
110901
110983
  }
110902
110984
  }
@@ -121788,6 +121870,7 @@ var BuilderState;
121788
121870
  getKeys: (v) => reverse.get(v),
121789
121871
  getValues: (k) => forward.get(k),
121790
121872
  keys: () => forward.keys(),
121873
+ size: () => forward.size,
121791
121874
  deleteKey: (k) => {
121792
121875
  (deleted || (deleted = /* @__PURE__ */ new Set())).add(k);
121793
121876
  const set = forward.get(k);
@@ -121914,12 +121997,15 @@ var BuilderState;
121914
121997
  return oldState && !oldState.referencedMap === !newReferencedMap;
121915
121998
  }
121916
121999
  BuilderState2.canReuseOldState = canReuseOldState;
122000
+ function createReferencedMap(options) {
122001
+ return options.module !== 0 /* None */ && !options.outFile ? createManyToManyPathMap() : void 0;
122002
+ }
122003
+ BuilderState2.createReferencedMap = createReferencedMap;
121917
122004
  function create(newProgram, oldState, disableUseFileVersionAsSignature) {
121918
122005
  var _a, _b;
121919
122006
  const fileInfos = /* @__PURE__ */ new Map();
121920
122007
  const options = newProgram.getCompilerOptions();
121921
- const isOutFile = options.outFile;
121922
- const referencedMap = options.module !== 0 /* None */ && !isOutFile ? createManyToManyPathMap() : void 0;
122008
+ const referencedMap = createReferencedMap(options);
121923
122009
  const useOldState = canReuseOldState(referencedMap, oldState);
121924
122010
  newProgram.getTypeChecker();
121925
122011
  for (const sourceFile of newProgram.getSourceFiles()) {
@@ -121936,7 +122022,7 @@ var BuilderState;
121936
122022
  version: version2,
121937
122023
  signature,
121938
122024
  // No need to calculate affectsGlobalScope with --out since its not used at all
121939
- affectsGlobalScope: !isOutFile ? isFileAffectingGlobalScope(sourceFile) || void 0 : void 0,
122025
+ affectsGlobalScope: !options.outFile ? isFileAffectingGlobalScope(sourceFile) || void 0 : void 0,
121940
122026
  impliedFormat: sourceFile.impliedNodeFormat
121941
122027
  });
121942
122028
  }
@@ -122213,7 +122299,7 @@ function createBuilderProgramState(newProgram, oldState) {
122213
122299
  if (emitDiagnostics) {
122214
122300
  (state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(
122215
122301
  sourceFilePath,
122216
- oldState.hasReusableDiagnostic ? convertToDiagnostics(emitDiagnostics, newProgram) : repopulateDiagnostics(emitDiagnostics, newProgram)
122302
+ oldState.hasReusableDiagnostic ? convertToDiagnostics(emitDiagnostics, sourceFilePath, newProgram) : repopulateDiagnostics(emitDiagnostics, newProgram)
122217
122303
  );
122218
122304
  }
122219
122305
  if (canCopySemanticDiagnostics) {
@@ -122223,7 +122309,7 @@ function createBuilderProgramState(newProgram, oldState) {
122223
122309
  if (diagnostics) {
122224
122310
  state.semanticDiagnosticsPerFile.set(
122225
122311
  sourceFilePath,
122226
- oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : repopulateDiagnostics(diagnostics, newProgram)
122312
+ oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, sourceFilePath, newProgram) : repopulateDiagnostics(diagnostics, newProgram)
122227
122313
  );
122228
122314
  (state.semanticDiagnosticsFromOldState ?? (state.semanticDiagnosticsFromOldState = /* @__PURE__ */ new Set())).add(sourceFilePath);
122229
122315
  }
@@ -122310,17 +122396,17 @@ function convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram
122310
122396
  function convertOrRepopulateDiagnosticMessageChainArray(array, sourceFile, newProgram, repopulateInfo) {
122311
122397
  return sameMap(array, (chain) => convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram, repopulateInfo));
122312
122398
  }
122313
- function convertToDiagnostics(diagnostics, newProgram) {
122399
+ function convertToDiagnostics(diagnostics, diagnosticFilePath, newProgram) {
122314
122400
  if (!diagnostics.length) return emptyArray;
122315
122401
  let buildInfoDirectory;
122316
122402
  return diagnostics.map((diagnostic) => {
122317
- const result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPathInBuildInfoDirectory);
122403
+ const result = convertToDiagnosticRelatedInformation(diagnostic, diagnosticFilePath, newProgram, toPathInBuildInfoDirectory);
122318
122404
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
122319
122405
  result.reportsDeprecated = diagnostic.reportDeprecated;
122320
122406
  result.source = diagnostic.source;
122321
122407
  result.skippedOn = diagnostic.skippedOn;
122322
122408
  const { relatedInformation } = diagnostic;
122323
- result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToDiagnosticRelatedInformation(r, newProgram, toPathInBuildInfoDirectory)) : [] : void 0;
122409
+ result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToDiagnosticRelatedInformation(r, diagnosticFilePath, newProgram, toPathInBuildInfoDirectory)) : [] : void 0;
122324
122410
  return result;
122325
122411
  });
122326
122412
  function toPathInBuildInfoDirectory(path) {
@@ -122328,9 +122414,9 @@ function convertToDiagnostics(diagnostics, newProgram) {
122328
122414
  return toPath(path, buildInfoDirectory, newProgram.getCanonicalFileName);
122329
122415
  }
122330
122416
  }
122331
- function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3) {
122417
+ function convertToDiagnosticRelatedInformation(diagnostic, diagnosticFilePath, newProgram, toPath3) {
122332
122418
  const { file } = diagnostic;
122333
- const sourceFile = file ? newProgram.getSourceFileByPath(toPath3(file)) : void 0;
122419
+ const sourceFile = file !== false ? newProgram.getSourceFileByPath(file ? toPath3(file) : diagnosticFilePath) : void 0;
122334
122420
  return {
122335
122421
  ...diagnostic,
122336
122422
  file: sourceFile,
@@ -122646,7 +122732,7 @@ function isProgramBundleEmitBuildInfo(info) {
122646
122732
  return !!((_a = info.options) == null ? void 0 : _a.outFile);
122647
122733
  }
122648
122734
  function getBuildInfo2(state) {
122649
- var _a;
122735
+ var _a, _b;
122650
122736
  const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
122651
122737
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
122652
122738
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
@@ -122683,7 +122769,7 @@ function getBuildInfo2(state) {
122683
122769
  let fileNamesToFileIdListId;
122684
122770
  let emitSignatures;
122685
122771
  const fileInfos = arrayFrom(state.fileInfos.entries(), ([key, value]) => {
122686
- var _a2, _b;
122772
+ var _a2, _b2;
122687
122773
  const fileId = toFileId(key);
122688
122774
  tryAddRoot(key, fileId);
122689
122775
  Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
@@ -122692,7 +122778,7 @@ function getBuildInfo2(state) {
122692
122778
  if (state.compilerOptions.composite) {
122693
122779
  const file = state.program.getSourceFileByPath(key);
122694
122780
  if (!isJsonSourceFile(file) && sourceFileMayBeEmitted(file, state.program)) {
122695
- const emitSignature = (_b = state.emitSignatures) == null ? void 0 : _b.get(key);
122781
+ const emitSignature = (_b2 = state.emitSignatures) == null ? void 0 : _b2.get(key);
122696
122782
  if (emitSignature !== actualSignature) {
122697
122783
  emitSignatures = append(
122698
122784
  emitSignatures,
@@ -122726,15 +122812,15 @@ function getBuildInfo2(state) {
122726
122812
  );
122727
122813
  });
122728
122814
  let referencedMap;
122729
- if (state.referencedMap) {
122815
+ if ((_a = state.referencedMap) == null ? void 0 : _a.size()) {
122730
122816
  referencedMap = arrayFrom(state.referencedMap.keys()).sort(compareStringsCaseSensitive).map((key) => [
122731
122817
  toFileId(key),
122732
122818
  toFileIdListId(state.referencedMap.getValues(key))
122733
122819
  ]);
122734
122820
  }
122735
- const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics(state.semanticDiagnosticsPerFile);
122821
+ const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics();
122736
122822
  let affectedFilesPendingEmit;
122737
- if ((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size) {
122823
+ if ((_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.size) {
122738
122824
  const fullEmitForOptions = getBuilderFileEmit(state.compilerOptions);
122739
122825
  const seenFiles = /* @__PURE__ */ new Set();
122740
122826
  for (const path of arrayFrom(state.affectedFilesPendingEmit.keys()).sort(compareStringsCaseSensitive)) {
@@ -122762,7 +122848,7 @@ function getBuildInfo2(state) {
122762
122848
  changeFileSet = append(changeFileSet, toFileId(path));
122763
122849
  }
122764
122850
  }
122765
- const emitDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics(state.emitDiagnosticsPerFile);
122851
+ const emitDiagnosticsPerFile = convertToProgramBuildInfoEmitDiagnostics();
122766
122852
  const program = {
122767
122853
  fileNames,
122768
122854
  fileInfos,
@@ -122854,40 +122940,53 @@ function getBuildInfo2(state) {
122854
122940
  }
122855
122941
  return value;
122856
122942
  }
122857
- function convertToProgramBuildInfoDiagnostics(diagnostics) {
122943
+ function convertToProgramBuildInfoDiagnostics() {
122858
122944
  let result;
122859
- if (diagnostics) {
122860
- for (const key of arrayFrom(diagnostics.keys()).sort(compareStringsCaseSensitive)) {
122861
- const value = diagnostics.get(key);
122862
- result = append(
122863
- result,
122864
- value.length ? [
122865
- toFileId(key),
122866
- convertToReusableDiagnostics(value)
122867
- ] : toFileId(key)
122868
- );
122945
+ state.fileInfos.forEach((_value, key) => {
122946
+ var _a2;
122947
+ const value = (_a2 = state.semanticDiagnosticsPerFile) == null ? void 0 : _a2.get(key);
122948
+ if (!value) {
122949
+ if (!state.changedFilesSet.has(key)) result = append(result, toFileId(key));
122950
+ } else if (value.length) {
122951
+ result = append(result, [
122952
+ toFileId(key),
122953
+ convertToReusableDiagnostics(value, key)
122954
+ ]);
122869
122955
  }
122956
+ });
122957
+ return result;
122958
+ }
122959
+ function convertToProgramBuildInfoEmitDiagnostics() {
122960
+ var _a2;
122961
+ let result;
122962
+ if (!((_a2 = state.emitDiagnosticsPerFile) == null ? void 0 : _a2.size)) return result;
122963
+ for (const key of arrayFrom(state.emitDiagnosticsPerFile.keys()).sort(compareStringsCaseSensitive)) {
122964
+ const value = state.emitDiagnosticsPerFile.get(key);
122965
+ result = append(result, [
122966
+ toFileId(key),
122967
+ convertToReusableDiagnostics(value, key)
122968
+ ]);
122870
122969
  }
122871
122970
  return result;
122872
122971
  }
122873
- function convertToReusableDiagnostics(diagnostics) {
122972
+ function convertToReusableDiagnostics(diagnostics, diagnosticFilePath) {
122874
122973
  Debug.assert(!!diagnostics.length);
122875
122974
  return diagnostics.map((diagnostic) => {
122876
- const result = convertToReusableDiagnosticRelatedInformation(diagnostic);
122975
+ const result = convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath);
122877
122976
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
122878
122977
  result.reportDeprecated = diagnostic.reportsDeprecated;
122879
122978
  result.source = diagnostic.source;
122880
122979
  result.skippedOn = diagnostic.skippedOn;
122881
122980
  const { relatedInformation } = diagnostic;
122882
- result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToReusableDiagnosticRelatedInformation(r)) : [] : void 0;
122981
+ result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToReusableDiagnosticRelatedInformation(r, diagnosticFilePath)) : [] : void 0;
122883
122982
  return result;
122884
122983
  });
122885
122984
  }
122886
- function convertToReusableDiagnosticRelatedInformation(diagnostic) {
122985
+ function convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath) {
122887
122986
  const { file } = diagnostic;
122888
122987
  return {
122889
122988
  ...diagnostic,
122890
- file: file ? relativeToBuildInfo(file.resolvedPath) : void 0,
122989
+ file: file ? file.resolvedPath === diagnosticFilePath ? void 0 : relativeToBuildInfo(file.resolvedPath) : false,
122891
122990
  messageText: isString(diagnostic.messageText) ? diagnostic.messageText : convertToReusableDiagnosticMessageChain(diagnostic.messageText)
122892
122991
  };
122893
122992
  }
@@ -123281,16 +123380,17 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123281
123380
  );
123282
123381
  }
123283
123382
  });
123383
+ const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
123284
123384
  const fullEmitForOptions = program.affectedFilesPendingEmit ? getBuilderFileEmit(program.options || {}) : void 0;
123285
123385
  state = {
123286
123386
  fileInfos,
123287
123387
  compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123288
- referencedMap: toManyToManyPathMap(program.referencedMap),
123289
- semanticDiagnosticsPerFile: toPerFileDiagnostics(program.semanticDiagnosticsPerFile),
123290
- emitDiagnosticsPerFile: toPerFileDiagnostics(program.emitDiagnosticsPerFile),
123388
+ referencedMap: toManyToManyPathMap(program.referencedMap, program.options ?? {}),
123389
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile, fileInfos, changedFilesSet),
123390
+ emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
123291
123391
  hasReusableDiagnostic: true,
123292
123392
  affectedFilesPendingEmit: program.affectedFilesPendingEmit && arrayToMap(program.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
123293
- changedFilesSet: new Set(map(program.changeFileSet, toFilePath)),
123393
+ changedFilesSet,
123294
123394
  latestChangedDtsFile,
123295
123395
  emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0
123296
123396
  };
@@ -123332,16 +123432,27 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
123332
123432
  function toFilePathsSet(fileIdsListId) {
123333
123433
  return filePathsSetList[fileIdsListId - 1];
123334
123434
  }
123335
- function toManyToManyPathMap(referenceMap) {
123336
- if (!referenceMap) {
123337
- return void 0;
123338
- }
123339
- const map2 = BuilderState.createManyToManyPathMap();
123435
+ function toManyToManyPathMap(referenceMap, options) {
123436
+ const map2 = BuilderState.createReferencedMap(options);
123437
+ if (!map2 || !referenceMap) return map2;
123340
123438
  referenceMap.forEach(([fileId, fileIdListId]) => map2.set(toFilePath(fileId), toFilePathsSet(fileIdListId)));
123341
123439
  return map2;
123342
123440
  }
123343
- function toPerFileDiagnostics(diagnostics) {
123344
- return diagnostics && arrayToMap(diagnostics, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => isNumber(value) ? emptyArray : value[1]);
123441
+ function toPerFileSemanticDiagnostics(diagnostics, fileInfos, changedFilesSet) {
123442
+ const semanticDiagnostics = new Map(
123443
+ mapDefinedIterator(
123444
+ fileInfos.keys(),
123445
+ (key) => !changedFilesSet.has(key) ? [key, emptyArray] : void 0
123446
+ )
123447
+ );
123448
+ diagnostics == null ? void 0 : diagnostics.forEach((value) => {
123449
+ if (isNumber(value)) semanticDiagnostics.delete(toFilePath(value));
123450
+ else semanticDiagnostics.set(toFilePath(value[0]), value[1]);
123451
+ });
123452
+ return semanticDiagnostics.size ? semanticDiagnostics : void 0;
123453
+ }
123454
+ function toPerFileEmitDiagnostics(diagnostics) {
123455
+ return diagnostics && arrayToMap(diagnostics, (value) => toFilePath(value[0]), (value) => value[1]);
123345
123456
  }
123346
123457
  }
123347
123458
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
@@ -126872,7 +126983,7 @@ function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime,
126872
126983
  }
126873
126984
  }
126874
126985
  function getUpToDateStatusWorker(state, project, resolvedPath) {
126875
- var _a, _b, _c;
126986
+ var _a, _b, _c, _d;
126876
126987
  if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
126877
126988
  return {
126878
126989
  type: 15 /* ContainerOnly */
@@ -126944,7 +127055,7 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
126944
127055
  };
126945
127056
  }
126946
127057
  if (buildInfo.program) {
126947
- if (((_a = buildInfo.program.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.program.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.program.emitDiagnosticsPerFile) == null ? void 0 : _c.length) : some(buildInfo.program.semanticDiagnosticsPerFile, isArray))) {
127058
+ if (((_a = buildInfo.program.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.program.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.program.emitDiagnosticsPerFile) == null ? void 0 : _c.length) : (_d = buildInfo.program.semanticDiagnosticsPerFile) == null ? void 0 : _d.length)) {
126948
127059
  return {
126949
127060
  type: 7 /* OutOfDateBuildInfo */,
126950
127061
  buildInfoFile: buildInfoPath
@@ -128810,8 +128921,8 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
128810
128921
  serializeReturnTypeForSignature,
128811
128922
  serializeTypeOfExpression
128812
128923
  };
128813
- function serializeExistingTypeAnnotation(type) {
128814
- return type === void 0 ? void 0 : !type.parent || !isParameter(type.parent) || !resolver.requiresAddingImplicitUndefined(type.parent) || canAddUndefined(type);
128924
+ function serializeExistingTypeAnnotation(type, addUndefined) {
128925
+ return type !== void 0 && (!addUndefined || type && canAddUndefined(type)) ? true : void 0;
128815
128926
  }
128816
128927
  function serializeTypeOfExpression(expr, context, addUndefined, preserveLiterals) {
128817
128928
  return typeFromExpression(
@@ -128932,12 +129043,17 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
128932
129043
  const declaredType = getEffectiveTypeAnnotationNode(node);
128933
129044
  const addUndefined = resolver.requiresAddingImplicitUndefined(node);
128934
129045
  let resultType;
128935
- if (!addUndefined) {
128936
- if (declaredType) {
128937
- return serializeExistingTypeAnnotation(declaredType);
128938
- }
129046
+ if (declaredType) {
129047
+ resultType = serializeExistingTypeAnnotation(declaredType, addUndefined);
129048
+ } else {
128939
129049
  if (node.initializer && isIdentifier(node.name)) {
128940
- resultType = typeFromExpression(node.initializer, context);
129050
+ resultType = typeFromExpression(
129051
+ node.initializer,
129052
+ context,
129053
+ /*isConstContext*/
129054
+ void 0,
129055
+ addUndefined
129056
+ );
128941
129057
  }
128942
129058
  }
128943
129059
  return resultType ?? inferTypeOfDeclaration(node, context);
@@ -129200,6 +129316,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
129200
129316
  function typeFromSingleReturnExpression(declaration, context) {
129201
129317
  let candidateExpr;
129202
129318
  if (declaration && !nodeIsMissing(declaration.body)) {
129319
+ if (getFunctionFlags(declaration) & 3 /* AsyncGenerator */) return void 0;
129203
129320
  const body = declaration.body;
129204
129321
  if (body && isBlock(body)) {
129205
129322
  forEachReturnStatement(body, (s) => {