@typescript-deploys/pr-build 5.4.0-pr-57358-23 → 5.4.0-pr-57116-10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.4";
21
- var version = `${versionMajorMinor}.0-insiders.20240213`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240215`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -32496,7 +32496,7 @@ var Parser;
32496
32496
  if (!jsDocDiagnostics) {
32497
32497
  jsDocDiagnostics = [];
32498
32498
  }
32499
- jsDocDiagnostics.push(...parseDiagnostics);
32499
+ addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
32500
32500
  }
32501
32501
  currentToken = saveToken;
32502
32502
  parseDiagnostics.length = saveParseDiagnosticsLength;
@@ -57358,7 +57358,7 @@ function createTypeChecker(host) {
57358
57358
  return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments);
57359
57359
  }
57360
57360
  function createNormalizedTupleType(target, elementTypes) {
57361
- var _a, _b, _c;
57361
+ var _a, _b, _c, _d;
57362
57362
  if (!(target.combinedFlags & 14 /* NonRequired */)) {
57363
57363
  return createTypeReference(target, elementTypes);
57364
57364
  }
@@ -57378,8 +57378,10 @@ function createTypeChecker(host) {
57378
57378
  const type = elementTypes[i];
57379
57379
  const flags = target.elementFlags[i];
57380
57380
  if (flags & 8 /* Variadic */) {
57381
- if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
57382
- addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
57381
+ if (type.flags & 1 /* Any */) {
57382
+ addElement(type, 4 /* Rest */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
57383
+ } else if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
57384
+ addElement(type, 8 /* Variadic */, (_b = target.labeledElementDeclarations) == null ? void 0 : _b[i]);
57383
57385
  } else if (isTupleType(type)) {
57384
57386
  const elements = getElementTypes(type);
57385
57387
  if (elements.length + expandedTypes.length >= 1e4) {
@@ -57394,10 +57396,10 @@ function createTypeChecker(host) {
57394
57396
  return addElement(t, type.target.elementFlags[n], (_a2 = type.target.labeledElementDeclarations) == null ? void 0 : _a2[n]);
57395
57397
  });
57396
57398
  } else {
57397
- addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) == null ? void 0 : _b[i]);
57399
+ addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_c = target.labeledElementDeclarations) == null ? void 0 : _c[i]);
57398
57400
  }
57399
57401
  } else {
57400
- addElement(type, flags, (_c = target.labeledElementDeclarations) == null ? void 0 : _c[i]);
57402
+ addElement(type, flags, (_d = target.labeledElementDeclarations) == null ? void 0 : _d[i]);
57401
57403
  }
57402
57404
  }
57403
57405
  for (let i = 0; i < lastRequiredIndex; i++) {
@@ -65650,7 +65652,7 @@ function createTypeChecker(host) {
65650
65652
  function hasMatchingArgument(expression, reference) {
65651
65653
  if (expression.arguments) {
65652
65654
  for (const argument of expression.arguments) {
65653
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
65655
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
65654
65656
  return true;
65655
65657
  }
65656
65658
  }
@@ -65660,6 +65662,36 @@ function createTypeChecker(host) {
65660
65662
  }
65661
65663
  return false;
65662
65664
  }
65665
+ function getCandidateDiscriminantPropertyAccess(expr, reference) {
65666
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
65667
+ if (isIdentifier(expr)) {
65668
+ const symbol = getResolvedSymbol(expr);
65669
+ const declaration = symbol.valueDeclaration;
65670
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
65671
+ return declaration;
65672
+ }
65673
+ }
65674
+ } else if (isAccessExpression(expr)) {
65675
+ if (isMatchingReference(reference, expr.expression)) {
65676
+ return expr;
65677
+ }
65678
+ } else if (isIdentifier(expr)) {
65679
+ const symbol = getResolvedSymbol(expr);
65680
+ if (isConstantVariable(symbol)) {
65681
+ const declaration = symbol.valueDeclaration;
65682
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
65683
+ return declaration.initializer;
65684
+ }
65685
+ if (isBindingElement(declaration) && !declaration.initializer) {
65686
+ const parent = declaration.parent.parent;
65687
+ if (isVariableDeclaration(parent) && !parent.type && parent.initializer && (isIdentifier(parent.initializer) || isAccessExpression(parent.initializer)) && isMatchingReference(reference, parent.initializer)) {
65688
+ return declaration;
65689
+ }
65690
+ }
65691
+ }
65692
+ }
65693
+ return void 0;
65694
+ }
65663
65695
  function getFlowNodeId(flow) {
65664
65696
  if (!flow.id || flow.id < 0) {
65665
65697
  flow.id = nextFlowId;
@@ -66759,39 +66791,9 @@ function createTypeChecker(host) {
66759
66791
  }
66760
66792
  return result;
66761
66793
  }
66762
- function getCandidateDiscriminantPropertyAccess(expr) {
66763
- if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
66764
- if (isIdentifier(expr)) {
66765
- const symbol = getResolvedSymbol(expr);
66766
- const declaration = symbol.valueDeclaration;
66767
- if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
66768
- return declaration;
66769
- }
66770
- }
66771
- } else if (isAccessExpression(expr)) {
66772
- if (isMatchingReference(reference, expr.expression)) {
66773
- return expr;
66774
- }
66775
- } else if (isIdentifier(expr)) {
66776
- const symbol = getResolvedSymbol(expr);
66777
- if (isConstantVariable(symbol)) {
66778
- const declaration = symbol.valueDeclaration;
66779
- if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
66780
- return declaration.initializer;
66781
- }
66782
- if (isBindingElement(declaration) && !declaration.initializer) {
66783
- const parent = declaration.parent.parent;
66784
- if (isVariableDeclaration(parent) && !parent.type && parent.initializer && (isIdentifier(parent.initializer) || isAccessExpression(parent.initializer)) && isMatchingReference(reference, parent.initializer)) {
66785
- return declaration;
66786
- }
66787
- }
66788
- }
66789
- }
66790
- return void 0;
66791
- }
66792
66794
  function getDiscriminantPropertyAccess(expr, computedType) {
66793
66795
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
66794
- const access = getCandidateDiscriminantPropertyAccess(expr);
66796
+ const access = getCandidateDiscriminantPropertyAccess(expr, reference);
66795
66797
  if (access) {
66796
66798
  const name = getAccessedPropertyName(access);
66797
66799
  if (name) {
@@ -67337,10 +67339,12 @@ function createTypeChecker(host) {
67337
67339
  return !(narrowedType.flags & 131072 /* Never */) ? narrowedType : isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]);
67338
67340
  }
67339
67341
  function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
67340
- const signature = assumeTrue || !isCallChain(callExpression) ? getEffectsSignature(callExpression) : void 0;
67341
- const predicate = signature && getTypePredicateOfSignature(signature);
67342
- if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
67343
- return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
67342
+ if (hasMatchingArgument(callExpression, reference)) {
67343
+ const signature = assumeTrue || !isCallChain(callExpression) ? getEffectsSignature(callExpression) : void 0;
67344
+ const predicate = signature && getTypePredicateOfSignature(signature);
67345
+ if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
67346
+ return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
67347
+ }
67344
67348
  }
67345
67349
  if (containsMissingType(type) && isAccessExpression(reference) && isPropertyAccessExpression(callExpression.expression)) {
67346
67350
  const callAccess = callExpression.expression;
package/lib/tsserver.js CHANGED
@@ -2340,7 +2340,7 @@ module.exports = __toCommonJS(server_exports);
2340
2340
 
2341
2341
  // src/compiler/corePublic.ts
2342
2342
  var versionMajorMinor = "5.4";
2343
- var version = `${versionMajorMinor}.0-insiders.20240213`;
2343
+ var version = `${versionMajorMinor}.0-insiders.20240215`;
2344
2344
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2345
2345
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2346
2346
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -36931,7 +36931,7 @@ var Parser;
36931
36931
  if (!jsDocDiagnostics) {
36932
36932
  jsDocDiagnostics = [];
36933
36933
  }
36934
- jsDocDiagnostics.push(...parseDiagnostics);
36934
+ addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
36935
36935
  }
36936
36936
  currentToken = saveToken;
36937
36937
  parseDiagnostics.length = saveParseDiagnosticsLength;
@@ -62102,7 +62102,7 @@ function createTypeChecker(host) {
62102
62102
  return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments);
62103
62103
  }
62104
62104
  function createNormalizedTupleType(target, elementTypes) {
62105
- var _a, _b, _c;
62105
+ var _a, _b, _c, _d;
62106
62106
  if (!(target.combinedFlags & 14 /* NonRequired */)) {
62107
62107
  return createTypeReference(target, elementTypes);
62108
62108
  }
@@ -62122,8 +62122,10 @@ function createTypeChecker(host) {
62122
62122
  const type = elementTypes[i];
62123
62123
  const flags = target.elementFlags[i];
62124
62124
  if (flags & 8 /* Variadic */) {
62125
- if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
62126
- addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
62125
+ if (type.flags & 1 /* Any */) {
62126
+ addElement(type, 4 /* Rest */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
62127
+ } else if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
62128
+ addElement(type, 8 /* Variadic */, (_b = target.labeledElementDeclarations) == null ? void 0 : _b[i]);
62127
62129
  } else if (isTupleType(type)) {
62128
62130
  const elements = getElementTypes(type);
62129
62131
  if (elements.length + expandedTypes.length >= 1e4) {
@@ -62138,10 +62140,10 @@ function createTypeChecker(host) {
62138
62140
  return addElement(t, type.target.elementFlags[n], (_a2 = type.target.labeledElementDeclarations) == null ? void 0 : _a2[n]);
62139
62141
  });
62140
62142
  } else {
62141
- addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) == null ? void 0 : _b[i]);
62143
+ addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_c = target.labeledElementDeclarations) == null ? void 0 : _c[i]);
62142
62144
  }
62143
62145
  } else {
62144
- addElement(type, flags, (_c = target.labeledElementDeclarations) == null ? void 0 : _c[i]);
62146
+ addElement(type, flags, (_d = target.labeledElementDeclarations) == null ? void 0 : _d[i]);
62145
62147
  }
62146
62148
  }
62147
62149
  for (let i = 0; i < lastRequiredIndex; i++) {
@@ -70394,7 +70396,7 @@ function createTypeChecker(host) {
70394
70396
  function hasMatchingArgument(expression, reference) {
70395
70397
  if (expression.arguments) {
70396
70398
  for (const argument of expression.arguments) {
70397
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
70399
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
70398
70400
  return true;
70399
70401
  }
70400
70402
  }
@@ -70404,6 +70406,36 @@ function createTypeChecker(host) {
70404
70406
  }
70405
70407
  return false;
70406
70408
  }
70409
+ function getCandidateDiscriminantPropertyAccess(expr, reference) {
70410
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
70411
+ if (isIdentifier(expr)) {
70412
+ const symbol = getResolvedSymbol(expr);
70413
+ const declaration = symbol.valueDeclaration;
70414
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
70415
+ return declaration;
70416
+ }
70417
+ }
70418
+ } else if (isAccessExpression(expr)) {
70419
+ if (isMatchingReference(reference, expr.expression)) {
70420
+ return expr;
70421
+ }
70422
+ } else if (isIdentifier(expr)) {
70423
+ const symbol = getResolvedSymbol(expr);
70424
+ if (isConstantVariable(symbol)) {
70425
+ const declaration = symbol.valueDeclaration;
70426
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
70427
+ return declaration.initializer;
70428
+ }
70429
+ if (isBindingElement(declaration) && !declaration.initializer) {
70430
+ const parent2 = declaration.parent.parent;
70431
+ if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
70432
+ return declaration;
70433
+ }
70434
+ }
70435
+ }
70436
+ }
70437
+ return void 0;
70438
+ }
70407
70439
  function getFlowNodeId(flow) {
70408
70440
  if (!flow.id || flow.id < 0) {
70409
70441
  flow.id = nextFlowId;
@@ -71503,39 +71535,9 @@ function createTypeChecker(host) {
71503
71535
  }
71504
71536
  return result;
71505
71537
  }
71506
- function getCandidateDiscriminantPropertyAccess(expr) {
71507
- if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
71508
- if (isIdentifier(expr)) {
71509
- const symbol = getResolvedSymbol(expr);
71510
- const declaration = symbol.valueDeclaration;
71511
- if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
71512
- return declaration;
71513
- }
71514
- }
71515
- } else if (isAccessExpression(expr)) {
71516
- if (isMatchingReference(reference, expr.expression)) {
71517
- return expr;
71518
- }
71519
- } else if (isIdentifier(expr)) {
71520
- const symbol = getResolvedSymbol(expr);
71521
- if (isConstantVariable(symbol)) {
71522
- const declaration = symbol.valueDeclaration;
71523
- if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
71524
- return declaration.initializer;
71525
- }
71526
- if (isBindingElement(declaration) && !declaration.initializer) {
71527
- const parent2 = declaration.parent.parent;
71528
- if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
71529
- return declaration;
71530
- }
71531
- }
71532
- }
71533
- }
71534
- return void 0;
71535
- }
71536
71538
  function getDiscriminantPropertyAccess(expr, computedType) {
71537
71539
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
71538
- const access = getCandidateDiscriminantPropertyAccess(expr);
71540
+ const access = getCandidateDiscriminantPropertyAccess(expr, reference);
71539
71541
  if (access) {
71540
71542
  const name = getAccessedPropertyName(access);
71541
71543
  if (name) {
@@ -72081,10 +72083,12 @@ function createTypeChecker(host) {
72081
72083
  return !(narrowedType.flags & 131072 /* Never */) ? narrowedType : isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]);
72082
72084
  }
72083
72085
  function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
72084
- const signature = assumeTrue || !isCallChain(callExpression) ? getEffectsSignature(callExpression) : void 0;
72085
- const predicate = signature && getTypePredicateOfSignature(signature);
72086
- if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
72087
- return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
72086
+ if (hasMatchingArgument(callExpression, reference)) {
72087
+ const signature = assumeTrue || !isCallChain(callExpression) ? getEffectsSignature(callExpression) : void 0;
72088
+ const predicate = signature && getTypePredicateOfSignature(signature);
72089
+ if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
72090
+ return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
72091
+ }
72088
72092
  }
72089
72093
  if (containsMissingType(type) && isAccessExpression(reference) && isPropertyAccessExpression(callExpression.expression)) {
72090
72094
  const callAccess = callExpression.expression;
@@ -178157,7 +178161,7 @@ var ScriptInfo = class {
178157
178161
  }
178158
178162
  break;
178159
178163
  default:
178160
- if (unorderedRemoveItem(this.containingProjects, project)) {
178164
+ if (orderedRemoveItem(this.containingProjects, project)) {
178161
178165
  project.onFileAddedOrRemoved(this.isSymlink());
178162
178166
  }
178163
178167
  break;
@@ -181829,7 +181833,7 @@ var _ProjectService = class _ProjectService {
181829
181833
  );
181830
181834
  project.addRoot(info);
181831
181835
  if (info.containingProjects[0] !== project) {
181832
- info.detachFromProject(project);
181836
+ orderedRemoveItem(info.containingProjects, project);
181833
181837
  info.containingProjects.unshift(project);
181834
181838
  }
181835
181839
  project.updateGraph();
@@ -182124,8 +182128,7 @@ var _ProjectService = class _ProjectService {
182124
182128
  * otherwise just file name
182125
182129
  */
182126
182130
  getConfigFileNameForFile(info) {
182127
- if (isOpenScriptInfo(info)) {
182128
- Debug.assert(info.isScriptOpen());
182131
+ if (!isAncestorConfigFileInfo(info)) {
182129
182132
  const result = this.configFileForOpenFiles.get(info.path);
182130
182133
  if (result !== void 0)
182131
182134
  return result || void 0;
@@ -183120,11 +183123,13 @@ Dynamic files must always be opened with service's current directory or service
183120
183123
  } = this.hostConfiguration.preferences;
183121
183124
  this.hostConfiguration.preferences = { ...this.hostConfiguration.preferences, ...args.preferences };
183122
183125
  if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) {
183123
- this.configuredProjects.forEach((project) => {
183124
- if (project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) {
183125
- project.updateGraph();
183126
- }
183127
- });
183126
+ this.externalProjectToConfiguredProjectMap.forEach(
183127
+ (projects) => projects.forEach((project) => {
183128
+ if (!project.isClosed() && project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) {
183129
+ project.updateGraph();
183130
+ }
183131
+ })
183132
+ );
183128
183133
  }
183129
183134
  if (includePackageJsonAutoImports !== args.preferences.includePackageJsonAutoImports) {
183130
183135
  this.forEachProject((project) => {
@@ -183709,23 +183714,20 @@ Dynamic files must always be opened with service's current directory or service
183709
183714
  scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText);
183710
183715
  }
183711
183716
  }
183712
- closeConfiguredProjectReferencedFromExternalProject(configFile) {
183713
- const configuredProject = this.findConfiguredProjectByProjectName(configFile);
183714
- if (configuredProject) {
183715
- configuredProject.deleteExternalProjectReference();
183716
- if (!configuredProject.hasOpenRef()) {
183717
- this.removeProject(configuredProject);
183718
- return;
183717
+ closeConfiguredProjectReferencedFromExternalProject(configuredProjects) {
183718
+ configuredProjects == null ? void 0 : configuredProjects.forEach((configuredProject) => {
183719
+ if (!configuredProject.isClosed()) {
183720
+ configuredProject.deleteExternalProjectReference();
183721
+ if (!configuredProject.hasOpenRef())
183722
+ this.removeProject(configuredProject);
183719
183723
  }
183720
- }
183724
+ });
183721
183725
  }
183722
183726
  closeExternalProject(uncheckedFileName, print) {
183723
183727
  const fileName = toNormalizedPath(uncheckedFileName);
183724
- const configFiles = this.externalProjectToConfiguredProjectMap.get(fileName);
183725
- if (configFiles) {
183726
- for (const configFile of configFiles) {
183727
- this.closeConfiguredProjectReferencedFromExternalProject(configFile);
183728
- }
183728
+ const configuredProjects = this.externalProjectToConfiguredProjectMap.get(fileName);
183729
+ if (configuredProjects) {
183730
+ this.closeConfiguredProjectReferencedFromExternalProject(configuredProjects);
183729
183731
  this.externalProjectToConfiguredProjectMap.delete(fileName);
183730
183732
  } else {
183731
183733
  const externalProject = this.findExternalProjectByProjectName(uncheckedFileName);
@@ -183765,16 +183767,18 @@ Dynamic files must always be opened with service's current directory or service
183765
183767
  this.safelist = defaultTypeSafeList;
183766
183768
  }
183767
183769
  applySafeList(proj) {
183768
- const { rootFiles } = proj;
183769
183770
  const typeAcquisition = proj.typeAcquisition;
183770
183771
  Debug.assert(!!typeAcquisition, "proj.typeAcquisition should be set by now");
183772
+ const result = this.applySafeListWorker(proj, proj.rootFiles, typeAcquisition);
183773
+ return (result == null ? void 0 : result.excludedFiles) ?? [];
183774
+ }
183775
+ applySafeListWorker(proj, rootFiles, typeAcquisition) {
183771
183776
  if (typeAcquisition.enable === false || typeAcquisition.disableFilenameBasedTypeAcquisition) {
183772
- return [];
183777
+ return void 0;
183773
183778
  }
183774
183779
  const typeAcqInclude = typeAcquisition.include || (typeAcquisition.include = []);
183775
183780
  const excludeRules = [];
183776
183781
  const normalizedNames = rootFiles.map((f) => normalizeSlashes(f.fileName));
183777
- const excludedFiles = [];
183778
183782
  for (const name of Object.keys(this.safelist)) {
183779
183783
  const rule2 = this.safelist[name];
183780
183784
  for (const root of normalizedNames) {
@@ -183815,12 +183819,12 @@ Dynamic files must always be opened with service's current directory or service
183815
183819
  }
183816
183820
  }
183817
183821
  const excludeRegexes = excludeRules.map((e) => new RegExp(e, "i"));
183818
- const filesToKeep = [];
183819
- for (let i = 0; i < proj.rootFiles.length; i++) {
183822
+ let filesToKeep;
183823
+ let excludedFiles;
183824
+ for (let i = 0; i < rootFiles.length; i++) {
183820
183825
  if (excludeRegexes.some((re) => re.test(normalizedNames[i]))) {
183821
- excludedFiles.push(normalizedNames[i]);
183826
+ addExcludedFile(i);
183822
183827
  } else {
183823
- let exclude = false;
183824
183828
  if (typeAcquisition.enable) {
183825
183829
  const baseName = getBaseFileName(toFileNameLowerCase(normalizedNames[i]));
183826
183830
  if (fileExtensionIs(baseName, "js")) {
@@ -183829,120 +183833,91 @@ Dynamic files must always be opened with service's current directory or service
183829
183833
  const typeName = this.legacySafelist.get(cleanedTypingName);
183830
183834
  if (typeName !== void 0) {
183831
183835
  this.logger.info(`Excluded '${normalizedNames[i]}' because it matched ${cleanedTypingName} from the legacy safelist`);
183832
- excludedFiles.push(normalizedNames[i]);
183833
- exclude = true;
183836
+ addExcludedFile(i);
183834
183837
  if (!typeAcqInclude.includes(typeName)) {
183835
183838
  typeAcqInclude.push(typeName);
183836
183839
  }
183840
+ continue;
183837
183841
  }
183838
183842
  }
183839
183843
  }
183840
- if (!exclude) {
183841
- if (/^.+[.-]min\.js$/.test(normalizedNames[i])) {
183842
- excludedFiles.push(normalizedNames[i]);
183843
- } else {
183844
- filesToKeep.push(proj.rootFiles[i]);
183845
- }
183844
+ if (/^.+[.-]min\.js$/.test(normalizedNames[i])) {
183845
+ addExcludedFile(i);
183846
+ } else {
183847
+ filesToKeep == null ? void 0 : filesToKeep.push(rootFiles[i]);
183846
183848
  }
183847
183849
  }
183848
183850
  }
183849
- proj.rootFiles = filesToKeep;
183850
- return excludedFiles;
183851
+ return excludedFiles ? {
183852
+ rootFiles: filesToKeep,
183853
+ excludedFiles
183854
+ } : void 0;
183855
+ function addExcludedFile(index) {
183856
+ if (!excludedFiles) {
183857
+ Debug.assert(!filesToKeep);
183858
+ filesToKeep = rootFiles.slice(0, index);
183859
+ excludedFiles = [];
183860
+ }
183861
+ excludedFiles.push(normalizedNames[index]);
183862
+ }
183851
183863
  }
183852
183864
  openExternalProject(proj, print) {
183853
- proj.typeAcquisition = proj.typeAcquisition || {};
183854
- proj.typeAcquisition.include = proj.typeAcquisition.include || [];
183855
- proj.typeAcquisition.exclude = proj.typeAcquisition.exclude || [];
183856
- if (proj.typeAcquisition.enable === void 0) {
183857
- proj.typeAcquisition.enable = hasNoTypeScriptSource(proj.rootFiles.map((f) => f.fileName));
183858
- }
183859
- const excludedFiles = this.applySafeList(proj);
183860
- let tsConfigFiles;
183861
- const rootFiles = [];
183865
+ const existingExternalProject = this.findExternalProjectByProjectName(proj.projectFileName);
183866
+ const existingConfiguredProjects = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
183867
+ let configuredProjects;
183868
+ let rootFiles = [];
183862
183869
  for (const file of proj.rootFiles) {
183863
183870
  const normalized = toNormalizedPath(file.fileName);
183864
183871
  if (getBaseConfigFileName(normalized)) {
183865
183872
  if (this.serverMode === 0 /* Semantic */ && this.host.fileExists(normalized)) {
183866
- (tsConfigFiles || (tsConfigFiles = [])).push(normalized);
183873
+ let project = this.findConfiguredProjectByProjectName(normalized);
183874
+ if (!project) {
183875
+ project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? this.createConfiguredProjectWithDelayLoad(normalized, `Creating configured project in external project: ${proj.projectFileName}`) : this.createLoadAndUpdateConfiguredProject(normalized, `Creating configured project in external project: ${proj.projectFileName}`);
183876
+ }
183877
+ if (!(existingConfiguredProjects == null ? void 0 : existingConfiguredProjects.has(project))) {
183878
+ project.addExternalProjectReference();
183879
+ }
183880
+ (configuredProjects ?? (configuredProjects = /* @__PURE__ */ new Set())).add(project);
183881
+ existingConfiguredProjects == null ? void 0 : existingConfiguredProjects.delete(project);
183867
183882
  }
183868
183883
  } else {
183869
183884
  rootFiles.push(file);
183870
183885
  }
183871
183886
  }
183872
- if (tsConfigFiles) {
183873
- tsConfigFiles.sort();
183874
- }
183875
- const externalProject = this.findExternalProjectByProjectName(proj.projectFileName);
183876
- let exisingConfigFiles;
183877
- if (externalProject) {
183878
- externalProject.excludedFiles = excludedFiles;
183879
- if (!tsConfigFiles) {
183887
+ if (configuredProjects) {
183888
+ this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, configuredProjects);
183889
+ if (existingExternalProject)
183890
+ this.removeProject(existingExternalProject);
183891
+ } else {
183892
+ this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
183893
+ const typeAcquisition = proj.typeAcquisition || {};
183894
+ typeAcquisition.include = typeAcquisition.include || [];
183895
+ typeAcquisition.exclude = typeAcquisition.exclude || [];
183896
+ if (typeAcquisition.enable === void 0) {
183897
+ typeAcquisition.enable = hasNoTypeScriptSource(rootFiles.map((f) => f.fileName));
183898
+ }
183899
+ const excludeResult = this.applySafeListWorker(proj, rootFiles, typeAcquisition);
183900
+ const excludedFiles = (excludeResult == null ? void 0 : excludeResult.excludedFiles) ?? [];
183901
+ rootFiles = (excludeResult == null ? void 0 : excludeResult.rootFiles) ?? rootFiles;
183902
+ if (existingExternalProject) {
183903
+ existingExternalProject.excludedFiles = excludedFiles;
183880
183904
  const compilerOptions = convertCompilerOptions(proj.options);
183881
- const watchOptionsAndErrors = convertWatchOptions(proj.options, externalProject.getCurrentDirectory());
183882
- const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader);
183905
+ const watchOptionsAndErrors = convertWatchOptions(proj.options, existingExternalProject.getCurrentDirectory());
183906
+ const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, rootFiles, externalFilePropertyReader);
183883
183907
  if (lastFileExceededProgramSize) {
183884
- externalProject.disableLanguageService(lastFileExceededProgramSize);
183908
+ existingExternalProject.disableLanguageService(lastFileExceededProgramSize);
183885
183909
  } else {
183886
- externalProject.enableLanguageService();
183910
+ existingExternalProject.enableLanguageService();
183887
183911
  }
183888
- externalProject.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
183889
- this.updateRootAndOptionsOfNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions);
183890
- externalProject.updateGraph();
183891
- if (print)
183892
- this.printProjects();
183893
- return;
183894
- }
183895
- this.closeExternalProject(
183896
- proj.projectFileName,
183897
- /*print*/
183898
- false
183899
- );
183900
- } else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) {
183901
- if (!tsConfigFiles) {
183902
- this.closeExternalProject(
183903
- proj.projectFileName,
183904
- /*print*/
183905
- false
183906
- );
183912
+ existingExternalProject.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
183913
+ this.updateRootAndOptionsOfNonInferredProject(existingExternalProject, rootFiles, externalFilePropertyReader, compilerOptions, typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions);
183914
+ existingExternalProject.updateGraph();
183907
183915
  } else {
183908
- const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
183909
- let iNew = 0;
183910
- let iOld = 0;
183911
- while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) {
183912
- const newConfig = tsConfigFiles[iNew];
183913
- const oldConfig = oldConfigFiles[iOld];
183914
- if (oldConfig < newConfig) {
183915
- this.closeConfiguredProjectReferencedFromExternalProject(oldConfig);
183916
- iOld++;
183917
- } else if (oldConfig > newConfig) {
183918
- iNew++;
183919
- } else {
183920
- (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig);
183921
- iOld++;
183922
- iNew++;
183923
- }
183924
- }
183925
- for (let i = iOld; i < oldConfigFiles.length; i++) {
183926
- this.closeConfiguredProjectReferencedFromExternalProject(oldConfigFiles[i]);
183927
- }
183916
+ const project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, typeAcquisition, excludedFiles);
183917
+ project.updateGraph();
183928
183918
  }
183929
183919
  }
183930
- if (tsConfigFiles) {
183931
- this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles);
183932
- for (const tsconfigFile of tsConfigFiles) {
183933
- let project = this.findConfiguredProjectByProjectName(tsconfigFile);
183934
- if (!project) {
183935
- project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? this.createConfiguredProjectWithDelayLoad(tsconfigFile, `Creating configured project in external project: ${proj.projectFileName}`) : this.createLoadAndUpdateConfiguredProject(tsconfigFile, `Creating configured project in external project: ${proj.projectFileName}`);
183936
- }
183937
- if (project && !contains(exisingConfigFiles, tsconfigFile)) {
183938
- project.addExternalProjectReference();
183939
- }
183940
- }
183941
- } else {
183942
- this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
183943
- const project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition, excludedFiles);
183944
- project.updateGraph();
183945
- }
183920
+ this.closeConfiguredProjectReferencedFromExternalProject(existingConfiguredProjects);
183946
183921
  if (print)
183947
183922
  this.printProjects();
183948
183923
  }
@@ -3906,6 +3906,7 @@ declare namespace ts {
3906
3906
  private static escapeFilenameForRegex;
3907
3907
  resetSafeList(): void;
3908
3908
  applySafeList(proj: protocol.ExternalProject): NormalizedPath[];
3909
+ private applySafeListWorker;
3909
3910
  openExternalProject(proj: protocol.ExternalProject): void;
3910
3911
  hasDeferredExtension(): boolean;
3911
3912
  private enableRequestedPluginsAsync;
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.4";
38
- version = `${versionMajorMinor}.0-insiders.20240213`;
38
+ version = `${versionMajorMinor}.0-insiders.20240215`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -35009,7 +35009,7 @@ ${lanes.join("\n")}
35009
35009
  if (!jsDocDiagnostics) {
35010
35010
  jsDocDiagnostics = [];
35011
35011
  }
35012
- jsDocDiagnostics.push(...parseDiagnostics);
35012
+ addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
35013
35013
  }
35014
35014
  currentToken = saveToken;
35015
35015
  parseDiagnostics.length = saveParseDiagnosticsLength;
@@ -59857,7 +59857,7 @@ ${lanes.join("\n")}
59857
59857
  return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments);
59858
59858
  }
59859
59859
  function createNormalizedTupleType(target, elementTypes) {
59860
- var _a, _b, _c;
59860
+ var _a, _b, _c, _d;
59861
59861
  if (!(target.combinedFlags & 14 /* NonRequired */)) {
59862
59862
  return createTypeReference(target, elementTypes);
59863
59863
  }
@@ -59877,8 +59877,10 @@ ${lanes.join("\n")}
59877
59877
  const type = elementTypes[i];
59878
59878
  const flags = target.elementFlags[i];
59879
59879
  if (flags & 8 /* Variadic */) {
59880
- if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
59881
- addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
59880
+ if (type.flags & 1 /* Any */) {
59881
+ addElement(type, 4 /* Rest */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
59882
+ } else if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
59883
+ addElement(type, 8 /* Variadic */, (_b = target.labeledElementDeclarations) == null ? void 0 : _b[i]);
59882
59884
  } else if (isTupleType(type)) {
59883
59885
  const elements = getElementTypes(type);
59884
59886
  if (elements.length + expandedTypes.length >= 1e4) {
@@ -59893,10 +59895,10 @@ ${lanes.join("\n")}
59893
59895
  return addElement(t, type.target.elementFlags[n], (_a2 = type.target.labeledElementDeclarations) == null ? void 0 : _a2[n]);
59894
59896
  });
59895
59897
  } else {
59896
- addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) == null ? void 0 : _b[i]);
59898
+ addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_c = target.labeledElementDeclarations) == null ? void 0 : _c[i]);
59897
59899
  }
59898
59900
  } else {
59899
- addElement(type, flags, (_c = target.labeledElementDeclarations) == null ? void 0 : _c[i]);
59901
+ addElement(type, flags, (_d = target.labeledElementDeclarations) == null ? void 0 : _d[i]);
59900
59902
  }
59901
59903
  }
59902
59904
  for (let i = 0; i < lastRequiredIndex; i++) {
@@ -68149,7 +68151,7 @@ ${lanes.join("\n")}
68149
68151
  function hasMatchingArgument(expression, reference) {
68150
68152
  if (expression.arguments) {
68151
68153
  for (const argument of expression.arguments) {
68152
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
68154
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
68153
68155
  return true;
68154
68156
  }
68155
68157
  }
@@ -68159,6 +68161,36 @@ ${lanes.join("\n")}
68159
68161
  }
68160
68162
  return false;
68161
68163
  }
68164
+ function getCandidateDiscriminantPropertyAccess(expr, reference) {
68165
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
68166
+ if (isIdentifier(expr)) {
68167
+ const symbol = getResolvedSymbol(expr);
68168
+ const declaration = symbol.valueDeclaration;
68169
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
68170
+ return declaration;
68171
+ }
68172
+ }
68173
+ } else if (isAccessExpression(expr)) {
68174
+ if (isMatchingReference(reference, expr.expression)) {
68175
+ return expr;
68176
+ }
68177
+ } else if (isIdentifier(expr)) {
68178
+ const symbol = getResolvedSymbol(expr);
68179
+ if (isConstantVariable(symbol)) {
68180
+ const declaration = symbol.valueDeclaration;
68181
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
68182
+ return declaration.initializer;
68183
+ }
68184
+ if (isBindingElement(declaration) && !declaration.initializer) {
68185
+ const parent2 = declaration.parent.parent;
68186
+ if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
68187
+ return declaration;
68188
+ }
68189
+ }
68190
+ }
68191
+ }
68192
+ return void 0;
68193
+ }
68162
68194
  function getFlowNodeId(flow) {
68163
68195
  if (!flow.id || flow.id < 0) {
68164
68196
  flow.id = nextFlowId;
@@ -69258,39 +69290,9 @@ ${lanes.join("\n")}
69258
69290
  }
69259
69291
  return result;
69260
69292
  }
69261
- function getCandidateDiscriminantPropertyAccess(expr) {
69262
- if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
69263
- if (isIdentifier(expr)) {
69264
- const symbol = getResolvedSymbol(expr);
69265
- const declaration = symbol.valueDeclaration;
69266
- if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
69267
- return declaration;
69268
- }
69269
- }
69270
- } else if (isAccessExpression(expr)) {
69271
- if (isMatchingReference(reference, expr.expression)) {
69272
- return expr;
69273
- }
69274
- } else if (isIdentifier(expr)) {
69275
- const symbol = getResolvedSymbol(expr);
69276
- if (isConstantVariable(symbol)) {
69277
- const declaration = symbol.valueDeclaration;
69278
- if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
69279
- return declaration.initializer;
69280
- }
69281
- if (isBindingElement(declaration) && !declaration.initializer) {
69282
- const parent2 = declaration.parent.parent;
69283
- if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
69284
- return declaration;
69285
- }
69286
- }
69287
- }
69288
- }
69289
- return void 0;
69290
- }
69291
69293
  function getDiscriminantPropertyAccess(expr, computedType) {
69292
69294
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
69293
- const access = getCandidateDiscriminantPropertyAccess(expr);
69295
+ const access = getCandidateDiscriminantPropertyAccess(expr, reference);
69294
69296
  if (access) {
69295
69297
  const name = getAccessedPropertyName(access);
69296
69298
  if (name) {
@@ -69836,10 +69838,12 @@ ${lanes.join("\n")}
69836
69838
  return !(narrowedType.flags & 131072 /* Never */) ? narrowedType : isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]);
69837
69839
  }
69838
69840
  function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
69839
- const signature = assumeTrue || !isCallChain(callExpression) ? getEffectsSignature(callExpression) : void 0;
69840
- const predicate = signature && getTypePredicateOfSignature(signature);
69841
- if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
69842
- return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
69841
+ if (hasMatchingArgument(callExpression, reference)) {
69842
+ const signature = assumeTrue || !isCallChain(callExpression) ? getEffectsSignature(callExpression) : void 0;
69843
+ const predicate = signature && getTypePredicateOfSignature(signature);
69844
+ if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
69845
+ return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
69846
+ }
69843
69847
  }
69844
69848
  if (containsMissingType(type) && isAccessExpression(reference) && isPropertyAccessExpression(callExpression.expression)) {
69845
69849
  const callAccess = callExpression.expression;
@@ -175441,7 +175445,7 @@ ${options.prefix}` : "\n" : options.prefix
175441
175445
  }
