@typescript-deploys/pr-build 5.6.0-pr-55887-49 → 5.6.0-pr-59436-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/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.6";
21
- var version = `${versionMajorMinor}.0-insiders.20240725`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240726`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6703,7 +6703,6 @@ var Diagnostics = {
6703
6703
  This_expression_is_always_nullish: diag(2871, 1 /* Error */, "This_expression_is_always_nullish_2871", "This expression is always nullish."),
6704
6704
  This_kind_of_expression_is_always_truthy: diag(2872, 1 /* Error */, "This_kind_of_expression_is_always_truthy_2872", "This kind of expression is always truthy."),
6705
6705
  This_kind_of_expression_is_always_falsy: diag(2873, 1 /* Error */, "This_kind_of_expression_is_always_falsy_2873", "This kind of expression is always falsy."),
6706
- Variable_0_is_used_but_never_initialized: diag(2874, 1 /* Error */, "Variable_0_is_used_but_never_initialized_2874", "Variable '{0}' is used but never initialized."),
6707
6706
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6708
6707
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6709
6708
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -17122,9 +17121,6 @@ function accessKind(node) {
17122
17121
  return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent);
17123
17122
  case 209 /* ArrayLiteralExpression */:
17124
17123
  return accessKind(parent);
17125
- case 249 /* ForInStatement */:
17126
- case 250 /* ForOfStatement */:
17127
- return node === parent.initializer ? 1 /* Write */ : 0 /* Read */;
17128
17124
  default:
17129
17125
  return 0 /* Read */;
17130
17126
  }
@@ -17264,7 +17260,6 @@ function Symbol4(flags, name) {
17264
17260
  this.constEnumOnlyModule = void 0;
17265
17261
  this.isReferenced = void 0;
17266
17262
  this.lastAssignmentPos = void 0;
17267
- this.isDefinitelyAssigned = void 0;
17268
17263
  this.links = void 0;
17269
17264
  }
17270
17265
  function Type3(checker, flags) {
@@ -45476,6 +45471,7 @@ function createTypeChecker(host) {
45476
45471
  getNonOptionalType: removeOptionalTypeMarker,
45477
45472
  getTypeArguments,
45478
45473
  typeToTypeNode: nodeBuilder.typeToTypeNode,
45474
+ typePredicateToTypePredicateNode: nodeBuilder.typePredicateToTypePredicateNode,
45479
45475
  indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration,
45480
45476
  signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration,
45481
45477
  symbolToEntityName: nodeBuilder.symbolToEntityName,
@@ -45746,16 +45742,11 @@ function createTypeChecker(host) {
45746
45742
  checkSourceFileWithEagerDiagnostics(file);
45747
45743
  Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
45748
45744
  diagnostics2 = addRange(diagnostics2, suggestionDiagnostics.getDiagnostics(file.fileName));
45749
- checkUnusedOrUninitializedIdentifiers(
45750
- getPotentiallyUnusedOrUninitializedIdentifiers(file),
45751
- (containingNode, kind, diag2) => {
45752
- if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
45753
- (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
45754
- }
45755
- },
45756
- /*checkUnused*/
45757
- true
45758
- );
45745
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), (containingNode, kind, diag2) => {
45746
+ if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
45747
+ (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
45748
+ }
45749
+ });
45759
45750
  return diagnostics2 || emptyArray;
45760
45751
  } finally {
45761
45752
  cancellationToken = void 0;
@@ -46248,7 +46239,7 @@ function createTypeChecker(host) {
46248
46239
  var deferredGlobalClassAccessorDecoratorTargetType;
46249
46240
  var deferredGlobalClassAccessorDecoratorResultType;
46250
46241
  var deferredGlobalClassFieldDecoratorContextType;
46251
- var allPotentiallyUnusedOrUninitializedIdentifiers = /* @__PURE__ */ new Map();
46242
+ var allPotentiallyUnusedIdentifiers = /* @__PURE__ */ new Map();
46252
46243
  var flowLoopStart = 0;
46253
46244
  var flowLoopCount = 0;
46254
46245
  var sharedFlowCount = 0;
@@ -67799,6 +67790,9 @@ function createTypeChecker(host) {
67799
67790
  return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
67800
67791
  }
67801
67792
  function isFunctionObjectType(type) {
67793
+ if (getObjectFlags(type) & 256 /* EvolvingArray */) {
67794
+ return false;
67795
+ }
67802
67796
  const resolved = resolveStructuredTypeMembers(type);
67803
67797
  return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
67804
67798
  }
@@ -69582,9 +69576,6 @@ function createTypeChecker(host) {
69582
69576
  void 0
69583
69577
  );
69584
69578
  }
69585
- function isSymbolAssignedDefinitely(symbol) {
69586
- return symbol.isDefinitelyAssigned ?? (isSymbolAssigned(symbol) && symbol.isDefinitelyAssigned);
69587
- }
69588
69579
  function isPastLastAssignment(symbol, location) {
69589
69580
  const parent = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
69590
69581
  if (!parent) {
@@ -69595,7 +69586,6 @@ function createTypeChecker(host) {
69595
69586
  links.flags |= 131072 /* AssignmentsMarked */;
69596
69587
  if (!hasParentWithAssignmentsMarked(parent)) {
69597
69588
  markNodeAssignments(parent);
69598
- symbol.isDefinitelyAssigned ?? (symbol.isDefinitelyAssigned = false);
69599
69589
  }
69600
69590
  }
69601
69591
  return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
@@ -69619,18 +69609,12 @@ function createTypeChecker(host) {
69619
69609
  function markNodeAssignments(node) {
69620
69610
  switch (node.kind) {
69621
69611
  case 80 /* Identifier */:
69622
- const assignmentKind = getAssignmentTargetKind(node);
69623
- if (assignmentKind !== 0 /* None */) {
69612
+ if (isAssignmentTarget(node)) {
69624
69613
  const symbol = getResolvedSymbol(node);
69625
- if (isParameterOrMutableLocalVariable(symbol)) {
69626
- if (assignmentKind === 1 /* Definite */) {
69627
- symbol.isDefinitelyAssigned = true;
69628
- }
69629
- if (symbol.lastAssignmentPos !== Number.MAX_VALUE) {
69630
- const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
69631
- const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
69632
- symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
69633
- }
69614
+ if (isParameterOrMutableLocalVariable(symbol) && symbol.lastAssignmentPos !== Number.MAX_VALUE) {
69615
+ const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
69616
+ const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
69617
+ symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
69634
69618
  }
69635
69619
  }
69636
69620
  return;
@@ -79180,7 +79164,7 @@ function createTypeChecker(host) {
79180
79164
  }
79181
79165
  }
79182
79166
  if (node.kind !== 181 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) {
79183
- registerForUnusedOrUninitializedIdentifiersCheck(node);
79167
+ registerForUnusedIdentifiersCheck(node);
79184
79168
  }
79185
79169
  }
79186
79170
  }
@@ -79726,7 +79710,7 @@ function createTypeChecker(host) {
79726
79710
  }
79727
79711
  }
79728
79712
  }
79729
- registerForUnusedOrUninitializedIdentifiersCheck(node);
79713
+ registerForUnusedIdentifiersCheck(node);
79730
79714
  }
79731
79715
  function checkTemplateLiteralType(node) {
79732
79716
  for (const span of node.templateSpans) {
@@ -80678,27 +80662,25 @@ function createTypeChecker(host) {
80678
80662
  }
80679
80663
  }
80680
80664
  }
80681
- function registerForUnusedOrUninitializedIdentifiersCheck(node) {
80682
- addLazyDiagnostic(registerForUnusedOrUninitializedIdentifiersCheckDiagnostics);
80683
- function registerForUnusedOrUninitializedIdentifiersCheckDiagnostics() {
80665
+ function registerForUnusedIdentifiersCheck(node) {
80666
+ addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
80667
+ function registerForUnusedIdentifiersCheckDiagnostics() {
80684
80668
  const sourceFile = getSourceFileOfNode(node);
80685
- let potentiallyUnusedOrUninitializedIdentifiers = allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path);
80686
- if (!potentiallyUnusedOrUninitializedIdentifiers) {
80687
- potentiallyUnusedOrUninitializedIdentifiers = [];
80688
- allPotentiallyUnusedOrUninitializedIdentifiers.set(sourceFile.path, potentiallyUnusedOrUninitializedIdentifiers);
80669
+ let potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
80670
+ if (!potentiallyUnusedIdentifiers) {
80671
+ potentiallyUnusedIdentifiers = [];
80672
+ allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
80689
80673
  }
80690
- potentiallyUnusedOrUninitializedIdentifiers.push(node);
80674
+ potentiallyUnusedIdentifiers.push(node);
80691
80675
  }
80692
80676
  }
80693
- function checkUnusedOrUninitializedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic, checkUnused, checkUninitialized) {
80677
+ function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
80694
80678
  for (const node of potentiallyUnusedIdentifiers) {
80695
80679
  switch (node.kind) {
80696
80680
  case 263 /* ClassDeclaration */:
80697
80681
  case 231 /* ClassExpression */:
80698
- if (checkUnused) {
80699
- checkUnusedClassMembers(node, addDiagnostic);
80700
- checkUnusedTypeParameters(node, addDiagnostic);
80701
- }
80682
+ checkUnusedClassMembers(node, addDiagnostic);
80683
+ checkUnusedTypeParameters(node, addDiagnostic);
80702
80684
  break;
80703
80685
  case 307 /* SourceFile */:
80704
80686
  case 267 /* ModuleDeclaration */:
@@ -80707,12 +80689,7 @@ function createTypeChecker(host) {
80707
80689
  case 248 /* ForStatement */:
80708
80690
  case 249 /* ForInStatement */:
80709
80691
  case 250 /* ForOfStatement */:
80710
- if (checkUnused) {
80711
- checkUnusedLocalsAndParameters(node, addDiagnostic);
80712
- }
80713
- if (checkUninitialized) {
80714
- checkUninitializedLocals(node);
80715
- }
80692
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
80716
80693
  break;
80717
80694
  case 176 /* Constructor */:
80718
80695
  case 218 /* FunctionExpression */:
@@ -80721,15 +80698,10 @@ function createTypeChecker(host) {
80721
80698
  case 174 /* MethodDeclaration */:
80722
80699
  case 177 /* GetAccessor */:
80723
80700
  case 178 /* SetAccessor */:
80724
- if (checkUnused) {
80725
- if (node.body) {
80726
- checkUnusedLocalsAndParameters(node, addDiagnostic);
80727
- }
80728
- checkUnusedTypeParameters(node, addDiagnostic);
80729
- }
80730
- if (checkUninitialized) {
80731
- checkUninitializedLocals(node);
80701
+ if (node.body) {
80702
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
80732
80703
  }
80704
+ checkUnusedTypeParameters(node, addDiagnostic);
80733
80705
  break;
80734
80706
  case 173 /* MethodSignature */:
80735
80707
  case 179 /* CallSignature */:
@@ -80738,14 +80710,10 @@ function createTypeChecker(host) {
80738
80710
  case 185 /* ConstructorType */:
80739
80711
  case 265 /* TypeAliasDeclaration */:
80740
80712
  case 264 /* InterfaceDeclaration */:
80741
- if (checkUnused) {
80742
- checkUnusedTypeParameters(node, addDiagnostic);
80743
- }
80713
+ checkUnusedTypeParameters(node, addDiagnostic);
80744
80714
  break;
80745
80715
  case 195 /* InferType */:
80746
- if (checkUnused) {
80747
- checkUnusedInferTypeParameter(node, addDiagnostic);
80748
- }
80716
+ checkUnusedInferTypeParameter(node, addDiagnostic);
80749
80717
  break;
80750
80718
  default:
80751
80719
  Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
@@ -80932,21 +80900,6 @@ function createTypeChecker(host) {
80932
80900
  }
80933
80901
  });
80934
80902
  }
80935
- function checkUninitializedLocals(nodeWithLocals) {
80936
- nodeWithLocals.locals.forEach((local) => {
80937
- if (!(local.flags & 3 /* Variable */) || !local.isReferenced || isSymbolAssignedDefinitely(local)) {
80938
- return;
80939
- }
80940
- const declaration = local.valueDeclaration;
80941
- if (!declaration || !isVariableDeclaration(declaration) || !(getCombinedNodeFlagsCached(declaration) & 7 /* BlockScoped */) || getCombinedNodeFlagsCached(declaration) & 33554432 /* Ambient */ || declaration.exclamationToken || declaration.initializer || !declaration.type) {
80942
- return;
80943
- }
80944
- const type = getTypeFromTypeNode(declaration.type);
80945
- if (!(type.flags & 3 /* AnyOrUnknown */) && !containsUndefinedType(type)) {
80946
- error(declaration, Diagnostics.Variable_0_is_used_but_never_initialized, idText(declaration.name));
80947
- }
80948
- });
80949
- }
80950
80903
  function checkPotentialUncheckedRenamedBindingElementsInTypes() {
80951
80904
  var _a;
80952
80905
  for (const node of potentialUnusedRenamedBindingElementsInTypes) {
@@ -80993,7 +80946,7 @@ function createTypeChecker(host) {
80993
80946
  forEach(node.statements, checkSourceElement);
80994
80947
  }
80995
80948
  if (node.locals) {
80996
- registerForUnusedOrUninitializedIdentifiersCheck(node);
80949
+ registerForUnusedIdentifiersCheck(node);
80997
80950
  }
80998
80951
  }
80999
80952
  function checkCollisionWithArgumentsInGeneratedCode(node) {
@@ -81583,7 +81536,7 @@ function createTypeChecker(host) {
81583
81536
  if (node.incrementor) checkExpression(node.incrementor);
81584
81537
  checkSourceElement(node.statement);
81585
81538
  if (node.locals) {
81586
- registerForUnusedOrUninitializedIdentifiersCheck(node);
81539
+ registerForUnusedIdentifiersCheck(node);
81587
81540
  }
81588
81541
  }
81589
81542
  function checkForOfStatement(node) {
@@ -81622,7 +81575,7 @@ function createTypeChecker(host) {
81622
81575
  }
81623
81576
  checkSourceElement(node.statement);
81624
81577
  if (node.locals) {
81625
- registerForUnusedOrUninitializedIdentifiersCheck(node);
81578
+ registerForUnusedIdentifiersCheck(node);
81626
81579
  }
81627
81580
  }
81628
81581
  function checkForInStatement(node) {
@@ -81654,7 +81607,7 @@ function createTypeChecker(host) {
81654
81607
  }
81655
81608
  checkSourceElement(node.statement);
81656
81609
  if (node.locals) {
81657
- registerForUnusedOrUninitializedIdentifiersCheck(node);
81610
+ registerForUnusedIdentifiersCheck(node);
81658
81611
  }
81659
81612
  }
81660
81613
  function checkRightHandSideOfForOf(statement) {
@@ -82340,7 +82293,7 @@ function createTypeChecker(host) {
82340
82293
  }
82341
82294
  });
82342
82295
  if (node.caseBlock.locals) {
82343
- registerForUnusedOrUninitializedIdentifiersCheck(node.caseBlock);
82296
+ registerForUnusedIdentifiersCheck(node.caseBlock);
82344
82297
  }
82345
82298
  }
82346
82299
  function checkLabeledStatement(node) {
@@ -82677,7 +82630,7 @@ function createTypeChecker(host) {
82677
82630
  }
82678
82631
  function checkClassExpressionDeferred(node) {
82679
82632
  forEach(node.members, checkSourceElement);
82680
- registerForUnusedOrUninitializedIdentifiersCheck(node);
82633
+ registerForUnusedIdentifiersCheck(node);
82681
82634
  }
82682
82635
  function checkClassDeclaration(node) {
82683
82636
  const firstDecorator = find(node.modifiers, isDecorator);
@@ -82689,7 +82642,7 @@ function createTypeChecker(host) {
82689
82642
  }
82690
82643
  checkClassLikeDeclaration(node);
82691
82644
  forEach(node.members, checkSourceElement);
82692
- registerForUnusedOrUninitializedIdentifiersCheck(node);
82645
+ registerForUnusedIdentifiersCheck(node);
82693
82646
  }
82694
82647
  function checkClassLikeDeclaration(node) {
82695
82648
  checkGrammarClassLikeDeclaration(node);
@@ -83245,7 +83198,7 @@ function createTypeChecker(host) {
83245
83198
  forEach(node.members, checkSourceElement);
83246
83199
  addLazyDiagnostic(() => {
83247
83200
  checkTypeForDuplicateIndexSignatures(node);
83248
- registerForUnusedOrUninitializedIdentifiersCheck(node);
83201
+ registerForUnusedIdentifiersCheck(node);
83249
83202
  });
83250
83203
  }
83251
83204
  function checkTypeAliasDeclaration(node) {
@@ -83261,7 +83214,7 @@ function createTypeChecker(host) {
83261
83214
  }
83262
83215
  } else {
83263
83216
  checkSourceElement(node.type);
83264
- registerForUnusedOrUninitializedIdentifiersCheck(node);
83217
+ registerForUnusedIdentifiersCheck(node);
83265
83218
  }
83266
83219
  }
83267
83220
  function computeEnumMemberValues(node) {
@@ -83523,7 +83476,7 @@ function createTypeChecker(host) {
83523
83476
  if (node.body) {
83524
83477
  checkSourceElement(node.body);
83525
83478
  if (!isGlobalScopeAugmentation(node)) {
83526
- registerForUnusedOrUninitializedIdentifiersCheck(node);
83479
+ registerForUnusedIdentifiersCheck(node);
83527
83480
  }
83528
83481
  }
83529
83482
  addLazyDiagnostic(checkModuleDeclarationDiagnostics);
@@ -84568,8 +84521,8 @@ function createTypeChecker(host) {
84568
84521
  return Debug.assertNever(kind);
84569
84522
  }
84570
84523
  }
84571
- function getPotentiallyUnusedOrUninitializedIdentifiers(sourceFile) {
84572
- return allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path) || emptyArray;
84524
+ function getPotentiallyUnusedIdentifiers(sourceFile) {
84525
+ return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || emptyArray;
84573
84526
  }
84574
84527
  function checkSourceFileWorker(node) {
84575
84528
  const links = getNodeLinks(node);
@@ -84594,21 +84547,15 @@ function createTypeChecker(host) {
84594
84547
  checkSourceElement(node.endOfFileToken);
84595
84548
  checkDeferredNodes(node);
84596
84549
  if (isExternalOrCommonJsModule(node)) {
84597
- registerForUnusedOrUninitializedIdentifiersCheck(node);
84550
+ registerForUnusedIdentifiersCheck(node);
84598
84551
  }
84599
84552
  addLazyDiagnostic(() => {
84600
- const checkUnused = !node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters);
84601
- if (checkUnused || strictNullChecks) {
84602
- checkUnusedOrUninitializedIdentifiers(
84603
- getPotentiallyUnusedOrUninitializedIdentifiers(node),
84604
- (containingNode, kind, diag2) => {
84605
- if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
84606
- diagnostics.add(diag2);
84607
- }
84608
- },
84609
- checkUnused,
84610
- strictNullChecks
84611
- );
84553
+ if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
84554
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), (containingNode, kind, diag2) => {
84555
+ if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
84556
+ diagnostics.add(diag2);
84557
+ }
84558
+ });
84612
84559
  }
84613
84560
  if (!node.isDeclarationFile) {
84614
84561
  checkPotentialUncheckedRenamedBindingElementsInTypes();
@@ -3268,6 +3268,7 @@ declare namespace ts {
3268
3268
  private delayUpdateProjectsOfScriptInfoPath;
3269
3269
  private handleDeletedFile;
3270
3270
  private watchWildcardDirectory;
3271
+ private onWildCardDirectoryWatcherInvoke;
3271
3272
  private delayUpdateProjectsFromParsedConfigOnConfigFileChange;
3272
3273
  private onConfigFileChanged;
3273
3274
  private removeProject;
@@ -3338,6 +3339,7 @@ declare namespace ts {
3338
3339
  private ensureProjectChildren;
3339
3340
  private cleanupConfiguredProjects;
3340
3341
  private cleanupProjectsAndScriptInfos;
3342
+ private tryInvokeWildCardDirectories;
3341
3343
  openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult;
3342
3344
  private removeOrphanScriptInfos;
3343
3345
  private telemetryOnOpenFile;
package/lib/typescript.js CHANGED
@@ -484,6 +484,7 @@ __export(typescript_exports, {
484
484
  decodeMappings: () => decodeMappings,
485
485
  decodedTextSpanIntersectsWith: () => decodedTextSpanIntersectsWith,
486
486
  deduplicate: () => deduplicate,
487
+ defaultInitCompilerOptions: () => defaultInitCompilerOptions,
487
488
  defaultMaximumTruncationLength: () => defaultMaximumTruncationLength,
488
489
  diagnosticCategoryName: () => diagnosticCategoryName,
489
490
  diagnosticToString: () => diagnosticToString,
@@ -2259,7 +2260,7 @@ module.exports = __toCommonJS(typescript_exports);
2259
2260
 
2260
2261
  // src/compiler/corePublic.ts
2261
2262
  var versionMajorMinor = "5.6";
2262
- var version = `${versionMajorMinor}.0-insiders.20240725`;
2263
+ var version = `${versionMajorMinor}.0-insiders.20240726`;
2263
2264
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2264
2265
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2265
2266
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -10099,7 +10100,6 @@ var Diagnostics = {
10099
10100
  This_expression_is_always_nullish: diag(2871, 1 /* Error */, "This_expression_is_always_nullish_2871", "This expression is always nullish."),
10100
10101
  This_kind_of_expression_is_always_truthy: diag(2872, 1 /* Error */, "This_kind_of_expression_is_always_truthy_2872", "This kind of expression is always truthy."),
10101
10102
  This_kind_of_expression_is_always_falsy: diag(2873, 1 /* Error */, "This_kind_of_expression_is_always_falsy_2873", "This kind of expression is always falsy."),
10102
- Variable_0_is_used_but_never_initialized: diag(2874, 1 /* Error */, "Variable_0_is_used_but_never_initialized_2874", "Variable '{0}' is used but never initialized."),
10103
10103
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
10104
10104
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
10105
10105
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -21012,9 +21012,6 @@ function accessKind(node) {
21012
21012
  return node === parent2.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent2.parent);
21013
21013
  case 209 /* ArrayLiteralExpression */:
21014
21014
  return accessKind(parent2);
21015
- case 249 /* ForInStatement */:
21016
- case 250 /* ForOfStatement */:
21017
- return node === parent2.initializer ? 1 /* Write */ : 0 /* Read */;
21018
21015
  default:
21019
21016
  return 0 /* Read */;
21020
21017
  }
@@ -21213,7 +21210,6 @@ function Symbol4(flags, name) {
21213
21210
  this.constEnumOnlyModule = void 0;
21214
21211
  this.isReferenced = void 0;
21215
21212
  this.lastAssignmentPos = void 0;
21216
- this.isDefinitelyAssigned = void 0;
21217
21213
  this.links = void 0;
21218
21214
  }
21219
21215
  function Type3(checker, flags) {
@@ -50094,6 +50090,7 @@ function createTypeChecker(host) {
50094
50090
  getNonOptionalType: removeOptionalTypeMarker,
50095
50091
  getTypeArguments,
50096
50092
  typeToTypeNode: nodeBuilder.typeToTypeNode,
50093
+ typePredicateToTypePredicateNode: nodeBuilder.typePredicateToTypePredicateNode,
50097
50094
  indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration,
50098
50095
  signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration,
50099
50096
  symbolToEntityName: nodeBuilder.symbolToEntityName,
@@ -50364,16 +50361,11 @@ function createTypeChecker(host) {
50364
50361
  checkSourceFileWithEagerDiagnostics(file);
50365
50362
  Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
50366
50363
  diagnostics2 = addRange(diagnostics2, suggestionDiagnostics.getDiagnostics(file.fileName));
50367
- checkUnusedOrUninitializedIdentifiers(
50368
- getPotentiallyUnusedOrUninitializedIdentifiers(file),
50369
- (containingNode, kind, diag2) => {
50370
- if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
50371
- (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
50372
- }
50373
- },
50374
- /*checkUnused*/
50375
- true
50376
- );
50364
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), (containingNode, kind, diag2) => {
50365
+ if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
50366
+ (diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
50367
+ }
50368
+ });
50377
50369
  return diagnostics2 || emptyArray;
50378
50370
  } finally {
50379
50371
  cancellationToken = void 0;
@@ -50866,7 +50858,7 @@ function createTypeChecker(host) {
50866
50858
  var deferredGlobalClassAccessorDecoratorTargetType;
50867
50859
  var deferredGlobalClassAccessorDecoratorResultType;
50868
50860
  var deferredGlobalClassFieldDecoratorContextType;
50869
- var allPotentiallyUnusedOrUninitializedIdentifiers = /* @__PURE__ */ new Map();
50861
+ var allPotentiallyUnusedIdentifiers = /* @__PURE__ */ new Map();
50870
50862
  var flowLoopStart = 0;
50871
50863
  var flowLoopCount = 0;
50872
50864
  var sharedFlowCount = 0;
@@ -72417,6 +72409,9 @@ function createTypeChecker(host) {
72417
72409
  return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
72418
72410
  }
72419
72411
  function isFunctionObjectType(type) {
72412
+ if (getObjectFlags(type) & 256 /* EvolvingArray */) {
72413
+ return false;
72414
+ }
72420
72415
  const resolved = resolveStructuredTypeMembers(type);
72421
72416
  return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
72422
72417
  }
@@ -74200,9 +74195,6 @@ function createTypeChecker(host) {
74200
74195
  void 0
74201
74196
  );
74202
74197
  }
74203
- function isSymbolAssignedDefinitely(symbol) {
74204
- return symbol.isDefinitelyAssigned ?? (isSymbolAssigned(symbol) && symbol.isDefinitelyAssigned);
74205
- }
74206
74198
  function isPastLastAssignment(symbol, location) {
74207
74199
  const parent2 = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
74208
74200
  if (!parent2) {
@@ -74213,7 +74205,6 @@ function createTypeChecker(host) {
74213
74205
  links.flags |= 131072 /* AssignmentsMarked */;
74214
74206
  if (!hasParentWithAssignmentsMarked(parent2)) {
74215
74207
  markNodeAssignments(parent2);
74216
- symbol.isDefinitelyAssigned ?? (symbol.isDefinitelyAssigned = false);
74217
74208
  }
74218
74209
  }
74219
74210
  return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
@@ -74237,18 +74228,12 @@ function createTypeChecker(host) {
74237
74228
  function markNodeAssignments(node) {
74238
74229
  switch (node.kind) {
74239
74230
  case 80 /* Identifier */:
74240
- const assignmentKind = getAssignmentTargetKind(node);
74241
- if (assignmentKind !== 0 /* None */) {
74231
+ if (isAssignmentTarget(node)) {
74242
74232
  const symbol = getResolvedSymbol(node);
74243
- if (isParameterOrMutableLocalVariable(symbol)) {
74244
- if (assignmentKind === 1 /* Definite */) {
74245
- symbol.isDefinitelyAssigned = true;
74246
- }
74247
- if (symbol.lastAssignmentPos !== Number.MAX_VALUE) {
74248
- const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
74249
- const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
74250
- symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
74251
- }
74233
+ if (isParameterOrMutableLocalVariable(symbol) && symbol.lastAssignmentPos !== Number.MAX_VALUE) {
74234
+ const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
74235
+ const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
74236
+ symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
74252
74237
  }
74253
74238
  }
74254
74239
  return;
@@ -83798,7 +83783,7 @@ function createTypeChecker(host) {
83798
83783
  }
83799
83784
  }
83800
83785
  if (node.kind !== 181 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) {
83801
- registerForUnusedOrUninitializedIdentifiersCheck(node);
83786
+ registerForUnusedIdentifiersCheck(node);
83802
83787
  }
83803
83788
  }
83804
83789
  }
@@ -84344,7 +84329,7 @@ function createTypeChecker(host) {
84344
84329
  }
84345
84330
  }
84346
84331
  }
84347
- registerForUnusedOrUninitializedIdentifiersCheck(node);
84332
+ registerForUnusedIdentifiersCheck(node);
84348
84333
  }
84349
84334
  function checkTemplateLiteralType(node) {
84350
84335
  for (const span of node.templateSpans) {
@@ -85296,27 +85281,25 @@ function createTypeChecker(host) {
85296
85281
  }
85297
85282
  }
85298
85283
  }
85299
- function registerForUnusedOrUninitializedIdentifiersCheck(node) {
85300
- addLazyDiagnostic(registerForUnusedOrUninitializedIdentifiersCheckDiagnostics);
85301
- function registerForUnusedOrUninitializedIdentifiersCheckDiagnostics() {
85284
+ function registerForUnusedIdentifiersCheck(node) {
85285
+ addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
85286
+ function registerForUnusedIdentifiersCheckDiagnostics() {
85302
85287
  const sourceFile = getSourceFileOfNode(node);
85303
- let potentiallyUnusedOrUninitializedIdentifiers = allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path);
85304
- if (!potentiallyUnusedOrUninitializedIdentifiers) {
85305
- potentiallyUnusedOrUninitializedIdentifiers = [];
85306
- allPotentiallyUnusedOrUninitializedIdentifiers.set(sourceFile.path, potentiallyUnusedOrUninitializedIdentifiers);
85288
+ let potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
85289
+ if (!potentiallyUnusedIdentifiers) {
85290
+ potentiallyUnusedIdentifiers = [];
85291
+ allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
85307
85292
  }
85308
- potentiallyUnusedOrUninitializedIdentifiers.push(node);
85293
+ potentiallyUnusedIdentifiers.push(node);
85309
85294
  }
85310
85295
  }
85311
- function checkUnusedOrUninitializedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic, checkUnused, checkUninitialized) {
85296
+ function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
85312
85297
  for (const node of potentiallyUnusedIdentifiers) {
85313
85298
  switch (node.kind) {
85314
85299
  case 263 /* ClassDeclaration */:
85315
85300
  case 231 /* ClassExpression */:
85316
- if (checkUnused) {
85317
- checkUnusedClassMembers(node, addDiagnostic);
85318
- checkUnusedTypeParameters(node, addDiagnostic);
85319
- }
85301
+ checkUnusedClassMembers(node, addDiagnostic);
85302
+ checkUnusedTypeParameters(node, addDiagnostic);
85320
85303
  break;
85321
85304
  case 307 /* SourceFile */:
85322
85305
  case 267 /* ModuleDeclaration */:
@@ -85325,12 +85308,7 @@ function createTypeChecker(host) {
85325
85308
  case 248 /* ForStatement */:
85326
85309
  case 249 /* ForInStatement */:
85327
85310
  case 250 /* ForOfStatement */:
85328
- if (checkUnused) {
85329
- checkUnusedLocalsAndParameters(node, addDiagnostic);
85330
- }
85331
- if (checkUninitialized) {
85332
- checkUninitializedLocals(node);
85333
- }
85311
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
85334
85312
  break;
85335
85313
  case 176 /* Constructor */:
85336
85314
  case 218 /* FunctionExpression */:
@@ -85339,15 +85317,10 @@ function createTypeChecker(host) {
85339
85317
  case 174 /* MethodDeclaration */:
85340
85318
  case 177 /* GetAccessor */:
85341
85319
  case 178 /* SetAccessor */:
85342
- if (checkUnused) {
85343
- if (node.body) {
85344
- checkUnusedLocalsAndParameters(node, addDiagnostic);
85345
- }
85346
- checkUnusedTypeParameters(node, addDiagnostic);
85347
- }
85348
- if (checkUninitialized) {
85349
- checkUninitializedLocals(node);
85320
+ if (node.body) {
85321
+ checkUnusedLocalsAndParameters(node, addDiagnostic);
85350
85322
  }
85323
+ checkUnusedTypeParameters(node, addDiagnostic);
85351
85324
  break;
85352
85325
  case 173 /* MethodSignature */:
85353
85326
  case 179 /* CallSignature */:
@@ -85356,14 +85329,10 @@ function createTypeChecker(host) {
85356
85329
  case 185 /* ConstructorType */:
85357
85330
  case 265 /* TypeAliasDeclaration */:
85358
85331
  case 264 /* InterfaceDeclaration */:
85359
- if (checkUnused) {
85360
- checkUnusedTypeParameters(node, addDiagnostic);
85361
- }
85332
+ checkUnusedTypeParameters(node, addDiagnostic);
85362
85333
  break;
85363
85334
  case 195 /* InferType */:
85364
- if (checkUnused) {
85365
- checkUnusedInferTypeParameter(node, addDiagnostic);
85366
- }
85335
+ checkUnusedInferTypeParameter(node, addDiagnostic);
85367
85336
  break;
85368
85337
  default:
85369
85338
  Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
@@ -85550,21 +85519,6 @@ function createTypeChecker(host) {
85550
85519
  }
85551
85520
  });
85552
85521
  }
85553
- function checkUninitializedLocals(nodeWithLocals) {
85554
- nodeWithLocals.locals.forEach((local) => {
85555
- if (!(local.flags & 3 /* Variable */) || !local.isReferenced || isSymbolAssignedDefinitely(local)) {
85556
- return;
85557
- }
85558
- const declaration = local.valueDeclaration;
85559
- if (!declaration || !isVariableDeclaration(declaration) || !(getCombinedNodeFlagsCached(declaration) & 7 /* BlockScoped */) || getCombinedNodeFlagsCached(declaration) & 33554432 /* Ambient */ || declaration.exclamationToken || declaration.initializer || !declaration.type) {
85560
- return;
85561
- }
85562
- const type = getTypeFromTypeNode(declaration.type);
85563
- if (!(type.flags & 3 /* AnyOrUnknown */) && !containsUndefinedType(type)) {
85564
- error2(declaration, Diagnostics.Variable_0_is_used_but_never_initialized, idText(declaration.name));
85565
- }
85566
- });
85567
- }
85568
85522
  function checkPotentialUncheckedRenamedBindingElementsInTypes() {
85569
85523
  var _a;
85570
85524
  for (const node of potentialUnusedRenamedBindingElementsInTypes) {
@@ -85611,7 +85565,7 @@ function createTypeChecker(host) {
85611
85565
  forEach(node.statements, checkSourceElement);
85612
85566
  }
85613
85567
  if (node.locals) {
85614
- registerForUnusedOrUninitializedIdentifiersCheck(node);
85568
+ registerForUnusedIdentifiersCheck(node);
85615
85569
  }
85616
85570
  }
85617
85571
  function checkCollisionWithArgumentsInGeneratedCode(node) {
@@ -86201,7 +86155,7 @@ function createTypeChecker(host) {
86201
86155
  if (node.incrementor) checkExpression(node.incrementor);
86202
86156
  checkSourceElement(node.statement);
86203
86157
  if (node.locals) {
86204
- registerForUnusedOrUninitializedIdentifiersCheck(node);
86158
+ registerForUnusedIdentifiersCheck(node);
86205
86159
  }
86206
86160
  }
86207
86161
  function checkForOfStatement(node) {
@@ -86240,7 +86194,7 @@ function createTypeChecker(host) {
86240
86194
  }
86241
86195
  checkSourceElement(node.statement);
86242
86196
  if (node.locals) {
86243
- registerForUnusedOrUninitializedIdentifiersCheck(node);
86197
+ registerForUnusedIdentifiersCheck(node);
86244
86198
  }
86245
86199
  }
86246
86200
  function checkForInStatement(node) {
@@ -86272,7 +86226,7 @@ function createTypeChecker(host) {
86272
86226
  }
86273
86227
  checkSourceElement(node.statement);
86274
86228
  if (node.locals) {
86275
- registerForUnusedOrUninitializedIdentifiersCheck(node);
86229
+ registerForUnusedIdentifiersCheck(node);
86276
86230
  }
86277
86231
  }
86278
86232
  function checkRightHandSideOfForOf(statement) {
@@ -86958,7 +86912,7 @@ function createTypeChecker(host) {
86958
86912
  }
86959
86913
  });
86960
86914
  if (node.caseBlock.locals) {
86961
- registerForUnusedOrUninitializedIdentifiersCheck(node.caseBlock);
86915
+ registerForUnusedIdentifiersCheck(node.caseBlock);
86962
86916
  }
86963
86917
  }
86964
86918
  function checkLabeledStatement(node) {
@@ -87295,7 +87249,7 @@ function createTypeChecker(host) {
87295
87249
  }
87296
87250
  function checkClassExpressionDeferred(node) {
87297
87251
  forEach(node.members, checkSourceElement);
87298
- registerForUnusedOrUninitializedIdentifiersCheck(node);
87252
+ registerForUnusedIdentifiersCheck(node);
87299
87253
  }
87300
87254
  function checkClassDeclaration(node) {
87301
87255
  const firstDecorator = find(node.modifiers, isDecorator);
@@ -87307,7 +87261,7 @@ function createTypeChecker(host) {
87307
87261
  }
87308
87262
  checkClassLikeDeclaration(node);
87309
87263
  forEach(node.members, checkSourceElement);
87310
- registerForUnusedOrUninitializedIdentifiersCheck(node);
87264
+ registerForUnusedIdentifiersCheck(node);
87311
87265
  }
87312
87266
  function checkClassLikeDeclaration(node) {
87313
87267
  checkGrammarClassLikeDeclaration(node);
@@ -87863,7 +87817,7 @@ function createTypeChecker(host) {
87863
87817
  forEach(node.members, checkSourceElement);
87864
87818
  addLazyDiagnostic(() => {
87865
87819
  checkTypeForDuplicateIndexSignatures(node);
87866
- registerForUnusedOrUninitializedIdentifiersCheck(node);
87820
+ registerForUnusedIdentifiersCheck(node);
87867
87821
  });
87868
87822
  }
87869
87823
  function checkTypeAliasDeclaration(node) {
@@ -87879,7 +87833,7 @@ function createTypeChecker(host) {
87879
87833
  }
87880
87834
  } else {
87881
87835
  checkSourceElement(node.type);
87882
- registerForUnusedOrUninitializedIdentifiersCheck(node);
87836
+ registerForUnusedIdentifiersCheck(node);
87883
87837
  }
87884
87838
  }
87885
87839
  function computeEnumMemberValues(node) {
@@ -88141,7 +88095,7 @@ function createTypeChecker(host) {
88141
88095
  if (node.body) {
88142
88096
  checkSourceElement(node.body);
88143
88097
  if (!isGlobalScopeAugmentation(node)) {
88144
- registerForUnusedOrUninitializedIdentifiersCheck(node);
88098
+ registerForUnusedIdentifiersCheck(node);
88145
88099
  }
88146
88100
  }
88147
88101
  addLazyDiagnostic(checkModuleDeclarationDiagnostics);
@@ -89186,8 +89140,8 @@ function createTypeChecker(host) {
89186
89140
  return Debug.assertNever(kind);
89187
89141
  }
89188
89142
  }
89189
- function getPotentiallyUnusedOrUninitializedIdentifiers(sourceFile) {
89190
- return allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path) || emptyArray;
89143
+ function getPotentiallyUnusedIdentifiers(sourceFile) {
89144
+ return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || emptyArray;
89191
89145
  }
89192
89146
  function checkSourceFileWorker(node) {
89193
89147
  const links = getNodeLinks(node);
@@ -89212,21 +89166,15 @@ function createTypeChecker(host) {
89212
89166
  checkSourceElement(node.endOfFileToken);
89213
89167
  checkDeferredNodes(node);
89214
89168
  if (isExternalOrCommonJsModule(node)) {
89215
- registerForUnusedOrUninitializedIdentifiersCheck(node);
89169
+ registerForUnusedIdentifiersCheck(node);
89216
89170
  }
89217
89171
  addLazyDiagnostic(() => {
89218
- const checkUnused = !node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters);
89219
- if (checkUnused || strictNullChecks) {
89220
- checkUnusedOrUninitializedIdentifiers(
89221
- getPotentiallyUnusedOrUninitializedIdentifiers(node),
89222
- (containingNode, kind, diag2) => {
89223
- if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
89224
- diagnostics.add(diag2);
89225
- }
89226
- },
89227
- checkUnused,
89228
- strictNullChecks
89229
- );
89172
+ if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
89173
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), (containingNode, kind, diag2) => {
89174
+ if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
89175
+ diagnostics.add(diag2);
89176
+ }
89177
+ });
89230
89178
  }
89231
89179
  if (!node.isDeclarationFile) {
89232
89180
  checkPotentialUncheckedRenamedBindingElementsInTypes();
@@ -148243,7 +148191,27 @@ function getInfo4(context) {
148243
148191
  return { error: getLocaleSpecificMessage(Diagnostics.Return_type_must_be_inferred_from_a_function) };
148244
148192
  }
148245
148193
  const typeChecker = context.program.getTypeChecker();
148246
- const returnType = tryGetReturnType(typeChecker, declaration);
148194
+ let returnType;
148195
+ if (typeChecker.isImplementationOfOverload(declaration)) {
148196
+ const signatures = typeChecker.getTypeAtLocation(declaration).getCallSignatures();
148197
+ if (signatures.length > 1) {
148198
+ returnType = typeChecker.getUnionType(mapDefined(signatures, (s) => s.getReturnType()));
148199
+ }
148200
+ }
148201
+ if (!returnType) {
148202
+ const signature = typeChecker.getSignatureFromDeclaration(declaration);
148203
+ if (signature) {
148204
+ const typePredicate = typeChecker.getTypePredicateOfSignature(signature);
148205
+ if (typePredicate && typePredicate.type) {
148206
+ const typePredicateTypeNode = typeChecker.typePredicateToTypePredicateNode(typePredicate, declaration, 1 /* NoTruncation */);
148207
+ if (typePredicateTypeNode) {
148208
+ return { declaration, returnTypeNode: typePredicateTypeNode };
148209
+ }
148210
+ } else {
148211
+ returnType = typeChecker.getReturnTypeOfSignature(signature);
148212
+ }
148213
+ }
148214
+ }
148247
148215
  if (!returnType) {
148248
148216
  return { error: getLocaleSpecificMessage(Diagnostics.Could_not_determine_function_return_type) };
148249
148217
  }
@@ -148263,18 +148231,6 @@ function isConvertibleDeclaration(node) {
148263
148231
  return false;
148264
148232
  }
148265
148233
  }
148266
- function tryGetReturnType(typeChecker, node) {
148267
- if (typeChecker.isImplementationOfOverload(node)) {
148268
- const signatures = typeChecker.getTypeAtLocation(node).getCallSignatures();
148269
- if (signatures.length > 1) {
148270
- return typeChecker.getUnionType(mapDefined(signatures, (s) => s.getReturnType()));
148271
- }
148272
- }
148273
- const signature = typeChecker.getSignatureFromDeclaration(node);
148274
- if (signature) {
148275
- return typeChecker.getReturnTypeOfSignature(signature);
148276
- }
148277
- }
148278
148234
 
148279
148235
  // src/services/classifier2020.ts
148280
148236
  var TokenEncodingConsts = /* @__PURE__ */ ((TokenEncodingConsts2) => {
@@ -150172,6 +150128,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
150172
150128
  synchronizeHostData();
150173
150129
  Debug.assert(args.type === "file");
150174
150130
  const sourceFile = getValidSourceFile(args.fileName);
150131
+ if (containsParseError(sourceFile)) return emptyArray;
150175
150132
  const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
150176
150133
  const mode = args.mode ?? (args.skipDestructiveCodeActions ? "SortAndCombine" /* SortAndCombine */ : "All" /* All */);
150177
150134
  return ts_OrganizeImports_exports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
@@ -151819,6 +151776,7 @@ __export(ts_codefix_exports, {
151819
151776
  setJsonCompilerOptionValue: () => setJsonCompilerOptionValue,
151820
151777
  setJsonCompilerOptionValues: () => setJsonCompilerOptionValues,
151821
151778
  tryGetAutoImportableReferenceFromTypeNode: () => tryGetAutoImportableReferenceFromTypeNode,
151779
+ typePredicateToAutoImportableTypeNode: () => typePredicateToAutoImportableTypeNode,
151822
151780
  typeToAutoImportableTypeNode: () => typeToAutoImportableTypeNode
151823
151781
  });
151824
151782
 
@@ -159905,7 +159863,25 @@ function withContext(context, typePrintMode, cb) {
159905
159863
  if (typePrintMode === 1 /* Relative */) {
159906
159864
  return relativeType(node);
159907
159865
  }
159908
- let type = isValueSignatureDeclaration(node) ? tryGetReturnType2(node) : typeChecker.getTypeAtLocation(node);
159866
+ let type;
159867
+ if (isValueSignatureDeclaration(node)) {
159868
+ const signature = typeChecker.getSignatureFromDeclaration(node);
159869
+ if (signature) {
159870
+ const typePredicate = typeChecker.getTypePredicateOfSignature(signature);
159871
+ if (typePredicate) {
159872
+ if (!typePredicate.type) {
159873
+ return emptyInferenceResult;
159874
+ }
159875
+ return {
159876
+ typeNode: typePredicateToTypeNode(typePredicate, findAncestor(node, isDeclaration) ?? sourceFile, getFlags(typePredicate.type)),
159877
+ mutatedTarget: false
159878
+ };
159879
+ }
159880
+ type = typeChecker.getReturnTypeOfSignature(signature);
159881
+ }
159882
+ } else {
159883
+ type = typeChecker.getTypeAtLocation(node);
159884
+ }
159909
159885
  if (!type) {
159910
159886
  return emptyInferenceResult;
159911
159887
  }
@@ -159922,11 +159898,13 @@ function withContext(context, typePrintMode, cb) {
159922
159898
  if (isParameter(node) && typeChecker.requiresAddingImplicitUndefined(node)) {
159923
159899
  type = typeChecker.getUnionType([typeChecker.getUndefinedType(), type], 0 /* None */);
159924
159900
  }
159925
- const flags = (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type.flags & 8192 /* UniqueESSymbol */ ? 1048576 /* AllowUniqueESSymbolType */ : 0 /* None */;
159926
159901
  return {
159927
- typeNode: typeToTypeNode2(type, findAncestor(node, isDeclaration) ?? sourceFile, flags),
159902
+ typeNode: typeToTypeNode2(type, findAncestor(node, isDeclaration) ?? sourceFile, getFlags(type)),
159928
159903
  mutatedTarget: false
159929
159904
  };
159905
+ function getFlags(type2) {
159906
+ return (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type2.flags & 8192 /* UniqueESSymbol */ ? 1048576 /* AllowUniqueESSymbolType */ : 0 /* None */;
159907
+ }
159930
159908
  }
159931
159909
  function createTypeOfFromEntityNameExpression(node) {
159932
159910
  return factory.createTypeQueryNode(getSynthesizedDeepClone(node));
@@ -160089,11 +160067,18 @@ function withContext(context, typePrintMode, cb) {
160089
160067
  });
160090
160068
  return isTruncated ? factory.createKeywordTypeNode(133 /* AnyKeyword */) : result2;
160091
160069
  }
160092
- function tryGetReturnType2(node) {
160093
- const signature = typeChecker.getSignatureFromDeclaration(node);
160094
- if (signature) {
160095
- return typeChecker.getReturnTypeOfSignature(signature);
160096
- }
160070
+ function typePredicateToTypeNode(typePredicate, enclosingDeclaration, flags = 0 /* None */) {
160071
+ let isTruncated = false;
160072
+ const result2 = typePredicateToAutoImportableTypeNode(typeChecker, importAdder, typePredicate, enclosingDeclaration, scriptTarget, declarationEmitNodeBuilderFlags2 | flags, {
160073
+ moduleResolverHost: program,
160074
+ trackSymbol() {
160075
+ return true;
160076
+ },
160077
+ reportTruncationError() {
160078
+ isTruncated = true;
160079
+ }
160080
+ });
160081
+ return isTruncated ? factory.createKeywordTypeNode(133 /* AnyKeyword */) : result2;
160097
160082
  }
160098
160083
  function addTypeToVariableLike(decl) {
160099
160084
  const { typeNode } = inferType(decl);
@@ -161764,6 +161749,17 @@ function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, s
161764
161749
  }
161765
161750
  return getSynthesizedDeepClone(typeNode);
161766
161751
  }
161752
+ function typePredicateToAutoImportableTypeNode(checker, importAdder, typePredicate, contextNode, scriptTarget, flags, tracker) {
161753
+ let typePredicateNode = checker.typePredicateToTypePredicateNode(typePredicate, contextNode, flags, tracker);
161754
+ if ((typePredicateNode == null ? void 0 : typePredicateNode.type) && isImportTypeNode(typePredicateNode.type)) {
161755
+ const importableReference = tryGetAutoImportableReferenceFromTypeNode(typePredicateNode.type, scriptTarget);
161756
+ if (importableReference) {
161757
+ importSymbols(importAdder, importableReference.symbols);
161758
+ typePredicateNode = factory.updateTypePredicateNode(typePredicateNode, typePredicateNode.assertsModifier, typePredicateNode.parameterName, importableReference.typeNode);
161759
+ }
161760
+ }
161761
+ return getSynthesizedDeepClone(typePredicateNode);
161762
+ }
161767
161763
  function typeContainsTypeParameter(type) {
161768
161764
  if (type.isUnionOrIntersection()) {
161769
161765
  return type.types.some(typeContainsTypeParameter);
@@ -179486,6 +179482,7 @@ __export(ts_exports2, {
179486
179482
  decodeMappings: () => decodeMappings,
179487
179483
  decodedTextSpanIntersectsWith: () => decodedTextSpanIntersectsWith,
179488
179484
  deduplicate: () => deduplicate,
179485
+ defaultInitCompilerOptions: () => defaultInitCompilerOptions,
179489
179486
  defaultMaximumTruncationLength: () => defaultMaximumTruncationLength,
179490
179487
  diagnosticCategoryName: () => diagnosticCategoryName,
179491
179488
  diagnosticToString: () => diagnosticToString,
@@ -183126,7 +183123,7 @@ var Project2 = class _Project {
183126
183123
  }
183127
183124
  fileExists(file) {
183128
183125
  const path = this.toPath(file);
183129
- return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file);
183126
+ return !!this.projectService.getScriptInfoForPath(path) || !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file);
183130
183127
  }
183131
183128
  /** @internal */
183132
183129
  resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
@@ -186150,59 +186147,13 @@ var _ProjectService = class _ProjectService {
186150
186147
  watchWildcardDirectory(directory, flags, configFileName, config) {
186151
186148
  let watcher = this.watchFactory.watchDirectory(
186152
186149
  directory,
186153
- (fileOrDirectory) => {
186154
- const fileOrDirectoryPath = this.toPath(fileOrDirectory);
186155
- const fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
186156
- if (getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) && (fsResult && fsResult.fileExists || !fsResult && this.host.fileExists(fileOrDirectory))) {
186157
- const file = this.getNormalizedAbsolutePath(fileOrDirectory);
186158
- this.logger.info(`Config: ${configFileName} Detected new package.json: ${file}`);
186159
- this.packageJsonCache.addOrUpdate(file, fileOrDirectoryPath);
186160
- this.watchPackageJsonFile(file, fileOrDirectoryPath, result);
186161
- }
186162
- const configuredProjectForConfig = this.findConfiguredProjectByProjectName(configFileName);
186163
- if (isIgnoredFileFromWildCardWatching({
186164
- watchedDirPath: this.toPath(directory),
186165
- fileOrDirectory,
186166
- fileOrDirectoryPath,
186167
- configFileName,
186168
- extraFileExtensions: this.hostConfiguration.extraFileExtensions,
186169
- currentDirectory: this.currentDirectory,
186170
- options: config.parsedCommandLine.options,
186171
- program: (configuredProjectForConfig == null ? void 0 : configuredProjectForConfig.getCurrentProgram()) || config.parsedCommandLine.fileNames,
186172
- useCaseSensitiveFileNames: this.host.useCaseSensitiveFileNames,
186173
- writeLog: (s) => this.logger.info(s),
186174
- toPath: (s) => this.toPath(s),
186175
- getScriptKind: configuredProjectForConfig ? (fileName) => configuredProjectForConfig.getScriptKind(fileName) : void 0
186176
- })) return;
186177
- if (config.updateLevel !== 2 /* Full */) config.updateLevel = 1 /* RootNamesAndUpdate */;
186178
- config.projects.forEach((watchWildcardDirectories, projectCanonicalPath) => {
186179
- var _a;
186180
- if (!watchWildcardDirectories) return;
186181
- const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath);
186182
- if (!project) return;
186183
- if (configuredProjectForConfig !== project && this.getHostPreferences().includeCompletionsForModuleExports) {
186184
- const path = this.toPath(configFileName);
186185
- if (find((_a = project.getCurrentProgram()) == null ? void 0 : _a.getResolvedProjectReferences(), (ref) => (ref == null ? void 0 : ref.sourceFile.path) === path)) {
186186
- project.markAutoImportProviderAsDirty();
186187
- }
186188
- }
186189
- const updateLevel = configuredProjectForConfig === project ? 1 /* RootNamesAndUpdate */ : 0 /* Update */;
186190
- if (project.pendingUpdateLevel > updateLevel) return;
186191
- if (this.openFiles.has(fileOrDirectoryPath)) {
186192
- const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath));
186193
- if (info.isAttached(project)) {
186194
- const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || 0 /* Update */);
186195
- project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet);
186196
- } else {
186197
- project.pendingUpdateLevel = updateLevel;
186198
- this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
186199
- }
186200
- } else {
186201
- project.pendingUpdateLevel = updateLevel;
186202
- this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
186203
- }
186204
- });
186205
- },
186150
+ (fileOrDirectory) => this.onWildCardDirectoryWatcherInvoke(
186151
+ directory,
186152
+ configFileName,
186153
+ config,
186154
+ result,
186155
+ fileOrDirectory
186156
+ ),
186206
186157
  flags,
186207
186158
  this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine.watchOptions, getDirectoryPath(configFileName)),
186208
186159
  WatchType.WildcardDirectory,
@@ -186225,6 +186176,59 @@ var _ProjectService = class _ProjectService {
186225
186176
  };
186226
186177
  return result;
186227
186178
  }
186179
+ onWildCardDirectoryWatcherInvoke(directory, configFileName, config, wildCardWatcher, fileOrDirectory) {
186180
+ const fileOrDirectoryPath = this.toPath(fileOrDirectory);
186181
+ const fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
186182
+ if (getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) && (fsResult && fsResult.fileExists || !fsResult && this.host.fileExists(fileOrDirectory))) {
186183
+ const file = this.getNormalizedAbsolutePath(fileOrDirectory);
186184
+ this.logger.info(`Config: ${configFileName} Detected new package.json: ${file}`);
186185
+ this.packageJsonCache.addOrUpdate(file, fileOrDirectoryPath);
186186
+ this.watchPackageJsonFile(file, fileOrDirectoryPath, wildCardWatcher);
186187
+ }
186188
+ const configuredProjectForConfig = this.findConfiguredProjectByProjectName(configFileName);
186189
+ if (isIgnoredFileFromWildCardWatching({
186190
+ watchedDirPath: this.toPath(directory),
186191
+ fileOrDirectory,
186192
+ fileOrDirectoryPath,
186193
+ configFileName,
186194
+ extraFileExtensions: this.hostConfiguration.extraFileExtensions,
186195
+ currentDirectory: this.currentDirectory,
186196
+ options: config.parsedCommandLine.options,
186197
+ program: (configuredProjectForConfig == null ? void 0 : configuredProjectForConfig.getCurrentProgram()) || config.parsedCommandLine.fileNames,
186198
+ useCaseSensitiveFileNames: this.host.useCaseSensitiveFileNames,
186199
+ writeLog: (s) => this.logger.info(s),
186200
+ toPath: (s) => this.toPath(s),
186201
+ getScriptKind: configuredProjectForConfig ? (fileName) => configuredProjectForConfig.getScriptKind(fileName) : void 0
186202
+ })) return;
186203
+ if (config.updateLevel !== 2 /* Full */) config.updateLevel = 1 /* RootNamesAndUpdate */;
186204
+ config.projects.forEach((watchWildcardDirectories, projectCanonicalPath) => {
186205
+ var _a;
186206
+ if (!watchWildcardDirectories) return;
186207
+ const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath);
186208
+ if (!project) return;
186209
+ if (configuredProjectForConfig !== project && this.getHostPreferences().includeCompletionsForModuleExports) {
186210
+ const path = this.toPath(configFileName);
186211
+ if (find((_a = project.getCurrentProgram()) == null ? void 0 : _a.getResolvedProjectReferences(), (ref) => (ref == null ? void 0 : ref.sourceFile.path) === path)) {
186212
+ project.markAutoImportProviderAsDirty();
186213
+ }
186214
+ }
186215
+ const updateLevel = configuredProjectForConfig === project ? 1 /* RootNamesAndUpdate */ : 0 /* Update */;
186216
+ if (project.pendingUpdateLevel > updateLevel) return;
186217
+ if (this.openFiles.has(fileOrDirectoryPath)) {
186218
+ const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath));
186219
+ if (info.isAttached(project)) {
186220
+ const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || 0 /* Update */);
186221
+ project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet);
186222
+ } else {
186223
+ project.pendingUpdateLevel = updateLevel;
186224
+ this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
186225
+ }
186226
+ } else {
186227
+ project.pendingUpdateLevel = updateLevel;
186228
+ this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
186229
+ }
186230
+ });
186231
+ }
186228
186232
  delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath, loadReason) {
186229
186233
  const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
186230
186234
  if (!(configFileExistenceInfo == null ? void 0 : configFileExistenceInfo.config)) return false;
@@ -188141,8 +188145,38 @@ Dynamic files must always be opened with service's current directory or service
188141
188145
  }
188142
188146
  this.removeOrphanScriptInfos();
188143
188147
  }
188148
+ tryInvokeWildCardDirectories(info) {
188149
+ this.configFileExistenceInfoCache.forEach((configFileExistenceInfo, config) => {
188150
+ var _a, _b;
188151
+ if (!((_a = configFileExistenceInfo.config) == null ? void 0 : _a.parsedCommandLine) || contains(
188152
+ configFileExistenceInfo.config.parsedCommandLine.fileNames,
188153
+ info.fileName,
188154
+ !this.host.useCaseSensitiveFileNames ? equateStringsCaseInsensitive : equateStringsCaseSensitive
188155
+ )) {
188156
+ return;
188157
+ }
188158
+ (_b = configFileExistenceInfo.config.watchedDirectories) == null ? void 0 : _b.forEach((watcher, directory) => {
188159
+ if (containsPath(directory, info.fileName, !this.host.useCaseSensitiveFileNames)) {
188160
+ this.logger.info(`Invoking ${config}:: wildcard for open scriptInfo:: ${info.fileName}`);
188161
+ this.onWildCardDirectoryWatcherInvoke(
188162
+ directory,
188163
+ config,
188164
+ configFileExistenceInfo.config,
188165
+ watcher.watcher,
188166
+ info.fileName
188167
+ );
188168
+ }
188169
+ });
188170
+ });
188171
+ }
188144
188172
  openClientFileWithNormalizedPath(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) {
188173
+ const existing = this.getScriptInfoForPath(normalizedPathToPath(
188174
+ fileName,
188175
+ projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory,
188176
+ this.toCanonicalFileName
188177
+ ));
188145
188178
  const info = this.getOrCreateOpenScriptInfo(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath);
188179
+ if (!existing && info && !info.isDynamic) this.tryInvokeWildCardDirectories(info);
188146
188180
  const { retainProjects, ...result } = this.assignProjectToOpenedScriptInfo(info);
188147
188181
  this.cleanupProjectsAndScriptInfos(
188148
188182
  retainProjects,
@@ -188289,10 +188323,16 @@ Dynamic files must always be opened with service's current directory or service
188289
188323
  }
188290
188324
  /** @internal */
188291
188325
  applyChangesInOpenFiles(openFiles, changedFiles, closedFiles) {
188326
+ let existingOpenScriptInfos;
188292
188327
  let openScriptInfos;
188293
188328
  let assignOrphanScriptInfosToInferredProject = false;
188294
188329
  if (openFiles) {
188295
188330
  for (const file of openFiles) {
188331
+ (existingOpenScriptInfos ?? (existingOpenScriptInfos = [])).push(this.getScriptInfoForPath(normalizedPathToPath(
188332
+ toNormalizedPath(file.fileName),
188333
+ file.projectRootPath ? this.getNormalizedAbsolutePath(file.projectRootPath) : this.currentDirectory,
188334
+ this.toCanonicalFileName
188335
+ )));
188296
188336
  const info = this.getOrCreateOpenScriptInfo(
188297
188337
  toNormalizedPath(file.fileName),
188298
188338
  file.content,
@@ -188320,6 +188360,10 @@ Dynamic files must always be opened with service's current directory or service
188320
188360
  }
188321
188361
  }
188322
188362
  let retainProjects;
188363
+ forEach(
188364
+ existingOpenScriptInfos,
188365
+ (existing, index) => !existing && openScriptInfos[index] && !openScriptInfos[index].isDynamic ? this.tryInvokeWildCardDirectories(openScriptInfos[index]) : void 0
188366
+ );
188323
188367
  openScriptInfos == null ? void 0 : openScriptInfos.forEach((info) => {
188324
188368
  var _a;
188325
188369
  return (_a = this.assignProjectToOpenedScriptInfo(info).retainProjects) == null ? void 0 : _a.forEach((p) => (retainProjects ?? (retainProjects = /* @__PURE__ */ new Set())).add(p));
@@ -193823,6 +193867,7 @@ if (typeof console !== "undefined") {
193823
193867
  decodeMappings,
193824
193868
  decodedTextSpanIntersectsWith,
193825
193869
  deduplicate,
193870
+ defaultInitCompilerOptions,
193826
193871
  defaultMaximumTruncationLength,
193827
193872
  diagnosticCategoryName,
193828
193873
  diagnosticToString,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.6.0-pr-55887-49",
5
+ "version": "5.6.0-pr-59436-2",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [