typescript 5.5.0-dev.20240524 → 5.5.0-dev.20240526

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 +192 -139
  2. package/lib/typescript.js +194 -141
  3. package/package.json +2 -2
package/lib/typescript.js CHANGED
@@ -2370,7 +2370,7 @@ module.exports = __toCommonJS(typescript_exports);
2370
2370
 
2371
2371
  // src/compiler/corePublic.ts
2372
2372
  var versionMajorMinor = "5.5";
2373
- var version = `${versionMajorMinor}.0-dev.20240524`;
2373
+ var version = `${versionMajorMinor}.0-dev.20240526`;
2374
2374
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2375
2375
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2376
2376
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6200,7 +6200,7 @@ var RegularExpressionFlags = /* @__PURE__ */ ((RegularExpressionFlags2) => {
6200
6200
  RegularExpressionFlags2[RegularExpressionFlags2["Unicode"] = 32] = "Unicode";
6201
6201
  RegularExpressionFlags2[RegularExpressionFlags2["UnicodeSets"] = 64] = "UnicodeSets";
6202
6202
  RegularExpressionFlags2[RegularExpressionFlags2["Sticky"] = 128] = "Sticky";
6203
- RegularExpressionFlags2[RegularExpressionFlags2["UnicodeMode"] = 96] = "UnicodeMode";
6203
+ RegularExpressionFlags2[RegularExpressionFlags2["AnyUnicodeMode"] = 96] = "AnyUnicodeMode";
6204
6204
  RegularExpressionFlags2[RegularExpressionFlags2["Modifiers"] = 28] = "Modifiers";
6205
6205
  return RegularExpressionFlags2;
6206
6206
  })(RegularExpressionFlags || {});
@@ -13326,25 +13326,19 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13326
13326
  }
