@typescript-deploys/pr-build 5.4.0-pr-57371-5 → 5.4.0-pr-55842-26

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.20240212`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240214`;
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;
@@ -58408,6 +58408,9 @@ function createTypeChecker(host) {
58408
58408
  if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
58409
58409
  return objectType;
58410
58410
  }
58411
+ if (indexType === neverType) {
58412
+ return neverType;
58413
+ }
58411
58414
  const indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType);
58412
58415
  if (indexInfo) {
58413
58416
  if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) {
@@ -58431,9 +58434,6 @@ function createTypeChecker(host) {
58431
58434
  }
58432
58435
  return indexInfo.type;
58433
58436
  }
58434
- if (indexType.flags & 131072 /* Never */) {
58435
- return neverType;
58436
- }
58437
58437
  if (isJSLiteralType(objectType)) {
58438
58438
  return anyType;
58439
58439
  }
@@ -65650,7 +65650,7 @@ function createTypeChecker(host) {
65650
65650
  function hasMatchingArgument(expression, reference) {
65651
65651
  if (expression.arguments) {
65652
65652
  for (const argument of expression.arguments) {
65653
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
65653
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
65654
65654
  return true;
65655
65655
  }
65656
65656
  }
@@ -65660,6 +65660,36 @@ function createTypeChecker(host) {
65660
65660
  }
65661
65661
  return false;
65662
65662
  }
65663
+ function getCandidateDiscriminantPropertyAccess(expr, reference) {
65664
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
65665
+ if (isIdentifier(expr)) {
65666
+ const symbol = getResolvedSymbol(expr);
65667
+ const declaration = symbol.valueDeclaration;
65668
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
65669
+ return declaration;
65670
+ }
65671
+ }
65672
+ } else if (isAccessExpression(expr)) {
65673
+ if (isMatchingReference(reference, expr.expression)) {
65674
+ return expr;
65675
+ }
65676
+ } else if (isIdentifier(expr)) {
65677
+ const symbol = getResolvedSymbol(expr);
65678
+ if (isConstantVariable(symbol)) {
65679
+ const declaration = symbol.valueDeclaration;
65680
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
65681
+ return declaration.initializer;
65682
+ }
65683
+ if (isBindingElement(declaration) && !declaration.initializer) {
65684
+ const parent = declaration.parent.parent;
65685
+ if (isVariableDeclaration(parent) && !parent.type && parent.initializer && (isIdentifier(parent.initializer) || isAccessExpression(parent.initializer)) && isMatchingReference(reference, parent.initializer)) {
65686
+ return declaration;
65687
+ }
65688
+ }
65689
+ }
65690
+ }
65691
+ return void 0;
65692
+ }
65663
65693
  function getFlowNodeId(flow) {
65664
65694
  if (!flow.id || flow.id < 0) {
65665
65695
  flow.id = nextFlowId;
@@ -66759,39 +66789,9 @@ function createTypeChecker(host) {
66759
66789
  }
66760
66790
  return result;
66761
66791
  }
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
66792
  function getDiscriminantPropertyAccess(expr, computedType) {
66793
66793
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
66794
- const access = getCandidateDiscriminantPropertyAccess(expr);
66794
+ const access = getCandidateDiscriminantPropertyAccess(expr, reference);
66795
66795
  if (access) {
66796
66796
  const name = getAccessedPropertyName(access);
66797
66797
  if (name) {
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.20240212`;
2343
+ var version = `${versionMajorMinor}.0-insiders.20240214`;
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;
@@ -63152,6 +63152,9 @@ function createTypeChecker(host) {
63152
63152
  if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
63153
63153
  return objectType;
63154
63154
  }
63155
+ if (indexType === neverType) {
63156
+ return neverType;
63157
+ }
63155
63158
  const indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType);
63156
63159
  if (indexInfo) {
63157
63160
  if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) {
@@ -63175,9 +63178,6 @@ function createTypeChecker(host) {
63175
63178
  }
63176
63179
  return indexInfo.type;
63177
63180
  }
63178
- if (indexType.flags & 131072 /* Never */) {
63179
- return neverType;
63180
- }
63181
63181
  if (isJSLiteralType(objectType)) {
63182
63182
  return anyType;
63183
63183
  }
@@ -70394,7 +70394,7 @@ function createTypeChecker(host) {
70394
70394
  function hasMatchingArgument(expression, reference) {
70395
70395
  if (expression.arguments) {
70396
70396
  for (const argument of expression.arguments) {
70397
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
70397
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
70398
70398
  return true;
70399
70399
  }
70400
70400
  }
@@ -70404,6 +70404,36 @@ function createTypeChecker(host) {
70404
70404
  }
70405
70405
  return false;
70406
70406
  }
70407
+ function getCandidateDiscriminantPropertyAccess(expr, reference) {
70408
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
70409
+ if (isIdentifier(expr)) {
70410
+ const symbol = getResolvedSymbol(expr);
70411
+ const declaration = symbol.valueDeclaration;
70412
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
70413
+ return declaration;
70414
+ }
70415
+ }
70416
+ } else if (isAccessExpression(expr)) {
70417
+ if (isMatchingReference(reference, expr.expression)) {
70418
+ return expr;
70419
+ }
70420
+ } else if (isIdentifier(expr)) {
70421
+ const symbol = getResolvedSymbol(expr);
70422
+ if (isConstantVariable(symbol)) {
70423
+ const declaration = symbol.valueDeclaration;
70424
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
70425
+ return declaration.initializer;
70426
+ }
70427
+ if (isBindingElement(declaration) && !declaration.initializer) {
70428
+ const parent2 = declaration.parent.parent;
70429
+ if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
70430
+ return declaration;
70431
+ }
70432
+ }
70433
+ }
70434
+ }
70435
+ return void 0;
70436
+ }
70407
70437
  function getFlowNodeId(flow) {
70408
70438
  if (!flow.id || flow.id < 0) {
70409
70439
  flow.id = nextFlowId;
@@ -71503,39 +71533,9 @@ function createTypeChecker(host) {
71503
71533
  }
71504
71534
  return result;
71505
71535
  }
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
71536
  function getDiscriminantPropertyAccess(expr, computedType) {
71537
71537
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
71538
- const access = getCandidateDiscriminantPropertyAccess(expr);
71538
+ const access = getCandidateDiscriminantPropertyAccess(expr, reference);
71539
71539
  if (access) {
71540
71540
  const name = getAccessedPropertyName(access);
71541
71541
  if (name) {
@@ -163054,15 +163054,18 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
163054
163054
  const basePath = compilerOptions.project || host.getCurrentDirectory();
163055
163055
  const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
163056
163056
  const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
163057
- return flatMap(baseDirectories, (baseDirectory) => arrayFrom(getCompletionEntriesForDirectoryFragment(
163058
- fragment,
163059
- baseDirectory,
163060
- extensionOptions,
163061
- host,
163062
- /*moduleSpecifierIsRelative*/
163063
- true,
163064
- exclude
163065
- ).values()));
163057
+ return deduplicate(
163058
+ flatMap(baseDirectories, (baseDirectory) => arrayFrom(getCompletionEntriesForDirectoryFragment(
163059
+ fragment,
163060
+ baseDirectory,
163061
+ extensionOptions,
163062
+ host,
163063
+ /*moduleSpecifierIsRelative*/
163064
+ true,
163065
+ exclude
163066
+ ).values())),
163067
+ (itemA, itemB) => itemA.name === itemB.name && itemA.kind === itemB.kind && itemA.extension === itemB.extension
163068
+ );
163066
163069
  }
163067
163070
  function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, host, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
163068
163071
  var _a;
@@ -178156,7 +178159,7 @@ var ScriptInfo = class {
178156
178159
  }
178157
178160
  break;
178158
178161
  default:
178159
- if (unorderedRemoveItem(this.containingProjects, project)) {
178162
+ if (orderedRemoveItem(this.containingProjects, project)) {
178160
178163
  project.onFileAddedOrRemoved(this.isSymlink());
178161
178164
  }
178162
178165
  break;
@@ -181828,7 +181831,7 @@ var _ProjectService = class _ProjectService {
181828
181831
  );
181829
181832
  project.addRoot(info);
181830
181833
  if (info.containingProjects[0] !== project) {
181831
- info.detachFromProject(project);
181834
+ orderedRemoveItem(info.containingProjects, project);
181832
181835
  info.containingProjects.unshift(project);
181833
181836
  }
181834
181837
  project.updateGraph();
@@ -182123,8 +182126,7 @@ var _ProjectService = class _ProjectService {
182123
182126
  * otherwise just file name
182124
182127
  */
182125
182128
  getConfigFileNameForFile(info) {
182126
- if (isOpenScriptInfo(info)) {
182127
- Debug.assert(info.isScriptOpen());
182129
+ if (!isAncestorConfigFileInfo(info)) {
182128
182130
  const result = this.configFileForOpenFiles.get(info.path);
182129
182131
  if (result !== void 0)
182130
182132
  return result || void 0;
@@ -183119,11 +183121,13 @@ Dynamic files must always be opened with service's current directory or service
183119
183121
  } = this.hostConfiguration.preferences;
183120
183122
  this.hostConfiguration.preferences = { ...this.hostConfiguration.preferences, ...args.preferences };
183121
183123
  if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) {
183122
- this.configuredProjects.forEach((project) => {
183123
- if (project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) {
183124
- project.updateGraph();
183125
- }
183126
- });
183124
+ this.externalProjectToConfiguredProjectMap.forEach(
183125
+ (projects) => projects.forEach((project) => {
183126
+ if (!project.isClosed() && project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) {
183127
+ project.updateGraph();
183128
+ }
183129
+ })
183130
+ );
183127
183131
  }
183128
183132
  if (includePackageJsonAutoImports !== args.preferences.includePackageJsonAutoImports) {
183129
183133
  this.forEachProject((project) => {
@@ -183708,23 +183712,20 @@ Dynamic files must always be opened with service's current directory or service
183708
183712
  scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText);
183709
183713
  }
183710
183714
  }
183711
- closeConfiguredProjectReferencedFromExternalProject(configFile) {
183712
- const configuredProject = this.findConfiguredProjectByProjectName(configFile);
183713
- if (configuredProject) {
183714
- configuredProject.deleteExternalProjectReference();
183715
- if (!configuredProject.hasOpenRef()) {
183716
- this.removeProject(configuredProject);
183717
- return;
183715
+ closeConfiguredProjectReferencedFromExternalProject(configuredProjects) {
183716
+ configuredProjects == null ? void 0 : configuredProjects.forEach((configuredProject) => {
183717
+ if (!configuredProject.isClosed()) {
183718
+ configuredProject.deleteExternalProjectReference();
183719
+ if (!configuredProject.hasOpenRef())
183720
+ this.removeProject(configuredProject);
183718
183721
  }
183719
- }
183722
+ });
183720
183723
  }
183721
183724
  closeExternalProject(uncheckedFileName, print) {
183722
183725
  const fileName = toNormalizedPath(uncheckedFileName);
183723
- const configFiles = this.externalProjectToConfiguredProjectMap.get(fileName);
183724
- if (configFiles) {
183725
- for (const configFile of configFiles) {
183726
- this.closeConfiguredProjectReferencedFromExternalProject(configFile);
183727
- }
183726
+ const configuredProjects = this.externalProjectToConfiguredProjectMap.get(fileName);
183727
+ if (configuredProjects) {
183728
+ this.closeConfiguredProjectReferencedFromExternalProject(configuredProjects);
183728
183729
  this.externalProjectToConfiguredProjectMap.delete(fileName);
183729
183730
  } else {
183730
183731
  const externalProject = this.findExternalProjectByProjectName(uncheckedFileName);
@@ -183764,16 +183765,18 @@ Dynamic files must always be opened with service's current directory or service
183764
183765
  this.safelist = defaultTypeSafeList;
183765
183766
  }
183766
183767
  applySafeList(proj) {
183767
- const { rootFiles } = proj;
183768
183768
  const typeAcquisition = proj.typeAcquisition;
183769
183769
  Debug.assert(!!typeAcquisition, "proj.typeAcquisition should be set by now");
183770
+ const result = this.applySafeListWorker(proj, proj.rootFiles, typeAcquisition);
183771
+ return (result == null ? void 0 : result.excludedFiles) ?? [];
183772
+ }
183773
+ applySafeListWorker(proj, rootFiles, typeAcquisition) {
183770
183774
  if (typeAcquisition.enable === false || typeAcquisition.disableFilenameBasedTypeAcquisition) {
183771
- return [];
183775
+ return void 0;
183772
183776
  }
183773
183777
  const typeAcqInclude = typeAcquisition.include || (typeAcquisition.include = []);
183774
183778
  const excludeRules = [];
183775
183779
  const normalizedNames = rootFiles.map((f) => normalizeSlashes(f.fileName));
183776
- const excludedFiles = [];
183777
183780
  for (const name of Object.keys(this.safelist)) {
183778
183781
  const rule2 = this.safelist[name];
183779
183782
  for (const root of normalizedNames) {
@@ -183814,12 +183817,12 @@ Dynamic files must always be opened with service's current directory or service
183814
183817
  }
183815
183818
  }
183816
183819
  const excludeRegexes = excludeRules.map((e) => new RegExp(e, "i"));
183817
- const filesToKeep = [];
183818
- for (let i = 0; i < proj.rootFiles.length; i++) {
183820
+ let filesToKeep;
183821
+ let excludedFiles;
183822
+ for (let i = 0; i < rootFiles.length; i++) {
183819
183823
  if (excludeRegexes.some((re) => re.test(normalizedNames[i]))) {
183820
- excludedFiles.push(normalizedNames[i]);
183824
+ addExcludedFile(i);
183821
183825
  } else {
183822
- let exclude = false;
183823
183826
  if (typeAcquisition.enable) {
183824
183827
  const baseName = getBaseFileName(toFileNameLowerCase(normalizedNames[i]));
183825
183828
  if (fileExtensionIs(baseName, "js")) {
@@ -183828,120 +183831,91 @@ Dynamic files must always be opened with service's current directory or service
183828
183831
  const typeName = this.legacySafelist.get(cleanedTypingName);
183829
183832
  if (typeName !== void 0) {
183830
183833
  this.logger.info(`Excluded '${normalizedNames[i]}' because it matched ${cleanedTypingName} from the legacy safelist`);
183831
- excludedFiles.push(normalizedNames[i]);
183832
- exclude = true;
183834
+ addExcludedFile(i);
183833
183835
  if (!typeAcqInclude.includes(typeName)) {
183834
183836
  typeAcqInclude.push(typeName);
183835
183837
  }
183838
+ continue;
183836
183839
  }
183837
183840
  }
183838
183841
  }
183839
- if (!exclude) {
183840
- if (/^.+[.-]min\.js$/.test(normalizedNames[i])) {
183841
- excludedFiles.push(normalizedNames[i]);
183842
- } else {
183843
- filesToKeep.push(proj.rootFiles[i]);
183844
- }
183842
+ if (/^.+[.-]min\.js$/.test(normalizedNames[i])) {
183843
+ addExcludedFile(i);
183844
+ } else {
183845
+ filesToKeep == null ? void 0 : filesToKeep.push(rootFiles[i]);
183845
183846
  }
183846
183847
  }
183847
183848
  }
183848
- proj.rootFiles = filesToKeep;
183849
- return excludedFiles;
183849
+ return excludedFiles ? {
183850
+ rootFiles: filesToKeep,
183851
+ excludedFiles
183852
+ } : void 0;
183853
+ function addExcludedFile(index) {
183854
+ if (!excludedFiles) {
183855
+ Debug.assert(!filesToKeep);
183856
+ filesToKeep = rootFiles.slice(0, index);
183857
+ excludedFiles = [];
183858
+ }
183859
+ excludedFiles.push(normalizedNames[index]);
183860
+ }
183850
183861
  }
183851
183862
  openExternalProject(proj, print) {
183852
- proj.typeAcquisition = proj.typeAcquisition || {};
183853
- proj.typeAcquisition.include = proj.typeAcquisition.include || [];
183854
- proj.typeAcquisition.exclude = proj.typeAcquisition.exclude || [];
183855
- if (proj.typeAcquisition.enable === void 0) {
183856
- proj.typeAcquisition.enable = hasNoTypeScriptSource(proj.rootFiles.map((f) => f.fileName));
183857
- }
183858
- const excludedFiles = this.applySafeList(proj);
183859
- let tsConfigFiles;
183860
- const rootFiles = [];
183863
+ const existingExternalProject = this.findExternalProjectByProjectName(proj.projectFileName);
183864
+ const existingConfiguredProjects = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
183865
+ let configuredProjects;
183866
+ let rootFiles = [];
183861
183867
  for (const file of proj.rootFiles) {
183862
183868
  const normalized = toNormalizedPath(file.fileName);
183863
183869
  if (getBaseConfigFileName(normalized)) {
183864
183870
  if (this.serverMode === 0 /* Semantic */ && this.host.fileExists(normalized)) {
183865
- (tsConfigFiles || (tsConfigFiles = [])).push(normalized);
183871
+ let project = this.findConfiguredProjectByProjectName(normalized);
183872
+ if (!project) {
183873
+ 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}`);
183874
+ }
183875
+ if (!(existingConfiguredProjects == null ? void 0 : existingConfiguredProjects.has(project))) {
183876
+ project.addExternalProjectReference();
183877
+ }
183878
+ (configuredProjects ?? (configuredProjects = /* @__PURE__ */ new Set())).add(project);
183879
+ existingConfiguredProjects == null ? void 0 : existingConfiguredProjects.delete(project);
183866
183880
  }
183867
183881
  } else {
183868
183882
  rootFiles.push(file);
183869
183883
  }
