typescript 5.4.0-dev.20231114 → 5.4.0-dev.20231116

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.
@@ -49,9 +49,11 @@ declare namespace ts {
49
49
  readonly fileName: Path;
50
50
  readonly packageName: string;
51
51
  readonly projectRootPath: Path;
52
+ readonly id: number;
52
53
  }
53
54
  interface PackageInstalledResponse extends ProjectResponse {
54
55
  readonly kind: ActionPackageInstalled;
56
+ readonly id: number;
55
57
  readonly success: boolean;
56
58
  readonly message: string;
57
59
  }
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-dev.20231114`;
38
+ version = `${versionMajorMinor}.0-dev.20231116`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -5779,6 +5779,7 @@ ${lanes.join("\n")}
5779
5779
  useNonPollingWatchers,
5780
5780
  tscWatchDirectory,
5781
5781
  inodeWatching,
5782
+ fsWatchWithTimestamp,
5782
5783
  sysLog: sysLog2
5783
5784
  }) {
5784
5785
  const pollingWatches = /* @__PURE__ */ new Map();
@@ -6017,7 +6018,7 @@ ${lanes.join("\n")}
6017
6018
  return watchPresentFileSystemEntryWithFsWatchFile();
6018
6019
  }
6019
6020
  try {
6020
- const presentWatcher = fsWatchWorker(
6021
+ const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
6021
6022
  fileOrDirectory,
6022
6023
  recursive,
6023
6024
  inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
@@ -6080,6 +6081,18 @@ ${lanes.join("\n")}
6080
6081
  );
6081
6082
  }
6082
6083
  }
6084
+ function fsWatchWorkerHandlingTimestamp(fileOrDirectory, recursive, callback) {
6085
+ let modifiedTime = getModifiedTime3(fileOrDirectory) || missingFileModifiedTime;
6086
+ return fsWatchWorker(fileOrDirectory, recursive, (eventName, relativeFileName, currentModifiedTime) => {
6087
+ if (eventName === "change") {
6088
+ currentModifiedTime || (currentModifiedTime = getModifiedTime3(fileOrDirectory) || missingFileModifiedTime);
6089
+ if (currentModifiedTime.getTime() === modifiedTime.getTime())
6090
+ return;
6091
+ }
6092
+ modifiedTime = currentModifiedTime || getModifiedTime3(fileOrDirectory) || missingFileModifiedTime;
6093
+ callback(eventName, relativeFileName, modifiedTime);
6094
+ });
6095
+ }
6083
6096
  }
6084
6097
  function patchWriteFileEnsuringDirectory(sys2) {
6085
6098
  const originalWriteFile = sys2.writeFile;
@@ -6139,12 +6152,13 @@ ${lanes.join("\n")}
6139
6152
  let activeSession;
6140
6153
  let profilePath = "./profile.cpuprofile";
6141
6154
  const Buffer2 = require("buffer").Buffer;
6142
- const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
6155
+ const isMacOs = process.platform === "darwin";
6156
+ const isLinuxOrMacOs = process.platform === "linux" || isMacOs;
6143
6157
  const platform = _os.platform();
6144
6158
  const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
6145
6159
  const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
6146
6160
  const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
6147
- const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
6161
+ const fsSupportsRecursiveFsWatch = process.platform === "win32" || isMacOs;
6148
6162
  const getCurrentDirectory = memoize(() => process.cwd());
6149
6163
  const { watchFile: watchFile2, watchDirectory } = createSystemWatchFunctions({
6150
6164
  pollingWatchFileWorker: fsWatchFileWorker,
@@ -6164,6 +6178,7 @@ ${lanes.join("\n")}
6164
6178
  useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
6165
6179
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
6166
6180
  inodeWatching: isLinuxOrMacOs,
6181
+ fsWatchWithTimestamp: isMacOs,
6167
6182
  sysLog
6168
6183
  });
6169
6184
  const nodeSystem = {
@@ -7979,6 +7994,7 @@ ${lanes.join("\n")}
7979
7994
  Type_0_is_generic_and_can_only_be_indexed_for_reading: diag(2862, 1 /* Error */, "Type_0_is_generic_and_can_only_be_indexed_for_reading_2862", "Type '{0}' is generic and can only be indexed for reading."),
7980
7995
  A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values: diag(2863, 1 /* Error */, "A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values_2863", "A class cannot extend a primitive type like '{0}'. Classes can only extend constructable values."),
7981
7996
  A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types: diag(2864, 1 /* Error */, "A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types_2864", "A class cannot implement a primitive type like '{0}'. It can only implement other named object types."),
7997
+ Import_0_conflicts_with_local_value_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled: diag(2865, 1 /* Error */, "Import_0_conflicts_with_local_value_so_must_be_declared_with_a_type_only_import_when_isolatedModules_2865", "Import '{0}' conflicts with local value, so must be declared with a type-only import when 'isolatedModules' is enabled."),
7982
7998
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
7983
7999
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
7984
8000
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -12430,7 +12446,7 @@ ${lanes.join("\n")}
12430
12446
  return kind === 211 /* PropertyAccessExpression */ || kind === 166 /* QualifiedName */;
12431
12447
  }
12432
12448
  function isCallLikeOrFunctionLikeExpression(node) {
12433
- return isCallLikeExpression(node) || isFunctionLike(node);
12449
+ return isCallLikeExpression(node) || isFunctionExpressionOrArrowFunction(node);
12434
12450
  }
12435
12451
  function isCallLikeExpression(node) {
12436
12452
  switch (node.kind) {
@@ -20847,10 +20863,8 @@ ${lanes.join("\n")}
20847
20863
  return update(updated, original);
20848
20864
  }
20849
20865
  function createNumericLiteral(value, numericLiteralFlags = 0 /* None */) {
20850
- const text = typeof value === "number" ? value + "" : value;
20851
- Debug.assert(text.charCodeAt(0) !== 45 /* minus */, "Negative numbers should be created in combination with createPrefixUnaryExpression");
20852
20866
  const node = createBaseDeclaration(9 /* NumericLiteral */);
20853
- node.text = text;
20867
+ node.text = typeof value === "number" ? value + "" : value;
20854
20868
  node.numericLiteralFlags = numericLiteralFlags;
20855
20869
  if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */)
20856
20870
  node.transformFlags |= 1024 /* ContainsES2015 */;
@@ -46165,7 +46179,7 @@ ${lanes.join("\n")}
46165
46179
  const nodeLinks2 = getNodeLinks(node);
46166
46180
  cachedResolvedSignatures.push([nodeLinks2, nodeLinks2.resolvedSignature]);
46167
46181
  nodeLinks2.resolvedSignature = void 0;
46168
- if (isFunctionLike(node)) {
46182
+ if (isFunctionExpressionOrArrowFunction(node)) {
46169
46183
  const symbolLinks2 = getSymbolLinks(getSymbolOfDeclaration(node));
46170
46184
  const type = symbolLinks2.type;
46171
46185
  cachedTypes2.push([symbolLinks2, type]);
@@ -50727,6 +50741,8 @@ ${lanes.join("\n")}
50727
50741
  context.symbolDepth.set(id, depth + 1);
50728
50742
  }
50729
50743
  context.visitedTypes.add(typeId);
50744
+ const prevTrackedSymbols = context.trackedSymbols;
50745
+ context.trackedSymbols = void 0;
50730
50746
  const startLength = context.approximateLength;
50731
50747
  const result = transform2(type2);
50732
50748
  const addedLength = context.approximateLength - startLength;
@@ -50742,6 +50758,7 @@ ${lanes.join("\n")}
50742
50758
  if (id) {
50743
50759
  context.symbolDepth.set(id, depth);
50744
50760
  }
50761
+ context.trackedSymbols = prevTrackedSymbols;
50745
50762
  return result;
50746
50763
  function deepCloneOrReuseNode(node) {
50747
50764
  if (!nodeIsSynthesized(node) && getParseTreeNode(node) === node) {
@@ -51044,7 +51061,7 @@ ${lanes.join("\n")}
51044
51061
  context.approximateLength += symbolName(propertySymbol).length + 1;
51045
51062
  if (propertySymbol.flags & 98304 /* Accessor */) {
51046
51063
  const writeType = getWriteTypeOfSymbol(propertySymbol);
51047
- if (propertyType !== writeType) {
51064
+ if (propertyType !== writeType && !isErrorType(propertyType) && !isErrorType(writeType)) {
51048
51065
  const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */);
51049
51066
  const getterSignature = getSignatureFromDeclaration(getterDeclaration);
51050
51067
  typeElements.push(
@@ -51993,7 +52010,7 @@ ${lanes.join("\n")}
51993
52010
  return factory.createStringLiteral(name, !!singleQuote);
51994
52011
  }
51995
52012
  if (isNumericLiteralName(name) && startsWith(name, "-")) {
51996
- return factory.createComputedPropertyName(factory.createPrefixUnaryExpression(41 /* MinusToken */, factory.createNumericLiteral(Math.abs(+name))));
52013
+ return factory.createComputedPropertyName(factory.createNumericLiteral(+name));
51997
52014
  }
51998
52015
  return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
51999
52016
  }
@@ -77876,14 +77893,9 @@ ${lanes.join("\n")}
77876
77893
  case 15 /* NoSubstitutionTemplateLiteral */:
77877
77894
  case 11 /* StringLiteral */:
77878
77895
  return hasSkipDirectInferenceFlag(node) ? blockedStringType : getFreshTypeOfLiteralType(getStringLiteralType(node.text));
77879
- case 9 /* NumericLiteral */: {
77896
+ case 9 /* NumericLiteral */:
77880
77897
  checkGrammarNumericLiteral(node);
77881
- const value = +node.text;
77882
- if (!isFinite(value)) {
77883
- return numberType;
77884
- }
77885
- return getFreshTypeOfLiteralType(getNumberLiteralType(value));
77886
- }
77898
+ return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text));
77887
77899
  case 10 /* BigIntLiteral */:
77888
77900
  checkGrammarBigIntLiteral(node);
77889
77901
  return getFreshTypeOfLiteralType(getBigIntLiteralType({
@@ -82788,6 +82800,16 @@ ${lanes.join("\n")}
82788
82800
  if (targetFlags & excludedMeanings) {
82789
82801
  const message = node.kind === 281 /* ExportSpecifier */ ? Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
82790
82802
  error2(node, message, symbolToString(symbol));
82803
+ } else if (node.kind !== 281 /* ExportSpecifier */) {
82804
+ const appearsValueyToTranspiler = compilerOptions.isolatedModules && !findAncestor(node, isTypeOnlyImportOrExportDeclaration);
82805
+ if (appearsValueyToTranspiler && symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */)) {
82806
+ error2(
82807
+ node,
82808
+ Diagnostics.Import_0_conflicts_with_local_value_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled,
82809
+ symbolToString(symbol),
82810
+ isolatedModulesLikeFlagName
82811
+ );
82812
+ }
82791
82813
  }
82792
82814
  if (getIsolatedModules(compilerOptions) && !isTypeOnlyImportOrExportDeclaration(node) && !(node.flags & 33554432 /* Ambient */)) {
82793
82815
  const typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
@@ -84884,7 +84906,7 @@ ${lanes.join("\n")}
84884
84906
  if (enumResult)
84885
84907
  return enumResult;
84886
84908
  const literalValue = type.value;
84887
- return typeof literalValue === "object" ? factory.createBigIntLiteral(literalValue) : typeof literalValue === "string" ? factory.createStringLiteral(literalValue) : literalValue < 0 ? factory.createPrefixUnaryExpression(41 /* MinusToken */, factory.createNumericLiteral(Math.abs(literalValue))) : factory.createNumericLiteral(literalValue);
84909
+ return typeof literalValue === "object" ? factory.createBigIntLiteral(literalValue) : typeof literalValue === "number" ? factory.createNumericLiteral(literalValue) : factory.createStringLiteral(literalValue);
84888
84910
  }
84889
84911
  function createLiteralConstValue(node, tracker) {
84890
84912
  const type = getTypeOfSymbol(getSymbolOfDeclaration(node));
@@ -91664,7 +91686,7 @@ ${lanes.join("\n")}
91664
91686
  function transformEnumMemberDeclarationValue(member) {
91665
91687
  const value = resolver.getConstantValue(member);
91666
91688
  if (value !== void 0) {
91667
- return typeof value === "string" ? factory2.createStringLiteral(value) : value < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(Math.abs(value))) : factory2.createNumericLiteral(value);
91689
+ return typeof value === "string" ? factory2.createStringLiteral(value) : factory2.createNumericLiteral(value);
91668
91690
  } else {
91669
91691
  enableSubstitutionForNonQualifiedEnumMembers();
91670
91692
  if (member.initializer) {
@@ -106077,7 +106099,7 @@ ${lanes.join("\n")}
106077
106099
  if (labelExpressions === void 0) {
106078
106100
  labelExpressions = [];
106079
106101
  }
106080
- const expression = factory2.createNumericLiteral(Number.MAX_SAFE_INTEGER);
106102
+ const expression = factory2.createNumericLiteral(-1);
106081
106103
  if (labelExpressions[label] === void 0) {
106082
106104
  labelExpressions[label] = [expression];
106083
106105
  } else {
@@ -111988,8 +112010,7 @@ ${lanes.join("\n")}
111988
112010
  if (shouldStripInternal(m))
111989
112011
  return;
111990
112012
  const constValue = resolver.getConstantValue(m);
111991
- const newInitializer = constValue === void 0 ? void 0 : typeof constValue === "string" ? factory2.createStringLiteral(constValue) : constValue < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(Math.abs(constValue))) : factory2.createNumericLiteral(constValue);
111992
- return preserveJsDoc(factory2.updateEnumMember(m, m.name, newInitializer), m);
112013
+ return preserveJsDoc(factory2.updateEnumMember(m, m.name, constValue !== void 0 ? typeof constValue === "string" ? factory2.createStringLiteral(constValue) : factory2.createNumericLiteral(constValue) : void 0), m);
111993
112014
  }))
111994
112015
  ));
111995
112016
  }
@@ -134067,6 +134088,7 @@ ${lanes.join("\n")}
134067
134088
  case 127 /* YieldKeyword */:
134068
134089
  return highlightSpans(getYieldOccurrences(node));
134069
134090
  case 103 /* InKeyword */:
134091
+ case 147 /* OutKeyword */:
134070
134092
  return void 0;
134071
134093
  default:
134072
134094
  return isModifierKind(node.kind) && (isDeclaration(node.parent) || isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) : void 0;
@@ -172591,6 +172613,32 @@ ${options.prefix}` : "\n" : options.prefix
172591
172613
  }