175442
175446
  break;
175443
175447
  default:
175444
- if (unorderedRemoveItem(this.containingProjects, project)) {
175448
+ if (orderedRemoveItem(this.containingProjects, project)) {
175445
175449
  project.onFileAddedOrRemoved(this.isSymlink());
175446
175450
  }
175447
175451
  break;
@@ -179150,7 +179154,7 @@ ${options.prefix}` : "\n" : options.prefix
179150
179154
  );
179151
179155
  project.addRoot(info);
179152
179156
  if (info.containingProjects[0] !== project) {
179153
- info.detachFromProject(project);
179157
+ orderedRemoveItem(info.containingProjects, project);
179154
179158
  info.containingProjects.unshift(project);
179155
179159
  }
179156
179160
  project.updateGraph();
@@ -179445,8 +179449,7 @@ ${options.prefix}` : "\n" : options.prefix
179445
179449
  * otherwise just file name
179446
179450
  */
179447
179451
  getConfigFileNameForFile(info) {
179448
- if (isOpenScriptInfo(info)) {
179449
- Debug.assert(info.isScriptOpen());
179452
+ if (!isAncestorConfigFileInfo(info)) {
179450
179453
  const result = this.configFileForOpenFiles.get(info.path);
179451
179454
  if (result !== void 0)
179452
179455
  return result || void 0;
@@ -180441,11 +180444,13 @@ Dynamic files must always be opened with service's current directory or service
180441
180444
  } = this.hostConfiguration.preferences;
180442
180445
  this.hostConfiguration.preferences = { ...this.hostConfiguration.preferences, ...args.preferences };
180443
180446
  if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) {
180444
- this.configuredProjects.forEach((project) => {
180445
- if (project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) {
180446
- project.updateGraph();
180447
- }
180448
- });
180447
+ this.externalProjectToConfiguredProjectMap.forEach(
180448
+ (projects) => projects.forEach((project) => {
180449
+ if (!project.isClosed() && project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) {
180450
+ project.updateGraph();
180451
+ }
180452
+ })
180453
+ );
180449
180454
  }
180450
180455
  if (includePackageJsonAutoImports !== args.preferences.includePackageJsonAutoImports) {
180451
180456
  this.forEachProject((project) => {
@@ -181030,23 +181035,20 @@ Dynamic files must always be opened with service's current directory or service
181030
181035
  scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText);
181031
181036
  }
181032
181037
  }
181033
- closeConfiguredProjectReferencedFromExternalProject(configFile) {
181034
- const configuredProject = this.findConfiguredProjectByProjectName(configFile);
181035
- if (configuredProject) {
181036
- configuredProject.deleteExternalProjectReference();
181037
- if (!configuredProject.hasOpenRef()) {
181038
- this.removeProject(configuredProject);
181039
- return;
181038
+ closeConfiguredProjectReferencedFromExternalProject(configuredProjects) {
181039
+ configuredProjects == null ? void 0 : configuredProjects.forEach((configuredProject) => {
181040
+ if (!configuredProject.isClosed()) {
181041
+ configuredProject.deleteExternalProjectReference();
181042
+ if (!configuredProject.hasOpenRef())
181043
+ this.removeProject(configuredProject);
181040
181044
  }
181041
- }
181045
+ });
181042
181046
  }
181043
181047
  closeExternalProject(uncheckedFileName, print) {
181044
181048
  const fileName = toNormalizedPath(uncheckedFileName);
181045
- const configFiles = this.externalProjectToConfiguredProjectMap.get(fileName);
181046
- if (configFiles) {
181047
- for (const configFile of configFiles) {
181048
- this.closeConfiguredProjectReferencedFromExternalProject(configFile);
181049
- }
181049
+ const configuredProjects = this.externalProjectToConfiguredProjectMap.get(fileName);
181050
+ if (configuredProjects) {
181051
+ this.closeConfiguredProjectReferencedFromExternalProject(configuredProjects);
181050
181052
  this.externalProjectToConfiguredProjectMap.delete(fileName);
181051
181053
  } else {
181052
181054
  const externalProject = this.findExternalProjectByProjectName(uncheckedFileName);
@@ -181086,16 +181088,18 @@ Dynamic files must always be opened with service's current directory or service
181086
181088
  this.safelist = defaultTypeSafeList;
181087
181089
  }
181088
181090
  applySafeList(proj) {
181089
- const { rootFiles } = proj;
181090
181091
  const typeAcquisition = proj.typeAcquisition;
181091
181092
  Debug.assert(!!typeAcquisition, "proj.typeAcquisition should be set by now");
181093
+ const result = this.applySafeListWorker(proj, proj.rootFiles, typeAcquisition);
181094
+ return (result == null ? void 0 : result.excludedFiles) ?? [];
181095
+ }
181096
+ applySafeListWorker(proj, rootFiles, typeAcquisition) {
181092
181097
  if (typeAcquisition.enable === false || typeAcquisition.disableFilenameBasedTypeAcquisition) {
181093
- return [];
181098
+ return void 0;
181094
181099
  }
181095
181100
  const typeAcqInclude = typeAcquisition.include || (typeAcquisition.include = []);
181096
181101
  const excludeRules = [];
181097
181102
  const normalizedNames = rootFiles.map((f) => normalizeSlashes(f.fileName));
181098
- const excludedFiles = [];
181099
181103
  for (const name of Object.keys(this.safelist)) {
181100
181104
  const rule2 = this.safelist[name];
181101
181105
  for (const root of normalizedNames) {
@@ -181136,12 +181140,12 @@ Dynamic files must always be opened with service's current directory or service
181136
181140
  }
181137
181141
  }
181138
181142
  const excludeRegexes = excludeRules.map((e) => new RegExp(e, "i"));
181139
- const filesToKeep = [];
181140
- for (let i = 0; i < proj.rootFiles.length; i++) {
181143
+ let filesToKeep;
181144
+ let excludedFiles;
181145
+ for (let i = 0; i < rootFiles.length; i++) {
181141
181146
  if (excludeRegexes.some((re) => re.test(normalizedNames[i]))) {
181142
- excludedFiles.push(normalizedNames[i]);
181147
+ addExcludedFile(i);
181143
181148
  } else {
181144
- let exclude = false;
181145
181149
  if (typeAcquisition.enable) {
181146
181150
  const baseName = getBaseFileName(toFileNameLowerCase(normalizedNames[i]));
181147
181151
  if (fileExtensionIs(baseName, "js")) {
@@ -181150,120 +181154,91 @@ Dynamic files must always be opened with service's current directory or service
181150
181154
  const typeName = this.legacySafelist.get(cleanedTypingName);
181151
181155
  if (typeName !== void 0) {
181152
181156
  this.logger.info(`Excluded '${normalizedNames[i]}' because it matched ${cleanedTypingName} from the legacy safelist`);
181153
- excludedFiles.push(normalizedNames[i]);
181154
- exclude = true;
181157
+ addExcludedFile(i);
181155
181158
  if (!typeAcqInclude.includes(typeName)) {
181156
181159
  typeAcqInclude.push(typeName);
181157
181160
  }
181161
+ continue;
181158
181162
  }
181159
181163
  }
181160
181164
  }
181161
- if (!exclude) {
181162
- if (/^.+[.-]min\.js$/.test(normalizedNames[i])) {
181163
- excludedFiles.push(normalizedNames[i]);
181164
- } else {
181165
- filesToKeep.push(proj.rootFiles[i]);
181166
- }
181165
+ if (/^.+[.-]min\.js$/.test(normalizedNames[i])) {
181166
+ addExcludedFile(i);
181167
+ } else {
181168
+ filesToKeep == null ? void 0 : filesToKeep.push(rootFiles[i]);
181167
181169
  }
181168
181170
  }
181169
181171
  }
181170
- proj.rootFiles = filesToKeep;
181171
- return excludedFiles;
181172
+ return excludedFiles ? {
181173
+ rootFiles: filesToKeep,
181174
+ excludedFiles
181175
+ } : void 0;
181176
+ function addExcludedFile(index) {
181177
+ if (!excludedFiles) {
181178
+ Debug.assert(!filesToKeep);
181179
+ filesToKeep = rootFiles.slice(0, index);
181180
+ excludedFiles = [];
181181
+ }
181182
+ excludedFiles.push(normalizedNames[index]);
181183
+ }
181172
181184
  }
181173
181185
  openExternalProject(proj, print) {
181174
- proj.typeAcquisition = proj.typeAcquisition || {};
181175
- proj.typeAcquisition.include = proj.typeAcquisition.include || [];
181176
- proj.typeAcquisition.exclude = proj.typeAcquisition.exclude || [];
181177
- if (proj.typeAcquisition.enable === void 0) {
181178
- proj.typeAcquisition.enable = hasNoTypeScriptSource(proj.rootFiles.map((f) => f.fileName));
181179
- }
181180
- const excludedFiles = this.applySafeList(proj);
181181
- let tsConfigFiles;
181182
- const rootFiles = [];
181186
+ const existingExternalProject = this.findExternalProjectByProjectName(proj.projectFileName);
181187
+ const existingConfiguredProjects = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
181188
+ let configuredProjects;
181189
+ let rootFiles = [];
181183
181190
  for (const file of proj.rootFiles) {
181184
181191
  const normalized = toNormalizedPath(file.fileName);
181185
181192
  if (getBaseConfigFileName(normalized)) {
181186
181193
  if (this.serverMode === 0 /* Semantic */ && this.host.fileExists(normalized)) {
181187
- (tsConfigFiles || (tsConfigFiles = [])).push(normalized);
181194
+ let project = this.findConfiguredProjectByProjectName(normalized);
181195
+ if (!project) {
181196
+ project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? this.createConfiguredProjectWithDelayLoad(normalized, `Creating configured project in external project: ${proj.projectFileName}`) : this.createLoadAndUpdateConfiguredProject(normalized, `Creating configured project in external project: ${proj.projectFileName}`);
181197
+ }
181198
+ if (!(existingConfiguredProjects == null ? void 0 : existingConfiguredProjects.has(project))) {
181199
+ project.addExternalProjectReference();
181200
+ }
181201
+ (configuredProjects ?? (configuredProjects = /* @__PURE__ */ new Set())).add(project);
181202
+ existingConfiguredProjects == null ? void 0 : existingConfiguredProjects.delete(project);
181188
181203
  }
181189
181204
  } else {
181190
181205
  rootFiles.push(file);
181191
181206
  }
181192
181207
  }
181193
- if (tsConfigFiles) {
181194
- tsConfigFiles.sort();
181195
- }
181196
- const externalProject = this.findExternalProjectByProjectName(proj.projectFileName);
181197
- let exisingConfigFiles;
181198
- if (externalProject) {
181199
- externalProject.excludedFiles = excludedFiles;
181200
- if (!tsConfigFiles) {
181208
+ if (configuredProjects) {
181209
+ this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, configuredProjects);
181210
+ if (existingExternalProject)
181211
+ this.removeProject(existingExternalProject);
181212
+ } else {
181213
+ this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
181214
+ const typeAcquisition = proj.typeAcquisition || {};
181215
+ typeAcquisition.include = typeAcquisition.include || [];
181216
+ typeAcquisition.exclude = typeAcquisition.exclude || [];
181217
+ if (typeAcquisition.enable === void 0) {
181218
+ typeAcquisition.enable = hasNoTypeScriptSource(rootFiles.map((f) => f.fileName));
181219
+ }
181220
+ const excludeResult = this.applySafeListWorker(proj, rootFiles, typeAcquisition);
181221
+ const excludedFiles = (excludeResult == null ? void 0 : excludeResult.excludedFiles) ?? [];
181222
+ rootFiles = (excludeResult == null ? void 0 : excludeResult.rootFiles) ?? rootFiles;
181223
+ if (existingExternalProject) {
181224
+ existingExternalProject.excludedFiles = excludedFiles;
181201
181225
  const compilerOptions = convertCompilerOptions(proj.options);
181202
- const watchOptionsAndErrors = convertWatchOptions(proj.options, externalProject.getCurrentDirectory());
181203
- const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader);
181226
+ const watchOptionsAndErrors = convertWatchOptions(proj.options, existingExternalProject.getCurrentDirectory());
181227
+ const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, rootFiles, externalFilePropertyReader);
181204
181228
  if (lastFileExceededProgramSize) {
181205
- externalProject.disableLanguageService(lastFileExceededProgramSize);
181229
+ existingExternalProject.disableLanguageService(lastFileExceededProgramSize);
181206
181230
  } else {
181207
- externalProject.enableLanguageService();
181231
+ existingExternalProject.enableLanguageService();
181208
181232
  }
181209
- externalProject.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
181210
- this.updateRootAndOptionsOfNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions);
181211
- externalProject.updateGraph();
181212
- if (print)
181213
- this.printProjects();
181214
- return;
181215
- }
181216
- this.closeExternalProject(
181217
- proj.projectFileName,
181218
- /*print*/
181219
- false
181220
- );
181221
- } else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) {
181222
- if (!tsConfigFiles) {
181223
- this.closeExternalProject(
181224
- proj.projectFileName,
181225
- /*print*/
181226
- false
181227
- );
181233
+ existingExternalProject.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
181234
+ this.updateRootAndOptionsOfNonInferredProject(existingExternalProject, rootFiles, externalFilePropertyReader, compilerOptions, typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions);
181235
+ existingExternalProject.updateGraph();
181228
181236
  } else {
181229
- const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
181230
- let iNew = 0;
181231
- let iOld = 0;
181232
- while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) {
181233
- const newConfig = tsConfigFiles[iNew];
181234
- const oldConfig = oldConfigFiles[iOld];
181235
- if (oldConfig < newConfig) {
181236
- this.closeConfiguredProjectReferencedFromExternalProject(oldConfig);
181237
- iOld++;
181238
- } else if (oldConfig > newConfig) {
181239
- iNew++;
181240
- } else {
181241
- (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig);
181242
- iOld++;
181243
- iNew++;
181244
- }
181245
- }
181246
- for (let i = iOld; i < oldConfigFiles.length; i++) {
181247
- this.closeConfiguredProjectReferencedFromExternalProject(oldConfigFiles[i]);
181248
- }
181237
+ const project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, typeAcquisition, excludedFiles);
181238
+ project.updateGraph();
181249
181239
  }
181250
181240
  }
181251
- if (tsConfigFiles) {
181252
- this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles);
181253
- for (const tsconfigFile of tsConfigFiles) {
181254
- let project = this.findConfiguredProjectByProjectName(tsconfigFile);
181255
- if (!project) {
181256
- project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? this.createConfiguredProjectWithDelayLoad(tsconfigFile, `Creating configured project in external project: ${proj.projectFileName}`) : this.createLoadAndUpdateConfiguredProject(tsconfigFile, `Creating configured project in external project: ${proj.projectFileName}`);
181257
- }
181258
- if (project && !contains(exisingConfigFiles, tsconfigFile)) {
181259
- project.addExternalProjectReference();
181260
- }
181261
- }
181262
- } else {
181263
- this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
181264
- const project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition, excludedFiles);
181265
- project.updateGraph();
181266
- }
181241
+ this.closeConfiguredProjectReferencedFromExternalProject(existingConfiguredProjects);
181267
181242
  if (print)
181268
181243
  this.printProjects();
181269
181244
  }
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.4";
57
- var version = `${versionMajorMinor}.0-insiders.20240213`;
57
+ var version = `${versionMajorMinor}.0-insiders.20240215`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -24326,7 +24326,7 @@ var Parser;
24326
24326
  if (!jsDocDiagnostics) {
24327
24327
  jsDocDiagnostics = [];
24328
24328
  }
24329
- jsDocDiagnostics.push(...parseDiagnostics);
24329
+ addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
24330
24330
  }
24331
24331
  currentToken = saveToken;
24332
24332
  parseDiagnostics.length = saveParseDiagnosticsLength;
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.4.0-pr-57358-23",
5
+ "version": "5.4.0-pr-57116-10",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -114,5 +114,5 @@
114
114
  "node": "20.1.0",
115
115
  "npm": "8.19.4"
116
116
  },
117
- "gitHead": "50eca250d6935fe06a0090848ac6347f1c118d1f"
117
+ "gitHead": "d699c813b58a106f0c6e8608c288a8937aecaec1"
118
118
  }