183870
183884
  }
183871
- if (tsConfigFiles) {
183872
- tsConfigFiles.sort();
183873
- }
183874
- const externalProject = this.findExternalProjectByProjectName(proj.projectFileName);
183875
- let exisingConfigFiles;
183876
- if (externalProject) {
183877
- externalProject.excludedFiles = excludedFiles;
183878
- if (!tsConfigFiles) {
183885
+ if (configuredProjects) {
183886
+ this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, configuredProjects);
183887
+ if (existingExternalProject)
183888
+ this.removeProject(existingExternalProject);
183889
+ } else {
183890
+ this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
183891
+ const typeAcquisition = proj.typeAcquisition || {};
183892
+ typeAcquisition.include = typeAcquisition.include || [];
183893
+ typeAcquisition.exclude = typeAcquisition.exclude || [];
183894
+ if (typeAcquisition.enable === void 0) {
183895
+ typeAcquisition.enable = hasNoTypeScriptSource(rootFiles.map((f) => f.fileName));
183896
+ }
183897
+ const excludeResult = this.applySafeListWorker(proj, rootFiles, typeAcquisition);
183898
+ const excludedFiles = (excludeResult == null ? void 0 : excludeResult.excludedFiles) ?? [];
183899
+ rootFiles = (excludeResult == null ? void 0 : excludeResult.rootFiles) ?? rootFiles;
183900
+ if (existingExternalProject) {
183901
+ existingExternalProject.excludedFiles = excludedFiles;
183879
183902
  const compilerOptions = convertCompilerOptions(proj.options);
183880
- const watchOptionsAndErrors = convertWatchOptions(proj.options, externalProject.getCurrentDirectory());
183881
- const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader);
183903
+ const watchOptionsAndErrors = convertWatchOptions(proj.options, existingExternalProject.getCurrentDirectory());
183904
+ const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, rootFiles, externalFilePropertyReader);
183882
183905
  if (lastFileExceededProgramSize) {
183883
- externalProject.disableLanguageService(lastFileExceededProgramSize);
183906
+ existingExternalProject.disableLanguageService(lastFileExceededProgramSize);
183884
183907
  } else {
183885
- externalProject.enableLanguageService();
183908
+ existingExternalProject.enableLanguageService();
183886
183909
  }
183887
- externalProject.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
183888
- this.updateRootAndOptionsOfNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions);
183889
- externalProject.updateGraph();
183890
- if (print)
183891
- this.printProjects();
183892
- return;
183893
- }
183894
- this.closeExternalProject(
183895
- proj.projectFileName,
183896
- /*print*/
183897
- false
183898
- );
183899
- } else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) {
183900
- if (!tsConfigFiles) {
183901
- this.closeExternalProject(
183902
- proj.projectFileName,
183903
- /*print*/
183904
- false
183905
- );
183910
+ existingExternalProject.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
183911
+ this.updateRootAndOptionsOfNonInferredProject(existingExternalProject, rootFiles, externalFilePropertyReader, compilerOptions, typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions);
183912
+ existingExternalProject.updateGraph();
183906
183913
  } else {
183907
- const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
183908
- let iNew = 0;
183909
- let iOld = 0;
183910
- while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) {
183911
- const newConfig = tsConfigFiles[iNew];
183912
- const oldConfig = oldConfigFiles[iOld];
183913
- if (oldConfig < newConfig) {
183914
- this.closeConfiguredProjectReferencedFromExternalProject(oldConfig);
183915
- iOld++;
183916
- } else if (oldConfig > newConfig) {
183917
- iNew++;
183918
- } else {
183919
- (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig);
183920
- iOld++;
183921
- iNew++;
183922
- }
183923
- }
183924
- for (let i = iOld; i < oldConfigFiles.length; i++) {
183925
- this.closeConfiguredProjectReferencedFromExternalProject(oldConfigFiles[i]);
183926
- }
183914
+ const project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, typeAcquisition, excludedFiles);
183915
+ project.updateGraph();
183927
183916
  }