172592
172614
  this.processCacheLocation(this.globalCachePath);
172593
172615
  }
172616
+ /** @internal */
172617
+ handleRequest(req) {
172618
+ switch (req.kind) {
172619
+ case "discover":
172620
+ this.install(req);
172621
+ break;
172622
+ case "closeProject":
172623
+ this.closeProject(req);
172624
+ break;
172625
+ case "typesRegistry": {
172626
+ const typesRegistry = {};
172627
+ this.typesRegistry.forEach((value, key) => {
172628
+ typesRegistry[key] = value;
172629
+ });
172630
+ const response = { kind: EventTypesRegistry, typesRegistry };
172631
+ this.sendResponse(response);
172632
+ break;
172633
+ }
172634
+ case "installPackage": {
172635
+ this.installPackage(req);
172636
+ break;
172637
+ }
172638
+ default:
172639
+ Debug.assertNever(req);
172640
+ }
172641
+ }
172594
172642
  closeProject(req) {
172595
172643
  this.closeWatchers(req.projectName);
172596
172644
  }
@@ -172648,7 +172696,7 @@ ${options.prefix}` : "\n" : options.prefix
172648
172696
  }
172649
172697
  /** @internal */
172650
172698
  installPackage(req) {
172651
- const { fileName, packageName, projectName, projectRootPath } = req;
172699
+ const { fileName, packageName, projectName, projectRootPath, id } = req;
172652
172700
  const cwd = forEachAncestorDirectory(getDirectoryPath(fileName), (directory) => {
172653
172701
  if (this.installTypingHost.fileExists(combinePaths(directory, "package.json"))) {
172654
172702
  return directory;
@@ -172660,6 +172708,7 @@ ${options.prefix}` : "\n" : options.prefix
172660
172708
  const response = {
172661
172709
  kind: ActionPackageInstalled,
172662
172710
  projectName,
172711
+ id,
172663
172712
  success,
172664
172713
  message
172665
172714
  };