13327
13327
  function reScanSlashToken(reportErrors2) {
13328
13328
  if (token === 44 /* SlashToken */ || token === 69 /* SlashEqualsToken */) {
13329
- let p = tokenStart + 1;
13329
+ const startOfRegExpBody = tokenStart + 1;
13330
+ pos = startOfRegExpBody;
13330
13331
  let inEscape = false;
13331
13332
  let inCharacterClass = false;
13332
13333
  while (true) {
13333
- if (p >= end) {
13334
- tokenFlags |= 4 /* Unterminated */;
13335
- error2(Diagnostics.Unterminated_regular_expression_literal);
13336
- break;
13337
- }
13338
- const ch = charCodeUnchecked(p);
13339
- if (isLineBreak(ch)) {
13334
+ const ch = charCodeChecked(pos);
13335
+ if (ch === -1 /* EOF */ || isLineBreak(ch)) {
13340
13336
  tokenFlags |= 4 /* Unterminated */;
13341
- error2(Diagnostics.Unterminated_regular_expression_literal);
13342
13337
  break;
13343
13338
  }
13344
13339
  if (inEscape) {
13345
13340
  inEscape = false;
13346
13341
  } else if (ch === 47 /* slash */ && !inCharacterClass) {
13347
- p++;
13348
13342
  break;
13349
13343
  } else if (ch === 91 /* openBracket */) {
13350
13344
  inCharacterClass = true;
@@ -13353,59 +13347,86 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13353
13347
  } else if (ch === 93 /* closeBracket */) {
13354
13348
  inCharacterClass = false;
13355
13349
  }
13356
- p++;
13350
+ pos++;
13357
13351
  }
13358
- const isUnterminated = !!(tokenFlags & 4 /* Unterminated */);
13359
- const endOfBody = p - (isUnterminated ? 0 : 1);
13360
- let regExpFlags = 0 /* None */;
13361
- while (p < end) {
13362
- const ch = charCodeUnchecked(p);
13363
- if (!isIdentifierPart(ch, languageVersion)) {
13364
- break;
13352
+ const endOfRegExpBody = pos;
13353
+ if (tokenFlags & 4 /* Unterminated */) {
13354
+ pos = startOfRegExpBody;
13355
+ inEscape = false;
13356
+ let characterClassDepth = 0;
13357
+ let inDecimalQuantifier = false;
13358
+ let groupDepth = 0;
13359
+ while (pos < endOfRegExpBody) {
13360
+ const ch = charCodeUnchecked(pos);
13361
+ if (inEscape) {
13362
+ inEscape = false;
13363
+ } else if (ch === 92 /* backslash */) {
13364
+ inEscape = true;
13365
+ } else if (ch === 91 /* openBracket */) {
13366
+ characterClassDepth++;
13367
+ } else if (ch === 93 /* closeBracket */ && characterClassDepth) {
13368
+ characterClassDepth--;
13369
+ } else if (!characterClassDepth) {
13370
+ if (ch === 123 /* openBrace */) {
13371
+ inDecimalQuantifier = true;
13372
+ } else if (ch === 125 /* closeBrace */ && inDecimalQuantifier) {
13373
+ inDecimalQuantifier = false;
13374
+ } else if (!inDecimalQuantifier) {
13375
+ if (ch === 40 /* openParen */) {
13376
+ groupDepth++;
13377
+ } else if (ch === 41 /* closeParen */ && groupDepth) {
13378
+ groupDepth--;
13379
+ } else if (ch === 41 /* closeParen */ || ch === 93 /* closeBracket */ || ch === 125 /* closeBrace */) {
13380
+ break;
13381
+ }
13382
+ }
13383
+ }
13384
+ pos++;
13365
13385
  }
13366
- if (reportErrors2) {
13367
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
13368
- if (flag === void 0) {
13369
- error2(Diagnostics.Unknown_regular_expression_flag, p, 1);
13370
- } else if (regExpFlags & flag) {
13371
- error2(Diagnostics.Duplicate_regular_expression_flag, p, 1);
13372
- } else if (((regExpFlags | flag) & 96 /* UnicodeMode */) === 96 /* UnicodeMode */) {
13373
- error2(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
13374
- } else {
13375
- regExpFlags |= flag;
13376
- checkRegularExpressionFlagAvailable(flag, p);
13386
+ while (isWhiteSpaceLike(charCodeChecked(pos - 1)) || charCodeChecked(pos - 1) === 59 /* semicolon */) pos--;
13387
+ error2(Diagnostics.Unterminated_regular_expression_literal, tokenStart, pos - tokenStart);
13388
+ } else {
13389
+ pos++;
13390
+ let regExpFlags = 0 /* None */;
13391
+ while (true) {
13392
+ const ch = codePointChecked(pos);
13393
+ if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
13394
+ break;
13395
+ }
13396
+ if (reportErrors2) {
13397
+ const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
13398
+ if (flag === void 0) {
13399
+ error2(Diagnostics.Unknown_regular_expression_flag, pos, 1);
13400
+ } else if (regExpFlags & flag) {
13401
+ error2(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
13402
+ } else if (((regExpFlags | flag) & 96 /* AnyUnicodeMode */) === 96 /* AnyUnicodeMode */) {
13403
+ error2(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, pos, 1);
13404
+ } else {
13405
+ regExpFlags |= flag;
13406
+ checkRegularExpressionFlagAvailable(flag, pos);
13407
+ }
13377
13408
  }
13409
+ pos++;
13410
+ }
13411
+ if (reportErrors2) {
13412
+ scanRange(startOfRegExpBody, endOfRegExpBody - startOfRegExpBody, () => {
13413
+ scanRegularExpressionWorker(
13414
+ regExpFlags,
13415
+ /*annexB*/
13416
+ true
13417
+ );
13418
+ });
13378
13419
  }
13379
- p++;
13380
- }
13381
- pos = p;
13382
- if (reportErrors2) {
13383
- const saveTokenStart = tokenStart;
13384
- const saveTokenFlags = tokenFlags;
13385
- const savePos = pos;
13386
- const saveEnd = end;
13387
- pos = tokenStart + 1;
13388
- end = endOfBody;
13389
- scanRegularExpressionWorker(
13390
- regExpFlags,
13391
- isUnterminated,
13392
- /*annexB*/
13393
- true
13394
- );
13395
- tokenStart = saveTokenStart;
13396
- tokenFlags = saveTokenFlags;
13397
- pos = savePos;
13398
- end = saveEnd;
13399
13420
  }
13400
13421
  tokenValue = text.substring(tokenStart, pos);
13401
13422
  token = 14 /* RegularExpressionLiteral */;
13402
13423
  }
13403
13424
  return token;
13404
13425
  }
13405
- function scanRegularExpressionWorker(regExpFlags, isUnterminated, annexB) {
13426
+ function scanRegularExpressionWorker(regExpFlags, annexB) {
13406
13427
  var unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
13407
- var unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
13408
- if (unicodeMode) {
13428
+ var anyUnicodeMode = !!(regExpFlags & 96 /* AnyUnicodeMode */);
13429
+ if (anyUnicodeMode) {
13409
13430
  annexB = false;
13410
13431
  }
13411
13432
  var mayContainStrings = false;
@@ -13524,7 +13545,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13524
13545
  if (max || charCodeChecked(pos) === 125 /* closeBrace */) {
13525
13546
  error2(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
13526
13547
  } else {
13527
- if (unicodeMode) {
13548
+ if (anyUnicodeMode) {
13528
13549
  error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13529
13550
  }
13530
13551
  isPreviousTermQuantifiable = true;
@@ -13535,7 +13556,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13535
13556
  error2(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
13536
13557
  }
13537
13558
  } else if (!min2) {
13538
- if (unicodeMode) {
13559
+ if (anyUnicodeMode) {
13539
13560
  error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13540
13561
  }
13541
13562
  isPreviousTermQuantifiable = true;
@@ -13575,10 +13596,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13575
13596
  }
13576
13597
  case 93 /* closeBracket */:
13577
13598
  case 125 /* closeBrace */:
13578
- if (isUnterminated && !isInGroup) {
13579
- return;
13580
- }
13581
- if (unicodeMode || ch === 41 /* closeParen */) {
13599
+ if (anyUnicodeMode || ch === 41 /* closeParen */) {
13582
13600
  error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
13583
13601
  }
13584
13602
  pos++;
@@ -13627,7 +13645,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13627
13645
  true
13628
13646
  );
13629
13647
  scanExpectedChar(62 /* greaterThan */);
13630
- } else if (unicodeMode) {
13648
+ } else if (anyUnicodeMode) {
13631
13649
  error2(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
13632
13650
  }
13633
13651
  break;
@@ -13660,6 +13678,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13660
13678
  Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
13661
13679
  let ch = charCodeChecked(pos);
13662
13680
  switch (ch) {
13681
+ case -1 /* EOF */:
13682
+ error2(Diagnostics.Undetermined_character_escape, pos - 1, 1);
13683
+ return "\\";
13663
13684
  case 99 /* c */:
13664
13685
  pos++;
13665
13686
  ch = charCodeChecked(pos);
@@ -13667,7 +13688,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13667
13688
  pos++;
13668
13689
  return String.fromCharCode(ch & 31);
13669
13690
  }
13670
- if (unicodeMode) {
13691
+ if (anyUnicodeMode) {
13671
13692
  error2(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
13672
13693
  } else if (atomEscape && annexB) {
13673
13694
  pos--;
@@ -13692,14 +13713,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13692
13713
  pos++;
13693
13714
  return String.fromCharCode(ch);
13694
13715
  default:
13695
- if (pos >= end) {
13696
- error2(Diagnostics.Undetermined_character_escape, pos - 1, 1);
13697
- return "\\";
13698
- }
13699
13716
  pos--;
13700
13717
  return scanEscapeSequence(
13701
13718
  /*shouldEmitInvalidEscapeError*/
13702
- unicodeMode,
13719
+ anyUnicodeMode,
13703
13720
  /*isRegularExpression*/
13704
13721
  annexB ? "annex-b" : true
13705
13722
  );
@@ -14175,10 +14192,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14175
14192
  }
14176
14193
  }
14177
14194
  scanExpectedChar(125 /* closeBrace */);
14178
- if (!unicodeMode) {
14195
+ if (!anyUnicodeMode) {
14179
14196
  error2(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
14180
14197
  }
14181
- } else if (unicodeMode) {
14198
+ } else if (anyUnicodeMode) {
14182
14199
  error2(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
14183
14200
  }
14184
14201
  return true;
@@ -14198,7 +14215,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14198
14215
  return value;
14199
14216
  }
14200
14217
  function scanSourceCharacter() {
14201
- const size = unicodeMode ? charSize(charCodeChecked(pos)) : 1;
14218
+ const size = anyUnicodeMode ? charSize(charCodeChecked(pos)) : 1;
14202
14219
  pos += size;
14203
14220
  return size > 0 ? text.substring(pos - size, pos) : "";
14204
14221
  }
@@ -32861,10 +32878,7 @@ var Parser;
32861
32878
  function parseErrorAtPosition(start, length2, message, ...args) {
32862
32879
  const lastError = lastOrUndefined(parseDiagnostics);
32863
32880
  let result;
32864
- if (message.category === 3 /* Message */ && lastError && start === lastError.start && length2 === lastError.length) {
32865
- result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
32866
- addRelatedInfo(lastError, result);
32867
- } else if (!lastError || start !== lastError.start) {
32881
+ if (!lastError || start !== lastError.start) {
32868
32882
  result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
32869
32883
  parseDiagnostics.push(result);
32870
32884
  }
@@ -54048,7 +54062,6 @@ function createTypeChecker(host) {
54048
54062
  return result;
54049
54063
  }
54050
54064
  }
54051
- context.tracker.reportInferenceFallback(existing);
54052
54065
  return void 0;
54053
54066
  }
54054
54067
  function symbolToNode(symbol, context, meaning) {
@@ -55964,26 +55977,27 @@ function createTypeChecker(host) {
55964
55977
  var _a;
55965
55978
  const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
55966
55979
  const enclosingDeclaration = context.enclosingDeclaration;
55980
+ const oldFlags = context.flags;
55981
+ if (declaration && hasInferredType(declaration) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
55982
+ syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, context);
55983
+ }
55984
+ context.flags |= -2147483648 /* NoSyntacticPrinter */;
55967
55985
  if (enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */)) {
55968
55986
  const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol);
55969
55987
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
55970
55988
  const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
55971
55989
  const result2 = !isTypePredicateNode(existing) && tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
55972
55990
  if (result2) {
55991
+ context.flags = oldFlags;
55973
55992
  return result2;
55974
55993
  }
55975
55994
  }
55976
55995
  }
55977
- const oldFlags = context.flags;
55978
55996
  if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
55979
55997
  context.flags |= 1048576 /* AllowUniqueESSymbolType */;
55980
55998
  }
55981
55999
  const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
55982
56000
  const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
55983
- if (decl && hasInferredType(decl) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
55984
- syntacticNodeBuilder.serializeTypeOfDeclaration(decl, context);
55985
- }
55986
- context.flags |= -2147483648 /* NoSyntacticPrinter */;
55987
56001
  const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
55988
56002
  context.flags = oldFlags;
55989
56003
  return result;
@@ -115930,13 +115944,18 @@ function transformDeclarations(context) {
115930
115944
  if (isDeclaration(input)) {
115931
115945
  if (isDeclarationAndNotVisible(input)) return;
115932
115946
  if (hasDynamicName(input)) {
115933
- if (isolatedDeclarations && (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent))) {
115934
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
115935
- }
115936
- if (isolatedDeclarations && (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)) {
115937
- context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
115938
- }
115939
- if (!isEntityNameExpression(input.name.expression)) {
115947
+ if (isolatedDeclarations) {
115948
+ if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
115949
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
115950
+ return;
115951
+ } else if (
115952
+ // Type declarations just need to double-check that the input computed name is an entity name expression
115953
+ (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
115954
+ ) {
115955
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
115956
+ return;
115957
+ }
115958
+ } else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
115940
115959
  return;
115941
115960
  }
115942
115961
  }
@@ -126899,6 +126918,7 @@ var BuilderState;
126899
126918
  getKeys: (v) => reverse.get(v),
126900
126919
  getValues: (k) => forward.get(k),
126901
126920
  keys: () => forward.keys(),
126921
+ size: () => forward.size,
126902
126922
  deleteKey: (k) => {
126903
126923
  (deleted || (deleted = /* @__PURE__ */ new Set())).add(k);
126904
126924
  const set = forward.get(k);
@@ -127025,12 +127045,15 @@ var BuilderState;
127025
127045
  return oldState && !oldState.referencedMap === !newReferencedMap;
127026
127046
  }
127027
127047
  BuilderState2.canReuseOldState = canReuseOldState;
127048
+ function createReferencedMap(options) {
127049
+ return options.module !== 0 /* None */ && !options.outFile ? createManyToManyPathMap() : void 0;
127050
+ }
127051
+ BuilderState2.createReferencedMap = createReferencedMap;
127028
127052
  function create(newProgram, oldState, disableUseFileVersionAsSignature) {
127029
127053
  var _a, _b;
127030
127054
  const fileInfos = /* @__PURE__ */ new Map();
127031
127055
  const options = newProgram.getCompilerOptions();
127032
- const isOutFile = options.outFile;
127033
- const referencedMap = options.module !== 0 /* None */ && !isOutFile ? createManyToManyPathMap() : void 0;
127056
+ const referencedMap = createReferencedMap(options);
127034
127057
  const useOldState = canReuseOldState(referencedMap, oldState);
127035
127058
  newProgram.getTypeChecker();
127036
127059
  for (const sourceFile of newProgram.getSourceFiles()) {
@@ -127047,7 +127070,7 @@ var BuilderState;
127047
127070
  version: version2,
127048
127071
  signature,
127049
127072
  // No need to calculate affectsGlobalScope with --out since its not used at all
127050
- affectsGlobalScope: !isOutFile ? isFileAffectingGlobalScope(sourceFile) || void 0 : void 0,
127073
+ affectsGlobalScope: !options.outFile ? isFileAffectingGlobalScope(sourceFile) || void 0 : void 0,
127051
127074
  impliedFormat: sourceFile.impliedNodeFormat
127052
127075
  });
127053
127076
  }
@@ -127336,7 +127359,7 @@ function createBuilderProgramState(newProgram, oldState) {
127336
127359
  if (emitDiagnostics) {
127337
127360
  (state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(
127338
127361
  sourceFilePath,
127339
- oldState.hasReusableDiagnostic ? convertToDiagnostics(emitDiagnostics, newProgram) : repopulateDiagnostics(emitDiagnostics, newProgram)
127362
+ oldState.hasReusableDiagnostic ? convertToDiagnostics(emitDiagnostics, sourceFilePath, newProgram) : repopulateDiagnostics(emitDiagnostics, newProgram)
127340
127363
  );
127341
127364
  }
127342
127365
  if (canCopySemanticDiagnostics) {
@@ -127346,7 +127369,7 @@ function createBuilderProgramState(newProgram, oldState) {
127346
127369
  if (diagnostics) {
127347
127370
  state.semanticDiagnosticsPerFile.set(
127348
127371
  sourceFilePath,
127349
- oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : repopulateDiagnostics(diagnostics, newProgram)
127372
+ oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, sourceFilePath, newProgram) : repopulateDiagnostics(diagnostics, newProgram)
127350
127373
  );
127351
127374
  (state.semanticDiagnosticsFromOldState ?? (state.semanticDiagnosticsFromOldState = /* @__PURE__ */ new Set())).add(sourceFilePath);
127352
127375
  }
@@ -127433,17 +127456,17 @@ function convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram
127433
127456
  function convertOrRepopulateDiagnosticMessageChainArray(array, sourceFile, newProgram, repopulateInfo) {
127434
127457
  return sameMap(array, (chain) => convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram, repopulateInfo));
127435
127458
  }
127436
- function convertToDiagnostics(diagnostics, newProgram) {
127459
+ function convertToDiagnostics(diagnostics, diagnosticFilePath, newProgram) {
127437
127460
  if (!diagnostics.length) return emptyArray;
127438
127461
  let buildInfoDirectory;
127439
127462
  return diagnostics.map((diagnostic) => {
127440
- const result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPathInBuildInfoDirectory);
127463
+ const result = convertToDiagnosticRelatedInformation(diagnostic, diagnosticFilePath, newProgram, toPathInBuildInfoDirectory);
127441
127464
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
127442
127465
  result.reportsDeprecated = diagnostic.reportDeprecated;
127443
127466
  result.source = diagnostic.source;
127444
127467
  result.skippedOn = diagnostic.skippedOn;
127445
127468
  const { relatedInformation } = diagnostic;
127446
- result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToDiagnosticRelatedInformation(r, newProgram, toPathInBuildInfoDirectory)) : [] : void 0;
127469
+ result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToDiagnosticRelatedInformation(r, diagnosticFilePath, newProgram, toPathInBuildInfoDirectory)) : [] : void 0;
127447
127470
  return result;
127448
127471
  });
127449
127472
  function toPathInBuildInfoDirectory(path) {
@@ -127451,9 +127474,9 @@ function convertToDiagnostics(diagnostics, newProgram) {
127451
127474
  return toPath(path, buildInfoDirectory, newProgram.getCanonicalFileName);
127452
127475
  }
127453
127476
  }
127454
- function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3) {
127477
+ function convertToDiagnosticRelatedInformation(diagnostic, diagnosticFilePath, newProgram, toPath3) {
127455
127478
  const { file } = diagnostic;
127456
- const sourceFile = file ? newProgram.getSourceFileByPath(toPath3(file)) : void 0;
127479
+ const sourceFile = file !== false ? newProgram.getSourceFileByPath(file ? toPath3(file) : diagnosticFilePath) : void 0;
127457
127480
  return {
127458
127481
  ...diagnostic,
127459
127482
  file: sourceFile,
@@ -127769,7 +127792,7 @@ function isProgramBundleEmitBuildInfo(info) {
127769
127792
  return !!((_a = info.options) == null ? void 0 : _a.outFile);
127770
127793
  }
127771
127794
  function getBuildInfo2(state) {
127772
- var _a;
127795
+ var _a, _b;
127773
127796
  const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
127774
127797
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
127775
127798
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
@@ -127806,7 +127829,7 @@ function getBuildInfo2(state) {
127806
127829
  let fileNamesToFileIdListId;
127807
127830
  let emitSignatures;
127808
127831
  const fileInfos = arrayFrom(state.fileInfos.entries(), ([key, value]) => {
127809
- var _a2, _b;
127832
+ var _a2, _b2;
127810
127833
  const fileId = toFileId(key);
127811
127834
  tryAddRoot(key, fileId);
127812
127835
  Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
@@ -127815,7 +127838,7 @@ function getBuildInfo2(state) {
127815
127838
  if (state.compilerOptions.composite) {
127816
127839
  const file = state.program.getSourceFileByPath(key);
127817
127840
  if (!isJsonSourceFile(file) && sourceFileMayBeEmitted(file, state.program)) {
127818
- const emitSignature = (_b = state.emitSignatures) == null ? void 0 : _b.get(key);
127841
+ const emitSignature = (_b2 = state.emitSignatures) == null ? void 0 : _b2.get(key);
127819
127842
  if (emitSignature !== actualSignature) {
127820
127843
  emitSignatures = append(
127821
127844
  emitSignatures,
@@ -127849,15 +127872,15 @@ function getBuildInfo2(state) {
127849
127872
  );
127850
127873
  });
127851
127874
  let referencedMap;
127852
- if (state.referencedMap) {
127875
+ if ((_a = state.referencedMap) == null ? void 0 : _a.size()) {
127853
127876
  referencedMap = arrayFrom(state.referencedMap.keys()).sort(compareStringsCaseSensitive).map((key) => [
127854
127877
  toFileId(key),
127855
127878
  toFileIdListId(state.referencedMap.getValues(key))
127856
127879
  ]);
127857
127880
  }
127858
- const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics(state.semanticDiagnosticsPerFile);
127881
+ const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics();
127859
127882
  let affectedFilesPendingEmit;
127860
- if ((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size) {
127883
+ if ((_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.size) {
127861
127884
  const fullEmitForOptions = getBuilderFileEmit(state.compilerOptions);
127862
127885
  const seenFiles = /* @__PURE__ */ new Set();
127863
127886
  for (const path of arrayFrom(state.affectedFilesPendingEmit.keys()).sort(compareStringsCaseSensitive)) {
@@ -127885,7 +127908,7 @@ function getBuildInfo2(state) {
127885
127908
  changeFileSet = append(changeFileSet, toFileId(path));
127886
127909
  }
127887
127910
  }
127888
- const emitDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics(state.emitDiagnosticsPerFile);
127911
+ const emitDiagnosticsPerFile = convertToProgramBuildInfoEmitDiagnostics();
127889
127912
  const program = {
127890
127913
  fileNames,
127891
127914
  fileInfos,
@@ -127977,40 +128000,53 @@ function getBuildInfo2(state) {
127977
128000
  }
127978
128001
  return value;
127979
128002
  }
127980
- function convertToProgramBuildInfoDiagnostics(diagnostics) {
128003
+ function convertToProgramBuildInfoDiagnostics() {
127981
128004
  let result;
127982
- if (diagnostics) {
127983
- for (const key of arrayFrom(diagnostics.keys()).sort(compareStringsCaseSensitive)) {
127984
- const value = diagnostics.get(key);
127985
- result = append(
127986
- result,
127987
- value.length ? [
127988
- toFileId(key),
127989
- convertToReusableDiagnostics(value)
127990
- ] : toFileId(key)
127991
- );
128005
+ state.fileInfos.forEach((_value, key) => {
128006
+ var _a2;
128007
+ const value = (_a2 = state.semanticDiagnosticsPerFile) == null ? void 0 : _a2.get(key);
128008
+ if (!value) {
128009
+ if (!state.changedFilesSet.has(key)) result = append(result, toFileId(key));
128010
+ } else if (value.length) {
128011
+ result = append(result, [
128012
+ toFileId(key),
128013
+ convertToReusableDiagnostics(value, key)
128014
+ ]);
127992
128015
  }
128016
+ });
128017
+ return result;
128018
+ }
128019
+ function convertToProgramBuildInfoEmitDiagnostics() {
128020
+ var _a2;
128021
+ let result;
128022
+ if (!((_a2 = state.emitDiagnosticsPerFile) == null ? void 0 : _a2.size)) return result;
128023
+ for (const key of arrayFrom(state.emitDiagnosticsPerFile.keys()).sort(compareStringsCaseSensitive)) {
128024
+ const value = state.emitDiagnosticsPerFile.get(key);
128025
+ result = append(result, [
128026
+ toFileId(key),
128027
+ convertToReusableDiagnostics(value, key)
128028
+ ]);
127993
128029
  }
127994
128030
  return result;
127995
128031
  }
127996
- function convertToReusableDiagnostics(diagnostics) {
128032
+ function convertToReusableDiagnostics(diagnostics, diagnosticFilePath) {
127997
128033
  Debug.assert(!!diagnostics.length);
127998
128034
  return diagnostics.map((diagnostic) => {
127999
- const result = convertToReusableDiagnosticRelatedInformation(diagnostic);
128035
+ const result = convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath);
128000
128036
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
128001
128037
  result.reportDeprecated = diagnostic.reportsDeprecated;
128002
128038
  result.source = diagnostic.source;
128003
128039
  result.skippedOn = diagnostic.skippedOn;
128004
128040
  const { relatedInformation } = diagnostic;
128005
- result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToReusableDiagnosticRelatedInformation(r)) : [] : void 0;
128041
+ result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToReusableDiagnosticRelatedInformation(r, diagnosticFilePath)) : [] : void 0;
128006
128042
  return result;
128007
128043
  });
128008
128044
  }
128009
- function convertToReusableDiagnosticRelatedInformation(diagnostic) {
128045
+ function convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath) {
128010
128046
  const { file } = diagnostic;
128011
128047
  return {
128012
128048
  ...diagnostic,
128013
- file: file ? relativeToBuildInfo(file.resolvedPath) : void 0,
128049
+ file: file ? file.resolvedPath === diagnosticFilePath ? void 0 : relativeToBuildInfo(file.resolvedPath) : false,
128014
128050
  messageText: isString(diagnostic.messageText) ? diagnostic.messageText : convertToReusableDiagnosticMessageChain(diagnostic.messageText)
128015
128051
  };
128016
128052
  }
@@ -128409,16 +128445,17 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
128409
128445
  );
128410
128446
  }
128411
128447
  });
128448
+ const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
128412
128449
  const fullEmitForOptions = program.affectedFilesPendingEmit ? getBuilderFileEmit(program.options || {}) : void 0;
128413
128450
  state = {
128414
128451
  fileInfos,
128415
128452
  compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
128416
- referencedMap: toManyToManyPathMap(program.referencedMap),
128417
- semanticDiagnosticsPerFile: toPerFileDiagnostics(program.semanticDiagnosticsPerFile),
128418
- emitDiagnosticsPerFile: toPerFileDiagnostics(program.emitDiagnosticsPerFile),
128453
+ referencedMap: toManyToManyPathMap(program.referencedMap, program.options ?? {}),
128454
+ semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile, fileInfos, changedFilesSet),
128455
+ emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
128419
128456
  hasReusableDiagnostic: true,
128420
128457
  affectedFilesPendingEmit: program.affectedFilesPendingEmit && arrayToMap(program.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
128421
- changedFilesSet: new Set(map(program.changeFileSet, toFilePath)),
128458
+ changedFilesSet,
128422
128459
  latestChangedDtsFile,
128423
128460
  emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0
128424
128461
  };
@@ -128460,16 +128497,27 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
128460
128497
  function toFilePathsSet(fileIdsListId) {
128461
128498
  return filePathsSetList[fileIdsListId - 1];
128462
128499
  }
128463
- function toManyToManyPathMap(referenceMap) {
128464
- if (!referenceMap) {
128465
- return void 0;
128466
- }
128467
- const map2 = BuilderState.createManyToManyPathMap();
128500
+ function toManyToManyPathMap(referenceMap, options) {
128501
+ const map2 = BuilderState.createReferencedMap(options);
128502
+ if (!map2 || !referenceMap) return map2;
128468
128503
  referenceMap.forEach(([fileId, fileIdListId]) => map2.set(toFilePath(fileId), toFilePathsSet(fileIdListId)));
128469
128504
  return map2;
128470
128505
  }
128471
- function toPerFileDiagnostics(diagnostics) {
128472
- return diagnostics && arrayToMap(diagnostics, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => isNumber(value) ? emptyArray : value[1]);
128506
+ function toPerFileSemanticDiagnostics(diagnostics, fileInfos, changedFilesSet) {
128507
+ const semanticDiagnostics = new Map(
128508
+ mapDefinedIterator(
128509
+ fileInfos.keys(),
128510
+ (key) => !changedFilesSet.has(key) ? [key, emptyArray] : void 0
128511
+ )
128512
+ );
128513
+ diagnostics == null ? void 0 : diagnostics.forEach((value) => {
128514
+ if (isNumber(value)) semanticDiagnostics.delete(toFilePath(value));
128515
+ else semanticDiagnostics.set(toFilePath(value[0]), value[1]);
128516
+ });
128517
+ return semanticDiagnostics.size ? semanticDiagnostics : void 0;
128518
+ }
128519
+ function toPerFileEmitDiagnostics(diagnostics) {
128520
+ return diagnostics && arrayToMap(diagnostics, (value) => toFilePath(value[0]), (value) => value[1]);
128473
128521
  }
128474
128522
  }
128475
128523
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
@@ -132060,7 +132108,7 @@ function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime,
132060
132108
  }
132061
132109
  }
132062
132110
  function getUpToDateStatusWorker(state, project, resolvedPath) {
132063
- var _a, _b, _c;
132111
+ var _a, _b, _c, _d;
132064
132112
  if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
132065
132113
  return {
132066
132114
  type: 15 /* ContainerOnly */
@@ -132132,7 +132180,7 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
132132
132180
  };
132133
132181
  }
132134
132182
  if (buildInfo.program) {
132135
- 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))) {
132183
+ 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)) {
132136
132184
  return {
132137
132185
  type: 7 /* OutOfDateBuildInfo */,
132138
132186
  buildInfoFile: buildInfoPath
@@ -134004,8 +134052,8 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
134004
134052
  serializeReturnTypeForSignature,
134005
134053
  serializeTypeOfExpression
134006
134054
  };
134007
- function serializeExistingTypeAnnotation(type) {
134008
- return type === void 0 ? void 0 : !type.parent || !isParameter(type.parent) || !resolver.requiresAddingImplicitUndefined(type.parent) || canAddUndefined(type);
134055
+ function serializeExistingTypeAnnotation(type, addUndefined) {
134056
+ return type !== void 0 && (!addUndefined || type && canAddUndefined(type)) ? true : void 0;
134009
134057
  }
134010
134058
  function serializeTypeOfExpression(expr, context, addUndefined, preserveLiterals) {
134011
134059
  return typeFromExpression(
@@ -134126,12 +134174,17 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
134126
134174
  const declaredType = getEffectiveTypeAnnotationNode(node);
134127
134175
  const addUndefined = resolver.requiresAddingImplicitUndefined(node);
134128
134176
  let resultType;
134129
- if (!addUndefined) {
134130
- if (declaredType) {
134131
- return serializeExistingTypeAnnotation(declaredType);
134132
- }
134177
+ if (declaredType) {
134178
+ resultType = serializeExistingTypeAnnotation(declaredType, addUndefined);
134179
+ } else {
134133
134180
  if (node.initializer && isIdentifier(node.name)) {
134134
- resultType = typeFromExpression(node.initializer, context);
134181
+ resultType = typeFromExpression(
134182
+ node.initializer,
134183
+ context,
134184
+ /*isConstContext*/
134185
+ void 0,
134186
+ addUndefined
134187
+ );
134135
134188
  }
134136
134189
  }
134137
134190
  return resultType ?? inferTypeOfDeclaration(node, context);
@@ -167562,7 +167615,7 @@ function entryToDocumentSpan(entry) {
167562
167615
  }
167563
167616
  }
167564
167617
  function getPrefixAndSuffixText(entry, originalNode, checker, quotePreference) {
167565
- if (entry.kind !== 0 /* Span */ && isIdentifier(originalNode)) {
167618
+ if (entry.kind !== 0 /* Span */ && (isIdentifier(originalNode) || isStringLiteralLike(originalNode))) {
167566
167619
  const { node, kind } = entry;
167567
167620
  const parent2 = node.parent;
167568
167621
  const name = originalNode.text;