183928
183917
  }
183929
- if (tsConfigFiles) {
183930
- this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles);
183931
- for (const tsconfigFile of tsConfigFiles) {
183932
- let project = this.findConfiguredProjectByProjectName(tsconfigFile);
183933
- if (!project) {
183934
- 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}`);
183935
- }
183936
- if (project && !contains(exisingConfigFiles, tsconfigFile)) {
183937
- project.addExternalProjectReference();
183938
- }
183939
- }
183940
- } else {
183941
- this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
183942
- const project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition, excludedFiles);
183943
- project.updateGraph();
183944
- }
183918
+ this.closeConfiguredProjectReferencedFromExternalProject(existingConfiguredProjects);
183945
183919
  if (print)
183946
183920
  this.printProjects();
183947
183921
  }
@@ -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.20240212`;
38
+ version = `${versionMajorMinor}.0-insiders.20240214`;
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;
@@ -60907,6 +60907,9 @@ ${lanes.join("\n")}
60907
60907
  if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
60908
60908
  return objectType;
60909
60909
  }
60910
+ if (indexType === neverType) {
60911
+ return neverType;
60912
+ }
60910
60913
  const indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType);
60911
60914
  if (indexInfo) {
60912
60915
  if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) {
@@ -60930,9 +60933,6 @@ ${lanes.join("\n")}
60930
60933
  }