@@ -172669,6 +172718,7 @@ ${options.prefix}` : "\n" : options.prefix
172669
172718
  const response = {
172670
172719
  kind: ActionPackageInstalled,
172671
172720
  projectName,
172721
+ id,
172672
172722
  success: false,
172673
172723
  message: "Could not determine a project root path."
172674
172724
  };
@@ -173989,8 +174039,9 @@ ${options.prefix}` : "\n" : options.prefix
173989
174039
  return !typeAcquisition || !typeAcquisition.enable ? emptyArray2 : typings;
173990
174040
  }
173991
174041
  onProjectClosed(project) {
173992
- this.perProjectCache.delete(project.getProjectName());
173993
- this.installer.onProjectClosed(project);
174042
+ if (this.perProjectCache.delete(project.getProjectName())) {
174043
+ this.installer.onProjectClosed(project);
174044
+ }
173994
174045
  }
173995
174046
  };
173996
174047
  }
@@ -183967,6 +184018,192 @@ ${e.message}`;
183967
184018
  }
183968
184019
  });
183969
184020
 
184021
+ // src/server/typingInstallerAdapter.ts
184022
+ var _TypingsInstallerAdapter, TypingsInstallerAdapter;
184023
+ var init_typingInstallerAdapter = __esm({
184024
+ "src/server/typingInstallerAdapter.ts"() {
184025
+ "use strict";
184026
+ init_ts7();
184027
+ init_ts_server3();
184028
+ _TypingsInstallerAdapter = class _TypingsInstallerAdapter {
184029
+ constructor(telemetryEnabled, logger, host, globalTypingsCacheLocation, event, maxActiveRequestCount) {
184030
+ this.telemetryEnabled = telemetryEnabled;
184031
+ this.logger = logger;
184032
+ this.host = host;
184033
+ this.globalTypingsCacheLocation = globalTypingsCacheLocation;
184034
+ this.event = event;
184035
+ this.maxActiveRequestCount = maxActiveRequestCount;
184036
+ this.activeRequestCount = 0;
184037
+ this.requestQueue = createQueue();
184038
+ this.requestMap = /* @__PURE__ */ new Map();
184039
+ // Maps project name to newest requestQueue entry for that project
184040
+ /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
184041
+ this.requestedRegistry = false;
184042
+ this.packageInstallId = 0;
184043
+ }
184044
+ isKnownTypesPackageName(name) {
184045
+ var _a;
184046
+ const validationResult = ts_JsTyping_exports.validatePackageName(name);
184047
+ if (validationResult !== ts_JsTyping_exports.NameValidationResult.Ok) {
184048
+ return false;
184049
+ }
184050
+ if (!this.requestedRegistry) {
184051
+ this.requestedRegistry = true;
184052
+ this.installer.send({ kind: "typesRegistry" });
184053
+ }
184054
+ return !!((_a = this.typesRegistryCache) == null ? void 0 : _a.has(name));
184055
+ }
184056
+ installPackage(options) {
184057
+ this.packageInstallId++;
184058
+ const request = { kind: "installPackage", ...options, id: this.packageInstallId };
184059
+ const promise = new Promise((resolve, reject) => {
184060
+ (this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve, reject });
184061
+ });
184062
+ this.installer.send(request);
184063
+ return promise;
184064
+ }
184065
+ attach(projectService) {
184066
+ this.projectService = projectService;
184067
+ this.installer = this.createInstallerProcess();
184068
+ }
184069
+ onProjectClosed(p) {
184070
+ this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" });
184071
+ }
184072
+ enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports) {
184073
+ const request = createInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
184074
+ if (this.logger.hasLevel(3 /* verbose */)) {
184075
+ this.logger.info(`TIAdapter:: Scheduling throttled operation:${stringifyIndented(request)}`);
184076
+ }
184077
+ if (this.activeRequestCount < this.maxActiveRequestCount) {
184078
+ this.scheduleRequest(request);
184079
+ } else {
184080
+ if (this.logger.hasLevel(3 /* verbose */)) {
184081
+ this.logger.info(`TIAdapter:: Deferring request for: ${request.projectName}`);
184082
+ }
184083
+ this.requestQueue.enqueue(request);
184084
+ this.requestMap.set(request.projectName, request);
184085
+ }
184086
+ }
184087
+ handleMessage(response) {
184088
+ var _a, _b;
184089
+ if (this.logger.hasLevel(3 /* verbose */)) {
184090
+ this.logger.info(`TIAdapter:: Received response:${stringifyIndented(response)}`);
184091
+ }
184092
+ switch (response.kind) {
184093
+ case EventTypesRegistry:
184094
+ this.typesRegistryCache = new Map(Object.entries(response.typesRegistry));
184095
+ break;
184096
+ case ActionPackageInstalled: {
184097
+ const promise = (_a = this.packageInstalledPromise) == null ? void 0 : _a.get(response.id);
184098
+ Debug.assertIsDefined(promise, "Should find the promise for package install");
184099
+ (_b = this.packageInstalledPromise) == null ? void 0 : _b.delete(response.id);
184100
+ if (response.success) {
184101
+ promise.resolve({ successMessage: response.message });
184102
+ } else {
184103
+ promise.reject(response.message);
184104
+ }
184105
+ this.projectService.updateTypingsForProject(response);
184106
+ this.event(response, "setTypings");
184107
+ break;
184108
+ }
184109
+ case EventInitializationFailed: {
184110
+ const body = {
184111
+ message: response.message
184112
+ };
184113
+ const eventName = "typesInstallerInitializationFailed";
184114
+ this.event(body, eventName);
184115
+ break;
184116
+ }
184117
+ case EventBeginInstallTypes: {
184118
+ const body = {
184119
+ eventId: response.eventId,
184120
+ packages: response.packagesToInstall
184121
+ };
184122
+ const eventName = "beginInstallTypes";
184123
+ this.event(body, eventName);
184124
+ break;
184125
+ }
184126
+ case EventEndInstallTypes: {
184127
+ if (this.telemetryEnabled) {
184128
+ const body2 = {
184129
+ telemetryEventName: "typingsInstalled",
184130
+ payload: {
184131
+ installedPackages: response.packagesToInstall.join(","),
184132
+ installSuccess: response.installSuccess,
184133
+ typingsInstallerVersion: response.typingsInstallerVersion
184134
+ }
184135
+ };
184136
+ const eventName2 = "telemetry";
184137
+ this.event(body2, eventName2);
184138
+ }
184139
+ const body = {
184140
+ eventId: response.eventId,
184141
+ packages: response.packagesToInstall,
184142
+ success: response.installSuccess
184143
+ };
184144
+ const eventName = "endInstallTypes";
184145
+ this.event(body, eventName);
184146
+ break;
184147
+ }
184148
+ case ActionInvalidate: {
184149
+ this.projectService.updateTypingsForProject(response);
184150
+ break;
184151
+ }
184152
+ case ActionSet: {
184153
+ if (this.activeRequestCount > 0) {
184154
+ this.activeRequestCount--;
184155
+ } else {
184156
+ Debug.fail("TIAdapter:: Received too many responses");
184157
+ }
184158
+ while (!this.requestQueue.isEmpty()) {
184159
+ const queuedRequest = this.requestQueue.dequeue();
184160
+ if (this.requestMap.get(queuedRequest.projectName) === queuedRequest) {
184161
+ this.requestMap.delete(queuedRequest.projectName);
184162
+ this.scheduleRequest(queuedRequest);
184163
+ break;
184164
+ }
184165
+ if (this.logger.hasLevel(3 /* verbose */)) {
184166
+ this.logger.info(`TIAdapter:: Skipping defunct request for: ${queuedRequest.projectName}`);
184167
+ }
184168
+ }
184169
+ this.projectService.updateTypingsForProject(response);
184170
+ this.event(response, "setTypings");
184171
+ break;
184172
+ }
184173
+ case ActionWatchTypingLocations:
184174
+ this.projectService.watchTypingLocations(response);
184175
+ break;
184176
+ default:
184177
+ assertType(response);
184178
+ }
184179
+ }
184180
+ scheduleRequest(request) {
184181
+ if (this.logger.hasLevel(3 /* verbose */)) {
184182
+ this.logger.info(`TIAdapter:: Scheduling request for: ${request.projectName}`);
184183
+ }
184184
+ this.activeRequestCount++;
184185
+ this.host.setTimeout(
184186
+ () => {
184187
+ if (this.logger.hasLevel(3 /* verbose */)) {
184188
+ this.logger.info(`TIAdapter:: Sending request:${stringifyIndented(request)}`);
184189
+ }
184190
+ this.installer.send(request);
184191
+ },
184192
+ _TypingsInstallerAdapter.requestDelayMillis,
184193
+ `${request.projectName}::${request.kind}`
184194
+ );
184195
+ }
184196
+ };
184197
+ // This number is essentially arbitrary. Processing more than one typings request
184198
+ // at a time makes sense, but having too many in the pipe results in a hang
184199
+ // (see https://github.com/nodejs/node/issues/7657).
184200
+ // It would be preferable to base our limit on the amount of space left in the
184201
+ // buffer, but we have yet to find a way to retrieve that value.
184202
+ _TypingsInstallerAdapter.requestDelayMillis = 100;
184203
+ TypingsInstallerAdapter = _TypingsInstallerAdapter;
184204
+ }
184205
+ });
184206
+
183970
184207
  // src/server/_namespaces/ts.server.ts
183971
184208
  var ts_server_exports3 = {};
183972
184209
  __export(ts_server_exports3, {
@@ -184014,6 +184251,7 @@ ${e.message}`;
184014
184251
  TextStorage: () => TextStorage,
184015
184252
  ThrottledOperations: () => ThrottledOperations,
184016
184253
  TypingsCache: () => TypingsCache,
184254
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
184017
184255
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
184018
184256
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
184019
184257
  asNormalizedPath: () => asNormalizedPath,
@@ -184082,6 +184320,7 @@ ${e.message}`;
184082
184320
  init_packageJsonCache();
184083
184321
  init_session();
184084
184322
  init_scriptVersionCache();
184323
+ init_typingInstallerAdapter();
184085
184324
  }
184086
184325
  });
184087
184326
 
@@ -186436,6 +186675,7 @@ ${e.message}`;
186436
186675
  TextStorage: () => TextStorage,
186437
186676
  ThrottledOperations: () => ThrottledOperations,
186438
186677
  TypingsCache: () => TypingsCache,
186678
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
186439
186679
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
186440
186680
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
186441
186681
  asNormalizedPath: () => asNormalizedPath,