60931
60934
  return indexInfo.type;
60932
60935
  }
60933
- if (indexType.flags & 131072 /* Never */) {
60934
- return neverType;
60935
- }
60936
60936
  if (isJSLiteralType(objectType)) {
60937
60937
  return anyType;
60938
60938
  }
@@ -68149,7 +68149,7 @@ ${lanes.join("\n")}
68149
68149
  function hasMatchingArgument(expression, reference) {
68150
68150
  if (expression.arguments) {
68151
68151
  for (const argument of expression.arguments) {
68152
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
68152
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
68153
68153
  return true;
68154
68154
  }
68155
68155
  }
@@ -68159,6 +68159,36 @@ ${lanes.join("\n")}
68159
68159
  }
68160
68160
  return false;
68161
68161
  }
68162
+ function getCandidateDiscriminantPropertyAccess(expr, reference) {
68163
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
68164
+ if (isIdentifier(expr)) {
68165
+ const symbol = getResolvedSymbol(expr);
68166
+ const declaration = symbol.valueDeclaration;
68167
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
68168
+ return declaration;
68169
+ }
68170
+ }
68171
+ } else if (isAccessExpression(expr)) {
68172
+ if (isMatchingReference(reference, expr.expression)) {
68173
+ return expr;
68174
+ }
68175
+ } else if (isIdentifier(expr)) {
68176
+ const symbol = getResolvedSymbol(expr);
68177
+ if (isConstantVariable(symbol)) {
68178
+ const declaration = symbol.valueDeclaration;
68179
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
68180
+ return declaration.initializer;
68181
+ }
68182
+ if (isBindingElement(declaration) && !declaration.initializer) {
68183
+ const parent2 = declaration.parent.parent;
68184
+ if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
68185
+ return declaration;
68186
+ }
68187
+ }
68188
+ }
68189
+ }
68190
+ return void 0;
68191
+ }
68162
68192
  function getFlowNodeId(flow) {
68163
68193
  if (!flow.id || flow.id < 0) {
68164
68194
  flow.id = nextFlowId;
@@ -69258,39 +69288,9 @@ ${lanes.join("\n")}
69258
69288
  }
69259
69289
  return result;
69260
69290
  }
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
69291
  function getDiscriminantPropertyAccess(expr, computedType) {
69292
69292
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
69293
- const access = getCandidateDiscriminantPropertyAccess(expr);
69293
+ const access = getCandidateDiscriminantPropertyAccess(expr, reference);
69294
69294
  if (access) {
69295
69295
  const name = getAccessedPropertyName(access);
69296
69296
  if (name) {
@@ -162321,15 +162321,18 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
162321
162321
  const basePath = compilerOptions.project || host.getCurrentDirectory();
162322
162322
  const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
162323
162323
  const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
162324
- return flatMap(baseDirectories, (baseDirectory) => arrayFrom(getCompletionEntriesForDirectoryFragment(
162325
- fragment,
162326
- baseDirectory,
162327
- extensionOptions,
162328
- host,
162329
- /*moduleSpecifierIsRelative*/
162330
- true,
162331
- exclude
162332
- ).values()));
162324
+ return deduplicate(
162325
+ flatMap(baseDirectories, (baseDirectory) => arrayFrom(getCompletionEntriesForDirectoryFragment(
162326
+ fragment,
162327
+ baseDirectory,
162328
+ extensionOptions,
162329
+ host,
162330
+ /*moduleSpecifierIsRelative*/
162331
+ true,
162332
+ exclude
162333
+ ).values())),
162334
+ (itemA, itemB) => itemA.name === itemB.name && itemA.kind === itemB.kind && itemA.extension === itemB.extension
162335
+ );
162333
162336
  }
162334
162337
  function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, host, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
162335
162338
  var _a;
@@ -175440,7 +175443,7 @@ ${options.prefix}` : "\n" : options.prefix
175440
175443
  }
175441
175444
  break;
175442
175445
  default:
175443
- if (unorderedRemoveItem(this.containingProjects, project)) {
175446
+ if (orderedRemoveItem(this.containingProjects, project)) {
175444
175447
  project.onFileAddedOrRemoved(this.isSymlink());
175445
175448
  }
175446
175449
  break;
@@ -179149,7 +179152,7 @@ ${options.prefix}` : "\n" : options.prefix
179149
179152
  );
179150
179153
  project.addRoot(info);
179151
179154
  if (info.containingProjects[0] !== project) {
179152
- info.detachFromProject(project);
179155
+ orderedRemoveItem(info.containingProjects, project);
179153
179156
  info.containingProjects.unshift(project);
179154
179157
  }
179155
179158
  project.updateGraph();
@@ -179444,8 +179447,7 @@ ${options.prefix}` : "\n" : options.prefix
179444
179447
  * otherwise just file name
179445
179448
  */
179446
179449
  getConfigFileNameForFile(info) {
179447
- if (isOpenScriptInfo(info)) {
179448
- Debug.assert(info.isScriptOpen());
179450
+ if (!isAncestorConfigFileInfo(info)) {
179449
179451
  const result = this.configFileForOpenFiles.get(info.path);
179450
179452
  if (result !== void 0)
179451
179453
  return result || void 0;
@@ -180440,11 +180442,13 @@ Dynamic files must always be opened with service's current directory or service
180440
180442
  } = this.hostConfiguration.preferences;
180441
180443
  this.hostConfiguration.preferences = { ...this.hostConfiguration.preferences, ...args.preferences };
180442
180444
  if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) {
180443
- this.configuredProjects.forEach((project) => {
180444
- if (project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) {
180445
- project.updateGraph();
180446
- }
180447
- });
180445
+ this.externalProjectToConfiguredProjectMap.forEach(
180446
+ (projects) => projects.forEach((project) => {
180447
+ if (!project.isClosed() && project.hasExternalProjectRef() && project.pendingUpdateLevel === 2 /* Full */ && !this.pendingProjectUpdates.has(project.getProjectName())) {
180448
+ project.updateGraph();
180449
+ }
180450
+ })
180451
+ );
180448
180452
  }
180449
180453
  if (includePackageJsonAutoImports !== args.preferences.includePackageJsonAutoImports) {
180450
180454
  this.forEachProject((project) => {
@@ -181029,23 +181033,20 @@ Dynamic files must always be opened with service's current directory or service
181029
181033
  scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText);
181030
181034
  }
181031
181035
  }
181032
- closeConfiguredProjectReferencedFromExternalProject(configFile) {
181033
- const configuredProject = this.findConfiguredProjectByProjectName(configFile);
181034
- if (configuredProject) {
181035
- configuredProject.deleteExternalProjectReference();
181036
- if (!configuredProject.hasOpenRef()) {
181037
- this.removeProject(configuredProject);
181038
- return;
181036
+ closeConfiguredProjectReferencedFromExternalProject(configuredProjects) {
181037
+ configuredProjects == null ? void 0 : configuredProjects.forEach((configuredProject) => {
181038
+ if (!configuredProject.isClosed()) {
181039
+ configuredProject.deleteExternalProjectReference();
181040
+ if (!configuredProject.hasOpenRef())
181041
+ this.removeProject(configuredProject);
181039
181042
  }
181040
- }
181043
+ });
181041
181044
  }
181042
181045
  closeExternalProject(uncheckedFileName, print) {
181043
181046
  const fileName = toNormalizedPath(uncheckedFileName);
181044
- const configFiles = this.externalProjectToConfiguredProjectMap.get(fileName);
181045
- if (configFiles) {
181046
- for (const configFile of configFiles) {
181047
- this.closeConfiguredProjectReferencedFromExternalProject(configFile);
181048
- }
181047
+ const configuredProjects = this.externalProjectToConfiguredProjectMap.get(fileName);
181048
+ if (configuredProjects) {
181049
+ this.closeConfiguredProjectReferencedFromExternalProject(configuredProjects);
181049
181050
  this.externalProjectToConfiguredProjectMap.delete(fileName);
181050
181051
  } else {
181051
181052
  const externalProject = this.findExternalProjectByProjectName(uncheckedFileName);
@@ -181085,16 +181086,18 @@ Dynamic files must always be opened with service's current directory or service
181085
181086
  this.safelist = defaultTypeSafeList;
181086
181087
  }
181087
181088
  applySafeList(proj) {
181088
- const { rootFiles } = proj;
181089
181089
  const typeAcquisition = proj.typeAcquisition;
181090
181090
  Debug.assert(!!typeAcquisition, "proj.typeAcquisition should be set by now");
181091
+ const result = this.applySafeListWorker(proj, proj.rootFiles, typeAcquisition);
181092
+ return (result == null ? void 0 : result.excludedFiles) ?? [];
181093
+ }
181094
+ applySafeListWorker(proj, rootFiles, typeAcquisition) {
181091
181095
  if (typeAcquisition.enable === false || typeAcquisition.disableFilenameBasedTypeAcquisition) {
181092
- return [];
181096
+ return void 0;
181093
181097
  }
181094
181098
  const typeAcqInclude = typeAcquisition.include || (typeAcquisition.include = []);
181095
181099
  const excludeRules = [];
181096
181100
  const normalizedNames = rootFiles.map((f) => normalizeSlashes(f.fileName));
181097
- const excludedFiles = [];
181098
181101
  for (const name of Object.keys(this.safelist)) {
181099
181102
  const rule2 = this.safelist[name];
181100
181103
  for (const root of normalizedNames) {
@@ -181135,12 +181138,12 @@ Dynamic files must always be opened with service's current directory or service
181135
181138
  }
181136
181139
  }
181137
181140
  const excludeRegexes = excludeRules.map((e) => new RegExp(e, "i"));
181138
- const filesToKeep = [];
181139
- for (let i = 0; i < proj.rootFiles.length; i++) {
181141
+ let filesToKeep;
181142
+ let excludedFiles;
181143
+ for (let i = 0; i < rootFiles.length; i++) {
181140
181144
  if (excludeRegexes.some((re) => re.test(normalizedNames[i]))) {
181141
- excludedFiles.push(normalizedNames[i]);
181145
+ addExcludedFile(i);
181142
181146
  } else {
181143
- let exclude = false;
181144
181147
  if (typeAcquisition.enable) {
181145
181148
  const baseName = getBaseFileName(toFileNameLowerCase(normalizedNames[i]));
181146
181149
  if (fileExtensionIs(baseName, "js")) {
@@ -181149,120 +181152,91 @@ Dynamic files must always be opened with service's current directory or service
181149
181152
  const typeName = this.legacySafelist.get(cleanedTypingName);
181150
181153
  if (typeName !== void 0) {
181151
181154
  this.logger.info(`Excluded '${normalizedNames[i]}' because it matched ${cleanedTypingName} from the legacy safelist`);
181152
- excludedFiles.push(normalizedNames[i]);
181153
- exclude = true;
181155
+ addExcludedFile(i);
181154
181156
  if (!typeAcqInclude.includes(typeName)) {
181155
181157
  typeAcqInclude.push(typeName);
181156
181158
  }
181159
+ continue;
181157
181160
  }
181158
181161
  }
181159
181162
  }
181160
- if (!exclude) {
181161
- if (/^.+[.-]min\.js$/.test(normalizedNames[i])) {
181162
- excludedFiles.push(normalizedNames[i]);
181163
- } else {
181164
- filesToKeep.push(proj.rootFiles[i]);
181165
- }
181163
+ if (/^.+[.-]min\.js$/.test(normalizedNames[i])) {
181164
+ addExcludedFile(i);
181165
+ } else {
181166
+ filesToKeep == null ? void 0 : filesToKeep.push(rootFiles[i]);
181166
181167
  }
181167
181168
  }
181168
181169
  }
181169
- proj.rootFiles = filesToKeep;
181170
- return excludedFiles;
181170
+ return excludedFiles ? {
181171
+ rootFiles: filesToKeep,
181172
+ excludedFiles
181173
+ } : void 0;
181174
+ function addExcludedFile(index) {
181175
+ if (!excludedFiles) {
181176
+ Debug.assert(!filesToKeep);
181177
+ filesToKeep = rootFiles.slice(0, index);
181178
+ excludedFiles = [];
181179
+ }
181180
+ excludedFiles.push(normalizedNames[index]);
181181
+ }
181171
181182
  }
181172
181183
  openExternalProject(proj, print) {
181173
- proj.typeAcquisition = proj.typeAcquisition || {};
181174
- proj.typeAcquisition.include = proj.typeAcquisition.include || [];
181175
- proj.typeAcquisition.exclude = proj.typeAcquisition.exclude || [];
181176
- if (proj.typeAcquisition.enable === void 0) {
181177
- proj.typeAcquisition.enable = hasNoTypeScriptSource(proj.rootFiles.map((f) => f.fileName));
181178
- }
181179
- const excludedFiles = this.applySafeList(proj);
181180
- let tsConfigFiles;
181181
- const rootFiles = [];
181184
+ const existingExternalProject = this.findExternalProjectByProjectName(proj.projectFileName);
181185
+ const existingConfiguredProjects = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
181186
+ let configuredProjects;
181187
+ let rootFiles = [];
181182
181188
  for (const file of proj.rootFiles) {
181183
181189
  const normalized = toNormalizedPath(file.fileName);
181184
181190
  if (getBaseConfigFileName(normalized)) {
181185
181191
  if (this.serverMode === 0 /* Semantic */ && this.host.fileExists(normalized)) {
181186
- (tsConfigFiles || (tsConfigFiles = [])).push(normalized);
181192
+ let project = this.findConfiguredProjectByProjectName(normalized);
181193
+ if (!project) {
181194
+ 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}`);
181195
+ }
181196
+ if (!(existingConfiguredProjects == null ? void 0 : existingConfiguredProjects.has(project))) {
181197
+ project.addExternalProjectReference();
181198
+ }
181199
+ (configuredProjects ?? (configuredProjects = /* @__PURE__ */ new Set())).add(project);
181200
+ existingConfiguredProjects == null ? void 0 : existingConfiguredProjects.delete(project);
181187
181201
  }
181188
181202
  } else {
181189
181203
  rootFiles.push(file);
181190
181204
  }
181191
181205
  }
181192
- if (tsConfigFiles) {
181193
- tsConfigFiles.sort();
181194
- }
181195
- const externalProject = this.findExternalProjectByProjectName(proj.projectFileName);
181196
- let exisingConfigFiles;
181197
- if (externalProject) {
181198
- externalProject.excludedFiles = excludedFiles;
181199
- if (!tsConfigFiles) {
181206
+ if (configuredProjects) {
181207
+ this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, configuredProjects);
181208
+ if (existingExternalProject)
181209
+ this.removeProject(existingExternalProject);
181210
+ } else {
181211
+ this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
181212
+ const typeAcquisition = proj.typeAcquisition || {};
181213
+ typeAcquisition.include = typeAcquisition.include || [];
181214
+ typeAcquisition.exclude = typeAcquisition.exclude || [];
181215
+ if (typeAcquisition.enable === void 0) {
181216
+ typeAcquisition.enable = hasNoTypeScriptSource(rootFiles.map((f) => f.fileName));
181217
+ }
181218
+ const excludeResult = this.applySafeListWorker(proj, rootFiles, typeAcquisition);
181219
+ const excludedFiles = (excludeResult == null ? void 0 : excludeResult.excludedFiles) ?? [];
181220
+ rootFiles = (excludeResult == null ? void 0 : excludeResult.rootFiles) ?? rootFiles;
181221
+ if (existingExternalProject) {
181222
+ existingExternalProject.excludedFiles = excludedFiles;
181200
181223
  const compilerOptions = convertCompilerOptions(proj.options);
181201
- const watchOptionsAndErrors = convertWatchOptions(proj.options, externalProject.getCurrentDirectory());
181202
- const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader);
181224
+ const watchOptionsAndErrors = convertWatchOptions(proj.options, existingExternalProject.getCurrentDirectory());
181225
+ const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, rootFiles, externalFilePropertyReader);
181203
181226
  if (lastFileExceededProgramSize) {
181204
- externalProject.disableLanguageService(lastFileExceededProgramSize);
181227
+ existingExternalProject.disableLanguageService(lastFileExceededProgramSize);
181205
181228
  } else {
181206
- externalProject.enableLanguageService();
181229
+ existingExternalProject.enableLanguageService();
181207
181230
  }
181208
- externalProject.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
181209
- this.updateRootAndOptionsOfNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions);
181210
- externalProject.updateGraph();
181211
- if (print)
181212
- this.printProjects();
181213
- return;
181214
- }
181215
- this.closeExternalProject(
181216
- proj.projectFileName,
181217
- /*print*/
181218
- false
181219
- );
181220
- } else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) {
181221
- if (!tsConfigFiles) {
181222
- this.closeExternalProject(
181223
- proj.projectFileName,
181224
- /*print*/
181225
- false
181226
- );
181231
+ existingExternalProject.setProjectErrors(watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.errors);
181232
+ this.updateRootAndOptionsOfNonInferredProject(existingExternalProject, rootFiles, externalFilePropertyReader, compilerOptions, typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors == null ? void 0 : watchOptionsAndErrors.watchOptions);
181233
+ existingExternalProject.updateGraph();
181227
181234
  } else {
181228
- const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
181229
- let iNew = 0;
181230
- let iOld = 0;
181231
- while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) {
181232
- const newConfig = tsConfigFiles[iNew];
181233
- const oldConfig = oldConfigFiles[iOld];
181234
- if (oldConfig < newConfig) {
181235
- this.closeConfiguredProjectReferencedFromExternalProject(oldConfig);
181236
- iOld++;
181237
- } else if (oldConfig > newConfig) {
181238
- iNew++;
181239
- } else {
181240
- (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig);
181241
- iOld++;
181242
- iNew++;
181243
- }
181244
- }
181245
- for (let i = iOld; i < oldConfigFiles.length; i++) {
181246
- this.closeConfiguredProjectReferencedFromExternalProject(oldConfigFiles[i]);
181247
- }
181235
+ const project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, typeAcquisition, excludedFiles);
181236
+ project.updateGraph();
181248
181237
  }
181249
181238
  }
181250
- if (tsConfigFiles) {
181251
- this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles);
181252
- for (const tsconfigFile of tsConfigFiles) {
181253
- let project = this.findConfiguredProjectByProjectName(tsconfigFile);
181254
- if (!project) {
181255
- 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}`);
181256
- }
181257
- if (project && !contains(exisingConfigFiles, tsconfigFile)) {
181258
- project.addExternalProjectReference();
181259
- }
181260
- }
181261
- } else {
181262
- this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName);
181263
- const project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition, excludedFiles);
181264
- project.updateGraph();
181265
- }
181239
+ this.closeConfiguredProjectReferencedFromExternalProject(existingConfiguredProjects);
181266
181240
  if (print)
181267
181241
  this.printProjects();
181268
181242
  }
@@ -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.20240212`;
57
+ var version = `${versionMajorMinor}.0-insiders.20240214`;
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-57371-5",
5
+ "version": "5.4.0-pr-55842-26",
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": "790925bcb211cf4fce75690fefcf6e3846ddee51"
117
+ "gitHead": "48898f2f820ea4a404e1f6ffc6e28e279d3ad869"
118
118
  }