@typescript-deploys/pr-build 5.4.0-pr-56301-7 → 5.4.0-pr-56403-3

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.20231113`;
21
+ var version = `${versionMajorMinor}.0-insiders.20231115`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -4521,6 +4521,7 @@ function createSystemWatchFunctions({
4521
4521
  useNonPollingWatchers,
4522
4522
  tscWatchDirectory,
4523
4523
  inodeWatching,
4524
+ fsWatchWithTimestamp,
4524
4525
  sysLog: sysLog2
4525
4526
  }) {
4526
4527
  const pollingWatches = /* @__PURE__ */ new Map();
@@ -4759,7 +4760,7 @@ function createSystemWatchFunctions({
4759
4760
  return watchPresentFileSystemEntryWithFsWatchFile();
4760
4761
  }
4761
4762
  try {
4762
- const presentWatcher = fsWatchWorker(
4763
+ const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
4763
4764
  fileOrDirectory,
4764
4765
  recursive,
4765
4766
  inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
@@ -4822,6 +4823,18 @@ function createSystemWatchFunctions({
4822
4823
  );
4823
4824
  }
4824
4825
  }
4826
+ function fsWatchWorkerHandlingTimestamp(fileOrDirectory, recursive, callback) {
4827
+ let modifiedTime = getModifiedTime3(fileOrDirectory) || missingFileModifiedTime;
4828
+ return fsWatchWorker(fileOrDirectory, recursive, (eventName, relativeFileName, currentModifiedTime) => {
4829
+ if (eventName === "change") {
4830
+ currentModifiedTime || (currentModifiedTime = getModifiedTime3(fileOrDirectory) || missingFileModifiedTime);
4831
+ if (currentModifiedTime.getTime() === modifiedTime.getTime())
4832
+ return;
4833
+ }
4834
+ modifiedTime = currentModifiedTime || getModifiedTime3(fileOrDirectory) || missingFileModifiedTime;
4835
+ callback(eventName, relativeFileName, modifiedTime);
4836
+ });
4837
+ }
4825
4838
  }
4826
4839
  function patchWriteFileEnsuringDirectory(sys2) {
4827
4840
  const originalWriteFile = sys2.writeFile;
@@ -4850,12 +4863,13 @@ var sys = (() => {
4850
4863
  let activeSession;
4851
4864
  let profilePath = "./profile.cpuprofile";
4852
4865
  const Buffer = require("buffer").Buffer;
4853
- const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
4866
+ const isMacOs = process.platform === "darwin";
4867
+ const isLinuxOrMacOs = process.platform === "linux" || isMacOs;
4854
4868
  const platform = _os.platform();
4855
4869
  const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
4856
4870
  const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
4857
4871
  const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
4858
- const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
4872
+ const fsSupportsRecursiveFsWatch = process.platform === "win32" || isMacOs;
4859
4873
  const getCurrentDirectory = memoize(() => process.cwd());
4860
4874
  const { watchFile: watchFile2, watchDirectory } = createSystemWatchFunctions({
4861
4875
  pollingWatchFileWorker: fsWatchFileWorker,
@@ -4875,6 +4889,7 @@ var sys = (() => {
4875
4889
  useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
4876
4890
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
4877
4891
  inodeWatching: isLinuxOrMacOs,
4892
+ fsWatchWithTimestamp: isMacOs,
4878
4893
  sysLog
4879
4894
  });
4880
4895
  const nodeSystem = {
@@ -31217,6 +31232,9 @@ var Parser;
31217
31232
  function nextTokenIsStringLiteral() {
31218
31233
  return nextToken() === 11 /* StringLiteral */;
31219
31234
  }
31235
+ function nextTokenIsFromKeyword() {
31236
+ return nextToken() === 161 /* FromKeyword */;
31237
+ }
31220
31238
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
31221
31239
  nextToken();
31222
31240
  return !scanner.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
@@ -31912,7 +31930,7 @@ var Parser;
31912
31930
  identifier = parseIdentifier();
31913
31931
  }
31914
31932
  let isTypeOnly = false;
31915
- if (token() !== 161 /* FromKeyword */ && (identifier == null ? void 0 : identifier.escapedText) === "type" && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
31933
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
31916
31934
  isTypeOnly = true;
31917
31935
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
31918
31936
  }
@@ -40407,6 +40425,9 @@ function createBinder() {
40407
40425
  for (let i = 0; i < clauses.length; i++) {
40408
40426
  const clauseStart = i;
40409
40427
  while (!clauses[i].statements.length && i + 1 < clauses.length) {
40428
+ if (fallthroughFlow === unreachableFlow) {
40429
+ currentFlow = preSwitchCaseFlow;
40430
+ }
40410
40431
  bind(clauses[i]);
40411
40432
  i++;
40412
40433
  }
@@ -73947,9 +73968,6 @@ function createTypeChecker(host) {
73947
73968
  }
73948
73969
  switch (node.operand.kind) {
73949
73970
  case 9 /* NumericLiteral */:
73950
- if (operandType === numberType) {
73951
- return numberType;
73952
- }
73953
73971
  switch (node.operator) {
73954
73972
  case 41 /* MinusToken */:
73955
73973
  return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text));
package/lib/tsserver.js CHANGED
@@ -2330,7 +2330,7 @@ module.exports = __toCommonJS(server_exports);
2330
2330
 
2331
2331
  // src/compiler/corePublic.ts
2332
2332
  var versionMajorMinor = "5.4";
2333
- var version = `${versionMajorMinor}.0-insiders.20231113`;
2333
+ var version = `${versionMajorMinor}.0-insiders.20231115`;
2334
2334
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2335
2335
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2336
2336
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -8041,6 +8041,7 @@ function createSystemWatchFunctions({
8041
8041
  useNonPollingWatchers,
8042
8042
  tscWatchDirectory,
8043
8043
  inodeWatching,
8044
+ fsWatchWithTimestamp,
8044
8045
  sysLog: sysLog2
8045
8046
  }) {
8046
8047
  const pollingWatches = /* @__PURE__ */ new Map();
@@ -8279,7 +8280,7 @@ function createSystemWatchFunctions({
8279
8280
  return watchPresentFileSystemEntryWithFsWatchFile();
8280
8281
  }
8281
8282
  try {
8282
- const presentWatcher = fsWatchWorker(
8283
+ const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
8283
8284
  fileOrDirectory,
8284
8285
  recursive,
8285
8286
  inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
@@ -8342,6 +8343,18 @@ function createSystemWatchFunctions({
8342
8343
  );
8343
8344
  }
8344
8345
  }
8346
+ function fsWatchWorkerHandlingTimestamp(fileOrDirectory, recursive, callback) {
8347
+ let modifiedTime = getModifiedTime3(fileOrDirectory) || missingFileModifiedTime;
8348
+ return fsWatchWorker(fileOrDirectory, recursive, (eventName, relativeFileName, currentModifiedTime) => {
8349
+ if (eventName === "change") {
8350
+ currentModifiedTime || (currentModifiedTime = getModifiedTime3(fileOrDirectory) || missingFileModifiedTime);
8351
+ if (currentModifiedTime.getTime() === modifiedTime.getTime())
8352
+ return;
8353
+ }
8354
+ modifiedTime = currentModifiedTime || getModifiedTime3(fileOrDirectory) || missingFileModifiedTime;
8355
+ callback(eventName, relativeFileName, modifiedTime);
8356
+ });
8357
+ }
8345
8358
  }
8346
8359
  function patchWriteFileEnsuringDirectory(sys2) {
8347
8360
  const originalWriteFile = sys2.writeFile;
@@ -8370,12 +8383,13 @@ var sys = (() => {
8370
8383
  let activeSession;
8371
8384
  let profilePath = "./profile.cpuprofile";
8372
8385
  const Buffer2 = require("buffer").Buffer;
8373
- const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
8386
+ const isMacOs = process.platform === "darwin";
8387
+ const isLinuxOrMacOs = process.platform === "linux" || isMacOs;
8374
8388
  const platform = _os.platform();
8375
8389
  const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
8376
8390
  const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
8377
8391
  const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
8378
- const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
8392
+ const fsSupportsRecursiveFsWatch = process.platform === "win32" || isMacOs;
8379
8393
  const getCurrentDirectory = memoize(() => process.cwd());
8380
8394
  const { watchFile: watchFile2, watchDirectory } = createSystemWatchFunctions({
8381
8395
  pollingWatchFileWorker: fsWatchFileWorker,
@@ -8395,6 +8409,7 @@ var sys = (() => {
8395
8409
  useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
8396
8410
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
8397
8411
  inodeWatching: isLinuxOrMacOs,
8412
+ fsWatchWithTimestamp: isMacOs,
8398
8413
  sysLog
8399
8414
  });
8400
8415
  const nodeSystem = {
@@ -35625,6 +35640,9 @@ var Parser;
35625
35640
  function nextTokenIsStringLiteral() {
35626
35641
  return nextToken() === 11 /* StringLiteral */;
35627
35642
  }
35643
+ function nextTokenIsFromKeyword() {
35644
+ return nextToken() === 161 /* FromKeyword */;
35645
+ }
35628
35646
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
35629
35647
  nextToken();
35630
35648
  return !scanner2.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
@@ -36320,7 +36338,7 @@ var Parser;
36320
36338
  identifier = parseIdentifier();
36321
36339
  }
36322
36340
  let isTypeOnly = false;
36323
- if (token() !== 161 /* FromKeyword */ && (identifier == null ? void 0 : identifier.escapedText) === "type" && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
36341
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
36324
36342
  isTypeOnly = true;
36325
36343
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
36326
36344
  }
@@ -45070,6 +45088,9 @@ function createBinder() {
45070
45088
  for (let i = 0; i < clauses.length; i++) {
45071
45089
  const clauseStart = i;
45072
45090
  while (!clauses[i].statements.length && i + 1 < clauses.length) {
45091
+ if (fallthroughFlow === unreachableFlow) {
45092
+ currentFlow = preSwitchCaseFlow;
45093
+ }
45073
45094
  bind(clauses[i]);
45074
45095
  i++;
45075
45096
  }
@@ -78655,9 +78676,6 @@ function createTypeChecker(host) {
78655
78676
  }
78656
78677
  switch (node.operand.kind) {
78657
78678
  case 9 /* NumericLiteral */:
78658
- if (operandType === numberType) {
78659
- return numberType;
78660
- }
78661
78679
  switch (node.operator) {
78662
78680
  case 41 /* MinusToken */:
78663
78681
  return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text));
@@ -161081,6 +161099,11 @@ function getImportStatementCompletionInfo(contextToken, sourceFile) {
161081
161099
  }
161082
161100
  return void 0;
161083
161101
  }
161102
+ if (isExportDeclaration(parent2) && contextToken.kind === 42 /* AsteriskToken */ || isNamedExports(parent2) && contextToken.kind === 20 /* CloseBraceToken */) {
161103
+ isKeywordOnlyCompletion = true;
161104
+ keywordCompletion = 161 /* FromKeyword */;
161105
+ return void 0;
161106
+ }
161084
161107
  if (isImportKeyword(contextToken) && isSourceFile(parent2)) {
161085
161108
  keywordCompletion = 156 /* TypeKeyword */;
161086
161109
  return contextToken;
@@ -175247,6 +175270,7 @@ __export(ts_server_exports3, {
175247
175270
  TextStorage: () => TextStorage,
175248
175271
  ThrottledOperations: () => ThrottledOperations,
175249
175272
  TypingsCache: () => TypingsCache,
175273
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
175250
175274
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
175251
175275
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
175252
175276
  asNormalizedPath: () => asNormalizedPath,
@@ -175368,6 +175392,32 @@ var TypingsInstaller = class {
175368
175392
  }
175369
175393
  this.processCacheLocation(this.globalCachePath);
175370
175394
  }
175395
+ /** @internal */
175396
+ handleRequest(req) {
175397
+ switch (req.kind) {
175398
+ case "discover":
175399
+ this.install(req);
175400
+ break;
175401
+ case "closeProject":
175402
+ this.closeProject(req);
175403
+ break;
175404
+ case "typesRegistry": {
175405
+ const typesRegistry = {};
175406
+ this.typesRegistry.forEach((value, key) => {
175407
+ typesRegistry[key] = value;
175408
+ });
175409
+ const response = { kind: EventTypesRegistry, typesRegistry };
175410
+ this.sendResponse(response);
175411
+ break;
175412
+ }
175413
+ case "installPackage": {
175414
+ this.installPackage(req);
175415
+ break;
175416
+ }
175417
+ default:
175418
+ Debug.assertNever(req);
175419
+ }
175420
+ }
175371
175421
  closeProject(req) {
175372
175422
  this.closeWatchers(req.projectName);
175373
175423
  }
@@ -176696,8 +176746,9 @@ var TypingsCache = class {
176696
176746
  return !typeAcquisition || !typeAcquisition.enable ? emptyArray2 : typings;
176697
176747
  }
176698
176748
  onProjectClosed(project) {
176699
- this.perProjectCache.delete(project.getProjectName());
176700
- this.installer.onProjectClosed(project);
176749
+ if (this.perProjectCache.delete(project.getProjectName())) {
176750
+ this.installer.onProjectClosed(project);
176751
+ }
176701
176752
  }
176702
176753
  };
176703
176754
 
@@ -186625,6 +186676,179 @@ var LineLeaf = class {
186625
186676
  }
186626
186677
  };
186627
186678
 
186679
+ // src/server/typingInstallerAdapter.ts
186680
+ var _TypingsInstallerAdapter = class _TypingsInstallerAdapter {
186681
+ constructor(telemetryEnabled, logger, host, globalTypingsCacheLocation, event, maxActiveRequestCount) {
186682
+ this.telemetryEnabled = telemetryEnabled;
186683
+ this.logger = logger;
186684
+ this.host = host;
186685
+ this.globalTypingsCacheLocation = globalTypingsCacheLocation;
186686
+ this.event = event;
186687
+ this.maxActiveRequestCount = maxActiveRequestCount;
186688
+ this.activeRequestCount = 0;
186689
+ this.requestQueue = createQueue();
186690
+ this.requestMap = /* @__PURE__ */ new Map();
186691
+ // Maps project name to newest requestQueue entry for that project
186692
+ /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
186693
+ this.requestedRegistry = false;
186694
+ }
186695
+ isKnownTypesPackageName(name) {
186696
+ var _a;
186697
+ const validationResult = ts_JsTyping_exports.validatePackageName(name);
186698
+ if (validationResult !== ts_JsTyping_exports.NameValidationResult.Ok) {
186699
+ return false;
186700
+ }
186701
+ if (!this.requestedRegistry) {
186702
+ this.requestedRegistry = true;
186703
+ this.installer.send({ kind: "typesRegistry" });
186704
+ }
186705
+ return !!((_a = this.typesRegistryCache) == null ? void 0 : _a.has(name));
186706
+ }
186707
+ installPackage(options) {
186708
+ this.installer.send({ kind: "installPackage", ...options });
186709
+ Debug.assert(this.packageInstalledPromise === void 0);
186710
+ return new Promise((resolve, reject) => {
186711
+ this.packageInstalledPromise = { resolve, reject };
186712
+ });
186713
+ }
186714
+ attach(projectService) {
186715
+ this.projectService = projectService;
186716
+ this.installer = this.createInstallerProcess();
186717
+ }
186718
+ onProjectClosed(p) {
186719
+ this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" });
186720
+ }
186721
+ enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports) {
186722
+ const request = createInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
186723
+ if (this.logger.hasLevel(3 /* verbose */)) {
186724
+ this.logger.info(`TIAdapter:: Scheduling throttled operation:${stringifyIndented(request)}`);
186725
+ }
186726
+ if (this.activeRequestCount < this.maxActiveRequestCount) {
186727
+ this.scheduleRequest(request);
186728
+ } else {
186729
+ if (this.logger.hasLevel(3 /* verbose */)) {
186730
+ this.logger.info(`TIAdapter:: Deferring request for: ${request.projectName}`);
186731
+ }
186732
+ this.requestQueue.enqueue(request);
186733
+ this.requestMap.set(request.projectName, request);
186734
+ }
186735
+ }
186736
+ handleMessage(response) {
186737
+ if (this.logger.hasLevel(3 /* verbose */)) {
186738
+ this.logger.info(`TIAdapter:: Received response:${stringifyIndented(response)}`);
186739
+ }
186740
+ switch (response.kind) {
186741
+ case EventTypesRegistry:
186742
+ this.typesRegistryCache = new Map(Object.entries(response.typesRegistry));
186743
+ break;
186744
+ case ActionPackageInstalled: {
186745
+ const { success, message } = response;
186746
+ if (success) {
186747
+ this.packageInstalledPromise.resolve({ successMessage: message });
186748
+ } else {
186749
+ this.packageInstalledPromise.reject(message);
186750
+ }
186751
+ this.packageInstalledPromise = void 0;
186752
+ this.projectService.updateTypingsForProject(response);
186753
+ this.event(response, "setTypings");
186754
+ break;
186755
+ }
186756
+ case EventInitializationFailed: {
186757
+ const body = {
186758
+ message: response.message
186759
+ };
186760
+ const eventName = "typesInstallerInitializationFailed";
186761
+ this.event(body, eventName);
186762
+ break;
186763
+ }
186764
+ case EventBeginInstallTypes: {
186765
+ const body = {
186766
+ eventId: response.eventId,
186767
+ packages: response.packagesToInstall
186768
+ };
186769
+ const eventName = "beginInstallTypes";
186770
+ this.event(body, eventName);
186771
+ break;
186772
+ }
186773
+ case EventEndInstallTypes: {
186774
+ if (this.telemetryEnabled) {
186775
+ const body2 = {
186776
+ telemetryEventName: "typingsInstalled",
186777
+ payload: {
186778
+ installedPackages: response.packagesToInstall.join(","),
186779
+ installSuccess: response.installSuccess,
186780
+ typingsInstallerVersion: response.typingsInstallerVersion
186781
+ }
186782
+ };
186783
+ const eventName2 = "telemetry";
186784
+ this.event(body2, eventName2);
186785
+ }
186786
+ const body = {
186787
+ eventId: response.eventId,
186788
+ packages: response.packagesToInstall,
186789
+ success: response.installSuccess
186790
+ };
186791
+ const eventName = "endInstallTypes";
186792
+ this.event(body, eventName);
186793
+ break;
186794
+ }
186795
+ case ActionInvalidate: {
186796
+ this.projectService.updateTypingsForProject(response);
186797
+ break;
186798
+ }
186799
+ case ActionSet: {
186800
+ if (this.activeRequestCount > 0) {
186801
+ this.activeRequestCount--;
186802
+ } else {
186803
+ Debug.fail("TIAdapter:: Received too many responses");
186804
+ }
186805
+ while (!this.requestQueue.isEmpty()) {
186806
+ const queuedRequest = this.requestQueue.dequeue();
186807
+ if (this.requestMap.get(queuedRequest.projectName) === queuedRequest) {
186808
+ this.requestMap.delete(queuedRequest.projectName);
186809
+ this.scheduleRequest(queuedRequest);
186810
+ break;
186811
+ }
186812
+ if (this.logger.hasLevel(3 /* verbose */)) {
186813
+ this.logger.info(`TIAdapter:: Skipping defunct request for: ${queuedRequest.projectName}`);
186814
+ }
186815
+ }
186816
+ this.projectService.updateTypingsForProject(response);
186817
+ this.event(response, "setTypings");
186818
+ break;
186819
+ }
186820
+ case ActionWatchTypingLocations:
186821
+ this.projectService.watchTypingLocations(response);
186822
+ break;
186823
+ default:
186824
+ assertType(response);
186825
+ }
186826
+ }
186827
+ scheduleRequest(request) {
186828
+ if (this.logger.hasLevel(3 /* verbose */)) {
186829
+ this.logger.info(`TIAdapter:: Scheduling request for: ${request.projectName}`);
186830
+ }
186831
+ this.activeRequestCount++;
186832
+ this.host.setTimeout(
186833
+ () => {
186834
+ if (this.logger.hasLevel(3 /* verbose */)) {
186835
+ this.logger.info(`TIAdapter:: Sending request:${stringifyIndented(request)}`);
186836
+ }
186837
+ this.installer.send(request);
186838
+ },
186839
+ _TypingsInstallerAdapter.requestDelayMillis,
186840
+ `${request.projectName}::${request.kind}`
186841
+ );
186842
+ }
186843
+ };
186844
+ // This number is essentially arbitrary. Processing more than one typings request
186845
+ // at a time makes sense, but having too many in the pipe results in a hang
186846
+ // (see https://github.com/nodejs/node/issues/7657).
186847
+ // It would be preferable to base our limit on the amount of space left in the
186848
+ // buffer, but we have yet to find a way to retrieve that value.
186849
+ _TypingsInstallerAdapter.requestDelayMillis = 100;
186850
+ var TypingsInstallerAdapter = _TypingsInstallerAdapter;
186851
+
186628
186852
  // src/tsserver/_namespaces/ts.server.ts
186629
186853
  var ts_server_exports4 = {};
186630
186854
  __export(ts_server_exports4, {
@@ -186672,6 +186896,7 @@ __export(ts_server_exports4, {
186672
186896
  TextStorage: () => TextStorage,
186673
186897
  ThrottledOperations: () => ThrottledOperations,
186674
186898
  TypingsCache: () => TypingsCache,
186899
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
186675
186900
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
186676
186901
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
186677
186902
  asNormalizedPath: () => asNormalizedPath,
@@ -186791,7 +187016,7 @@ function initializeNodeSystem() {
186791
187016
  const sys2 = Debug.checkDefined(sys);
186792
187017
  const childProcess = require("child_process");
186793
187018
  const fs = require("fs");
186794
- class Logger6 {
187019
+ class Logger7 {
186795
187020
  constructor(logFilename, traceToConsole, level) {
186796
187021
  this.logFilename = logFilename;
186797
187022
  this.traceToConsole = traceToConsole;
@@ -186858,7 +187083,7 @@ function initializeNodeSystem() {
186858
187083
  s = `[${nowString()}] ${s}
186859
187084
  `;
186860
187085
  if (!this.inGroup || this.firstInGroup) {
186861
- const prefix = Logger6.padStringRight(type + " " + this.seq.toString(), " ");
187086
+ const prefix = Logger7.padStringRight(type + " " + this.seq.toString(), " ");
186862
187087
  s = prefix + s;
186863
187088
  }
186864
187089
  this.write(s, type);
@@ -186995,7 +187220,7 @@ function initializeNodeSystem() {
186995
187220
  const unsubstitutedLogFileName = cmdLineLogFileName ? stripQuotes(cmdLineLogFileName) : envLogOptions.logToFile ? envLogOptions.file || libDirectory + "/.log" + process.pid.toString() : void 0;
186996
187221
  const substitutedLogFileName = unsubstitutedLogFileName ? unsubstitutedLogFileName.replace("PID", process.pid.toString()) : void 0;
186997
187222
  const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
186998
- return new Logger6(substitutedLogFileName, envLogOptions.traceToConsole, logVerbosity);
187223
+ return new Logger7(substitutedLogFileName, envLogOptions.traceToConsole, logVerbosity);
186999
187224
  }
187000
187225
  function writeMessage(buf) {
187001
187226
  if (!canWrite) {
@@ -187055,45 +187280,22 @@ function startNodeSession(options, logger, cancellationToken) {
187055
187280
  output: process.stdout,
187056
187281
  terminal: false
187057
187282
  });
187058
- const _NodeTypingsInstaller = class _NodeTypingsInstaller {
187283
+ const _NodeTypingsInstallerAdapter = class _NodeTypingsInstallerAdapter extends TypingsInstallerAdapter {
187059
187284
  constructor(telemetryEnabled2, logger2, host, globalTypingsCacheLocation, typingSafeListLocation2, typesMapLocation2, npmLocation2, validateDefaultNpmLocation2, event) {
187060
- this.telemetryEnabled = telemetryEnabled2;
187061
- this.logger = logger2;
187062
- this.host = host;
187063
- this.globalTypingsCacheLocation = globalTypingsCacheLocation;
187285
+ super(
187286
+ telemetryEnabled2,
187287
+ logger2,
187288
+ host,
187289
+ globalTypingsCacheLocation,
187290
+ event,
187291
+ _NodeTypingsInstallerAdapter.maxActiveRequestCount
187292
+ );
187064
187293
  this.typingSafeListLocation = typingSafeListLocation2;
187065
187294
  this.typesMapLocation = typesMapLocation2;
187066
187295
  this.npmLocation = npmLocation2;
187067
187296
  this.validateDefaultNpmLocation = validateDefaultNpmLocation2;
187068
- this.event = event;
187069
- this.activeRequestCount = 0;
187070
- this.requestQueue = createQueue();
187071
- this.requestMap = /* @__PURE__ */ new Map();
187072
- // Maps operation ID to newest requestQueue entry with that ID
187073
- /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
187074
- this.requestedRegistry = false;
187075
- }
187076
- isKnownTypesPackageName(name) {
187077
- const validationResult = ts_JsTyping_exports.validatePackageName(name);
187078
- if (validationResult !== ts_JsTyping_exports.NameValidationResult.Ok) {
187079
- return false;
187080
- }
187081
- if (this.requestedRegistry) {
187082
- return !!this.typesRegistryCache && this.typesRegistryCache.has(name);
187083
- }
187084
- this.requestedRegistry = true;
187085
- this.send({ kind: "typesRegistry" });
187086
- return false;
187087
187297
  }
187088
- installPackage(options2) {
187089
- this.send({ kind: "installPackage", ...options2 });
187090
- Debug.assert(this.packageInstalledPromise === void 0);
187091
- return new Promise((resolve, reject) => {
187092
- this.packageInstalledPromise = { resolve, reject };
187093
- });
187094
- }
187095
- attach(projectService) {
187096
- this.projectService = projectService;
187298
+ createInstallerProcess() {
187097
187299
  if (this.logger.hasLevel(2 /* requestTime */)) {
187098
187300
  this.logger.info("Binding...");
187099
187301
  }
@@ -187132,135 +187334,7 @@ function startNodeSession(options, logger, cancellationToken) {
187132
187334
  process.on("exit", () => {
187133
187335
  this.installer.kill();
187134
187336
  });
187135
- }
187136
- onProjectClosed(p) {
187137
- this.send({ projectName: p.getProjectName(), kind: "closeProject" });
187138
- }
187139
- send(rq) {
187140
- this.installer.send(rq);
187141
- }
187142
- enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports) {
187143
- const request = createInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
187144
- if (this.logger.hasLevel(3 /* verbose */)) {
187145
- if (this.logger.hasLevel(3 /* verbose */)) {
187146
- this.logger.info(`Scheduling throttled operation:${stringifyIndented(request)}`);
187147
- }
187148
- }
187149
- const operationId = project.getProjectName();
187150
- const operation = () => {
187151
- if (this.logger.hasLevel(3 /* verbose */)) {
187152
- this.logger.info(`Sending request:${stringifyIndented(request)}`);
187153
- }
187154
- this.send(request);
187155
- };
187156
- const queuedRequest = { operationId, operation };
187157
- if (this.activeRequestCount < _NodeTypingsInstaller.maxActiveRequestCount) {
187158
- this.scheduleRequest(queuedRequest);
187159
- } else {
187160
- if (this.logger.hasLevel(3 /* verbose */)) {
187161
- this.logger.info(`Deferring request for: ${operationId}`);
187162
- }
187163
- this.requestQueue.enqueue(queuedRequest);
187164
- this.requestMap.set(operationId, queuedRequest);
187165
- }
187166
- }
187167
- handleMessage(response) {
187168
- if (this.logger.hasLevel(3 /* verbose */)) {
187169
- this.logger.info(`Received response:${stringifyIndented(response)}`);
187170
- }
187171
- switch (response.kind) {
187172
- case EventTypesRegistry:
187173
- this.typesRegistryCache = new Map(Object.entries(response.typesRegistry));
187174
- break;
187175
- case ActionPackageInstalled: {
187176
- const { success, message } = response;
187177
- if (success) {
187178
- this.packageInstalledPromise.resolve({ successMessage: message });
187179
- } else {
187180
- this.packageInstalledPromise.reject(message);
187181
- }
187182
- this.packageInstalledPromise = void 0;
187183
- this.projectService.updateTypingsForProject(response);
187184
- this.event(response, "setTypings");
187185
- break;
187186
- }
187187
- case EventInitializationFailed: {
187188
- const body = {
187189
- message: response.message
187190
- };
187191
- const eventName = "typesInstallerInitializationFailed";
187192
- this.event(body, eventName);
187193
- break;
187194
- }
187195
- case EventBeginInstallTypes: {
187196
- const body = {
187197
- eventId: response.eventId,
187198
- packages: response.packagesToInstall
187199
- };
187200
- const eventName = "beginInstallTypes";
187201
- this.event(body, eventName);
187202
- break;
187203
- }
187204
- case EventEndInstallTypes: {
187205
- if (this.telemetryEnabled) {
187206
- const body2 = {
187207
- telemetryEventName: "typingsInstalled",
187208
- payload: {
187209
- installedPackages: response.packagesToInstall.join(","),
187210
- installSuccess: response.installSuccess,
187211
- typingsInstallerVersion: response.typingsInstallerVersion
187212
- }
187213
- };
187214
- const eventName2 = "telemetry";
187215
- this.event(body2, eventName2);
187216
- }
187217
- const body = {
187218
- eventId: response.eventId,
187219
- packages: response.packagesToInstall,
187220
- success: response.installSuccess
187221
- };
187222
- const eventName = "endInstallTypes";
187223
- this.event(body, eventName);
187224
- break;
187225
- }
187226
- case ActionInvalidate: {
187227
- this.projectService.updateTypingsForProject(response);
187228
- break;
187229
- }
187230
- case ActionSet: {
187231
- if (this.activeRequestCount > 0) {
187232
- this.activeRequestCount--;
187233
- } else {
187234
- Debug.fail("Received too many responses");
187235
- }
187236
- while (!this.requestQueue.isEmpty()) {
187237
- const queuedRequest = this.requestQueue.dequeue();
187238
- if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) {
187239
- this.requestMap.delete(queuedRequest.operationId);
187240
- this.scheduleRequest(queuedRequest);
187241
- break;
187242
- }
187243
- if (this.logger.hasLevel(3 /* verbose */)) {
187244
- this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`);
187245
- }
187246
- }
187247
- this.projectService.updateTypingsForProject(response);
187248
- this.event(response, "setTypings");
187249
- break;
187250
- }
187251
- case ActionWatchTypingLocations:
187252
- this.projectService.watchTypingLocations(response);
187253
- break;
187254
- default:
187255
- assertType(response);
187256
- }
187257
- }
187258
- scheduleRequest(request) {
187259
- if (this.logger.hasLevel(3 /* verbose */)) {
187260
- this.logger.info(`Scheduling request for: ${request.operationId}`);
187261
- }
187262
- this.activeRequestCount++;
187263
- this.host.setTimeout(request.operation, _NodeTypingsInstaller.requestDelayMillis);
187337
+ return this.installer;
187264
187338
  }
187265
187339
  };
187266
187340
  // This number is essentially arbitrary. Processing more than one typings request
@@ -187268,21 +187342,20 @@ function startNodeSession(options, logger, cancellationToken) {
187268
187342
  // (see https://github.com/nodejs/node/issues/7657).
187269
187343
  // It would be preferable to base our limit on the amount of space left in the
187270
187344
  // buffer, but we have yet to find a way to retrieve that value.
187271
- _NodeTypingsInstaller.maxActiveRequestCount = 10;
187272
- _NodeTypingsInstaller.requestDelayMillis = 100;
187273
- let NodeTypingsInstaller = _NodeTypingsInstaller;
187345
+ _NodeTypingsInstallerAdapter.maxActiveRequestCount = 10;
187346
+ let NodeTypingsInstallerAdapter = _NodeTypingsInstallerAdapter;
187274
187347
  class IOSession extends Session3 {
187275
187348
  constructor() {
187276
187349
  const event = (body, eventName) => {
187277
187350
  this.event(body, eventName);
187278
187351
  };
187279
187352
  const host = sys;
187280
- const typingsInstaller = disableAutomaticTypingAcquisition ? void 0 : new NodeTypingsInstaller(telemetryEnabled, logger, host, getGlobalTypingsCacheLocation(), typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, event);
187353
+ const typingsInstaller = disableAutomaticTypingAcquisition ? void 0 : new NodeTypingsInstallerAdapter(telemetryEnabled, logger, host, getGlobalTypingsCacheLocation(), typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, event);
187281
187354
  super({
187282
187355
  host,
187283
187356
  cancellationToken,
187284
187357
  ...options,
187285
- typingsInstaller: typingsInstaller || nullTypingsInstaller,
187358
+ typingsInstaller,
187286
187359
  byteLength: Buffer.byteLength,
187287
187360
  hrtime: process.hrtime,
187288
187361
  logger,
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.20231113`;
38
+ version = `${versionMajorMinor}.0-insiders.20231115`;
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 = {
@@ -33695,6 +33710,9 @@ ${lanes.join("\n")}
33695
33710
  function nextTokenIsStringLiteral() {
33696
33711
  return nextToken() === 11 /* StringLiteral */;
33697
33712
  }
33713
+ function nextTokenIsFromKeyword() {
33714
+ return nextToken() === 161 /* FromKeyword */;
33715
+ }
33698
33716
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
33699
33717
  nextToken();
33700
33718
  return !scanner2.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
@@ -34390,7 +34408,7 @@ ${lanes.join("\n")}
34390
34408
  identifier = parseIdentifier();
34391
34409
  }
34392
34410
  let isTypeOnly = false;
34393
- if (token() !== 161 /* FromKeyword */ && (identifier == null ? void 0 : identifier.escapedText) === "type" && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
34411
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
34394
34412
  isTypeOnly = true;
34395
34413
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
34396
34414
  }
@@ -42915,6 +42933,9 @@ ${lanes.join("\n")}
42915
42933
  for (let i = 0; i < clauses.length; i++) {
42916
42934
  const clauseStart = i;
42917
42935
  while (!clauses[i].statements.length && i + 1 < clauses.length) {
42936
+ if (fallthroughFlow === unreachableFlow) {
42937
+ currentFlow = preSwitchCaseFlow;
42938
+ }
42918
42939
  bind(clauses[i]);
42919
42940
  i++;
42920
42941
  }
@@ -76420,9 +76441,6 @@ ${lanes.join("\n")}
76420
76441
  }
76421
76442
  switch (node.operand.kind) {
76422
76443
  case 9 /* NumericLiteral */:
76423
- if (operandType === numberType) {
76424
- return numberType;
76425
- }
76426
76444
  switch (node.operator) {
76427
76445
  case 41 /* MinusToken */:
76428
76446
  return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text));
@@ -160282,6 +160300,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160282
160300
  }
160283
160301
  return void 0;
160284
160302
  }
160303
+ if (isExportDeclaration(parent2) && contextToken.kind === 42 /* AsteriskToken */ || isNamedExports(parent2) && contextToken.kind === 20 /* CloseBraceToken */) {
160304
+ isKeywordOnlyCompletion = true;
160305
+ keywordCompletion = 161 /* FromKeyword */;
160306
+ return void 0;
160307
+ }
160285
160308
  if (isImportKeyword(contextToken) && isSourceFile(parent2)) {
160286
160309
  keywordCompletion = 156 /* TypeKeyword */;
160287
160310
  return contextToken;
@@ -172583,6 +172606,32 @@ ${options.prefix}` : "\n" : options.prefix
172583
172606
  }
172584
172607
  this.processCacheLocation(this.globalCachePath);
172585
172608
  }
172609
+ /** @internal */
172610
+ handleRequest(req) {
172611
+ switch (req.kind) {
172612
+ case "discover":
172613
+ this.install(req);
172614
+ break;
172615
+ case "closeProject":
172616
+ this.closeProject(req);
172617
+ break;
172618
+ case "typesRegistry": {
172619
+ const typesRegistry = {};
172620
+ this.typesRegistry.forEach((value, key) => {
172621
+ typesRegistry[key] = value;
172622
+ });
172623
+ const response = { kind: EventTypesRegistry, typesRegistry };
172624
+ this.sendResponse(response);
172625
+ break;
172626
+ }
172627
+ case "installPackage": {
172628
+ this.installPackage(req);
172629
+ break;
172630
+ }
172631
+ default:
172632
+ Debug.assertNever(req);
172633
+ }
172634
+ }
172586
172635
  closeProject(req) {
172587
172636
  this.closeWatchers(req.projectName);
172588
172637
  }
@@ -173981,8 +174030,9 @@ ${options.prefix}` : "\n" : options.prefix
173981
174030
  return !typeAcquisition || !typeAcquisition.enable ? emptyArray2 : typings;
173982
174031
  }
173983
174032
  onProjectClosed(project) {
173984
- this.perProjectCache.delete(project.getProjectName());
173985
- this.installer.onProjectClosed(project);
174033
+ if (this.perProjectCache.delete(project.getProjectName())) {
174034
+ this.installer.onProjectClosed(project);
174035
+ }
173986
174036
  }
173987
174037
  };
173988
174038
  }
@@ -183959,6 +184009,187 @@ ${e.message}`;
183959
184009
  }
183960
184010
  });
183961
184011
 
184012
+ // src/server/typingInstallerAdapter.ts
184013
+ var _TypingsInstallerAdapter, TypingsInstallerAdapter;
184014
+ var init_typingInstallerAdapter = __esm({
184015
+ "src/server/typingInstallerAdapter.ts"() {
184016
+ "use strict";
184017
+ init_ts7();
184018
+ init_ts_server3();
184019
+ _TypingsInstallerAdapter = class _TypingsInstallerAdapter {
184020
+ constructor(telemetryEnabled, logger, host, globalTypingsCacheLocation, event, maxActiveRequestCount) {
184021
+ this.telemetryEnabled = telemetryEnabled;
184022
+ this.logger = logger;
184023
+ this.host = host;
184024
+ this.globalTypingsCacheLocation = globalTypingsCacheLocation;
184025
+ this.event = event;
184026
+ this.maxActiveRequestCount = maxActiveRequestCount;
184027
+ this.activeRequestCount = 0;
184028
+ this.requestQueue = createQueue();
184029
+ this.requestMap = /* @__PURE__ */ new Map();
184030
+ // Maps project name to newest requestQueue entry for that project
184031
+ /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
184032
+ this.requestedRegistry = false;
184033
+ }
184034
+ isKnownTypesPackageName(name) {
184035
+ var _a;
184036
+ const validationResult = ts_JsTyping_exports.validatePackageName(name);
184037
+ if (validationResult !== ts_JsTyping_exports.NameValidationResult.Ok) {
184038
+ return false;
184039
+ }
184040
+ if (!this.requestedRegistry) {
184041
+ this.requestedRegistry = true;
184042
+ this.installer.send({ kind: "typesRegistry" });
184043
+ }
184044
+ return !!((_a = this.typesRegistryCache) == null ? void 0 : _a.has(name));
184045
+ }
184046
+ installPackage(options) {
184047
+ this.installer.send({ kind: "installPackage", ...options });
184048
+ Debug.assert(this.packageInstalledPromise === void 0);
184049
+ return new Promise((resolve, reject) => {
184050
+ this.packageInstalledPromise = { resolve, reject };
184051
+ });
184052
+ }
184053
+ attach(projectService) {
184054
+ this.projectService = projectService;
184055
+ this.installer = this.createInstallerProcess();
184056
+ }
184057
+ onProjectClosed(p) {
184058
+ this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" });
184059
+ }
184060
+ enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports) {
184061
+ const request = createInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
184062
+ if (this.logger.hasLevel(3 /* verbose */)) {
184063
+ this.logger.info(`TIAdapter:: Scheduling throttled operation:${stringifyIndented(request)}`);
184064
+ }
184065
+ if (this.activeRequestCount < this.maxActiveRequestCount) {
184066
+ this.scheduleRequest(request);
184067
+ } else {
184068
+ if (this.logger.hasLevel(3 /* verbose */)) {
184069
+ this.logger.info(`TIAdapter:: Deferring request for: ${request.projectName}`);
184070
+ }
184071
+ this.requestQueue.enqueue(request);
184072
+ this.requestMap.set(request.projectName, request);
184073
+ }
184074
+ }
184075
+ handleMessage(response) {
184076
+ if (this.logger.hasLevel(3 /* verbose */)) {
184077
+ this.logger.info(`TIAdapter:: Received response:${stringifyIndented(response)}`);
184078
+ }
184079
+ switch (response.kind) {
184080
+ case EventTypesRegistry:
184081
+ this.typesRegistryCache = new Map(Object.entries(response.typesRegistry));
184082
+ break;
184083
+ case ActionPackageInstalled: {
184084
+ const { success, message } = response;
184085
+ if (success) {
184086
+ this.packageInstalledPromise.resolve({ successMessage: message });
184087
+ } else {
184088
+ this.packageInstalledPromise.reject(message);
184089
+ }
184090
+ this.packageInstalledPromise = void 0;
184091
+ this.projectService.updateTypingsForProject(response);
184092
+ this.event(response, "setTypings");
184093
+ break;
184094
+ }
184095
+ case EventInitializationFailed: {
184096
+ const body = {
184097
+ message: response.message
184098
+ };
184099
+ const eventName = "typesInstallerInitializationFailed";
184100
+ this.event(body, eventName);
184101
+ break;
184102
+ }
184103
+ case EventBeginInstallTypes: {
184104
+ const body = {
184105
+ eventId: response.eventId,
184106
+ packages: response.packagesToInstall
184107
+ };
184108
+ const eventName = "beginInstallTypes";
184109
+ this.event(body, eventName);
184110
+ break;
184111
+ }
184112
+ case EventEndInstallTypes: {
184113
+ if (this.telemetryEnabled) {
184114
+ const body2 = {
184115
+ telemetryEventName: "typingsInstalled",
184116
+ payload: {
184117
+ installedPackages: response.packagesToInstall.join(","),
184118
+ installSuccess: response.installSuccess,
184119
+ typingsInstallerVersion: response.typingsInstallerVersion
184120
+ }
184121
+ };
184122
+ const eventName2 = "telemetry";
184123
+ this.event(body2, eventName2);
184124
+ }
184125
+ const body = {
184126
+ eventId: response.eventId,
184127
+ packages: response.packagesToInstall,
184128
+ success: response.installSuccess
184129
+ };
184130
+ const eventName = "endInstallTypes";
184131
+ this.event(body, eventName);
184132
+ break;
184133
+ }
184134
+ case ActionInvalidate: {
184135
+ this.projectService.updateTypingsForProject(response);
184136
+ break;
184137
+ }
184138
+ case ActionSet: {
184139
+ if (this.activeRequestCount > 0) {
184140
+ this.activeRequestCount--;
184141
+ } else {
184142
+ Debug.fail("TIAdapter:: Received too many responses");
184143
+ }
184144
+ while (!this.requestQueue.isEmpty()) {
184145
+ const queuedRequest = this.requestQueue.dequeue();
184146
+ if (this.requestMap.get(queuedRequest.projectName) === queuedRequest) {
184147
+ this.requestMap.delete(queuedRequest.projectName);
184148
+ this.scheduleRequest(queuedRequest);
184149
+ break;
184150
+ }
184151
+ if (this.logger.hasLevel(3 /* verbose */)) {
184152
+ this.logger.info(`TIAdapter:: Skipping defunct request for: ${queuedRequest.projectName}`);
184153
+ }
184154
+ }
184155
+ this.projectService.updateTypingsForProject(response);
184156
+ this.event(response, "setTypings");
184157
+ break;
184158
+ }
184159
+ case ActionWatchTypingLocations:
184160
+ this.projectService.watchTypingLocations(response);
184161
+ break;
184162
+ default:
184163
+ assertType(response);
184164
+ }
184165
+ }
184166
+ scheduleRequest(request) {
184167
+ if (this.logger.hasLevel(3 /* verbose */)) {
184168
+ this.logger.info(`TIAdapter:: Scheduling request for: ${request.projectName}`);
184169
+ }
184170
+ this.activeRequestCount++;
184171
+ this.host.setTimeout(
184172
+ () => {
184173
+ if (this.logger.hasLevel(3 /* verbose */)) {
184174
+ this.logger.info(`TIAdapter:: Sending request:${stringifyIndented(request)}`);
184175
+ }
184176
+ this.installer.send(request);
184177
+ },
184178
+ _TypingsInstallerAdapter.requestDelayMillis,
184179
+ `${request.projectName}::${request.kind}`
184180
+ );
184181
+ }
184182
+ };
184183
+ // This number is essentially arbitrary. Processing more than one typings request
184184
+ // at a time makes sense, but having too many in the pipe results in a hang
184185
+ // (see https://github.com/nodejs/node/issues/7657).
184186
+ // It would be preferable to base our limit on the amount of space left in the
184187
+ // buffer, but we have yet to find a way to retrieve that value.
184188
+ _TypingsInstallerAdapter.requestDelayMillis = 100;
184189
+ TypingsInstallerAdapter = _TypingsInstallerAdapter;
184190
+ }
184191
+ });
184192
+
183962
184193
  // src/server/_namespaces/ts.server.ts
183963
184194
  var ts_server_exports3 = {};
183964
184195
  __export(ts_server_exports3, {
@@ -184006,6 +184237,7 @@ ${e.message}`;
184006
184237
  TextStorage: () => TextStorage,
184007
184238
  ThrottledOperations: () => ThrottledOperations,
184008
184239
  TypingsCache: () => TypingsCache,
184240
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
184009
184241
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
184010
184242
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
184011
184243
  asNormalizedPath: () => asNormalizedPath,
@@ -184074,6 +184306,7 @@ ${e.message}`;
184074
184306
  init_packageJsonCache();
184075
184307
  init_session();
184076
184308
  init_scriptVersionCache();
184309
+ init_typingInstallerAdapter();
184077
184310
  }
184078
184311
  });
184079
184312
 
@@ -186428,6 +186661,7 @@ ${e.message}`;
186428
186661
  TextStorage: () => TextStorage,
186429
186662
  ThrottledOperations: () => ThrottledOperations,
186430
186663
  TypingsCache: () => TypingsCache,
186664
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
186431
186665
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
186432
186666
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
186433
186667
  asNormalizedPath: () => asNormalizedPath,
@@ -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.20231113`;
57
+ var version = `${versionMajorMinor}.0-insiders.20231115`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -3934,6 +3934,7 @@ function createSystemWatchFunctions({
3934
3934
  useNonPollingWatchers,
3935
3935
  tscWatchDirectory,
3936
3936
  inodeWatching,
3937
+ fsWatchWithTimestamp,
3937
3938
  sysLog: sysLog2
3938
3939
  }) {
3939
3940
  const pollingWatches = /* @__PURE__ */ new Map();
@@ -4172,7 +4173,7 @@ function createSystemWatchFunctions({
4172
4173
  return watchPresentFileSystemEntryWithFsWatchFile();
4173
4174
  }
4174
4175
  try {
4175
- const presentWatcher = fsWatchWorker(
4176
+ const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
4176
4177
  fileOrDirectory,
4177
4178
  recursive,
4178
4179
  inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
@@ -4235,6 +4236,18 @@ function createSystemWatchFunctions({
4235
4236
  );
4236
4237
  }
4237
4238
  }
4239
+ function fsWatchWorkerHandlingTimestamp(fileOrDirectory, recursive, callback) {
4240
+ let modifiedTime = getModifiedTime2(fileOrDirectory) || missingFileModifiedTime;
4241
+ return fsWatchWorker(fileOrDirectory, recursive, (eventName, relativeFileName, currentModifiedTime) => {
4242
+ if (eventName === "change") {
4243
+ currentModifiedTime || (currentModifiedTime = getModifiedTime2(fileOrDirectory) || missingFileModifiedTime);
4244
+ if (currentModifiedTime.getTime() === modifiedTime.getTime())
4245
+ return;
4246
+ }
4247
+ modifiedTime = currentModifiedTime || getModifiedTime2(fileOrDirectory) || missingFileModifiedTime;
4248
+ callback(eventName, relativeFileName, modifiedTime);
4249
+ });
4250
+ }
4238
4251
  }
4239
4252
  function patchWriteFileEnsuringDirectory(sys2) {
4240
4253
  const originalWriteFile = sys2.writeFile;
@@ -4263,12 +4276,13 @@ var sys = (() => {
4263
4276
  let activeSession;
4264
4277
  let profilePath = "./profile.cpuprofile";
4265
4278
  const Buffer2 = require("buffer").Buffer;
4266
- const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
4279
+ const isMacOs = process.platform === "darwin";
4280
+ const isLinuxOrMacOs = process.platform === "linux" || isMacOs;
4267
4281
  const platform = _os.platform();
4268
4282
  const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
4269
4283
  const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
4270
4284
  const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
4271
- const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
4285
+ const fsSupportsRecursiveFsWatch = process.platform === "win32" || isMacOs;
4272
4286
  const getCurrentDirectory = memoize(() => process.cwd());
4273
4287
  const { watchFile, watchDirectory } = createSystemWatchFunctions({
4274
4288
  pollingWatchFileWorker: fsWatchFileWorker,
@@ -4288,6 +4302,7 @@ var sys = (() => {
4288
4302
  useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
4289
4303
  tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
4290
4304
  inodeWatching: isLinuxOrMacOs,
4305
+ fsWatchWithTimestamp: isMacOs,
4291
4306
  sysLog
4292
4307
  });
4293
4308
  const nodeSystem = {
@@ -23031,6 +23046,9 @@ var Parser;
23031
23046
  function nextTokenIsStringLiteral() {
23032
23047
  return nextToken() === 11 /* StringLiteral */;
23033
23048
  }
23049
+ function nextTokenIsFromKeyword() {
23050
+ return nextToken() === 161 /* FromKeyword */;
23051
+ }
23034
23052
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
23035
23053
  nextToken();
23036
23054
  return !scanner.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
@@ -23726,7 +23744,7 @@ var Parser;
23726
23744
  identifier = parseIdentifier();
23727
23745
  }
23728
23746
  let isTypeOnly = false;
23729
- if (token() !== 161 /* FromKeyword */ && (identifier == null ? void 0 : identifier.escapedText) === "type" && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
23747
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
23730
23748
  isTypeOnly = true;
23731
23749
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
23732
23750
  }
@@ -31847,6 +31865,32 @@ var TypingsInstaller = class {
31847
31865
  }
31848
31866
  this.processCacheLocation(this.globalCachePath);
31849
31867
  }
31868
+ /** @internal */
31869
+ handleRequest(req) {
31870
+ switch (req.kind) {
31871
+ case "discover":
31872
+ this.install(req);
31873
+ break;
31874
+ case "closeProject":
31875
+ this.closeProject(req);
31876
+ break;
31877
+ case "typesRegistry": {
31878
+ const typesRegistry = {};
31879
+ this.typesRegistry.forEach((value, key) => {
31880
+ typesRegistry[key] = value;
31881
+ });
31882
+ const response = { kind: EventTypesRegistry, typesRegistry };
31883
+ this.sendResponse(response);
31884
+ break;
31885
+ }
31886
+ case "installPackage": {
31887
+ this.installPackage(req);
31888
+ break;
31889
+ }
31890
+ default:
31891
+ Debug.assertNever(req);
31892
+ }
31893
+ }
31850
31894
  closeProject(req) {
31851
31895
  this.closeWatchers(req.projectName);
31852
31896
  }
@@ -32264,29 +32308,7 @@ var NodeTypingsInstaller = class extends TypingsInstaller {
32264
32308
  this.sendResponse(this.delayedInitializationError);
32265
32309
  this.delayedInitializationError = void 0;
32266
32310
  }
32267
- switch (req.kind) {
32268
- case "discover":
32269
- this.install(req);
32270
- break;
32271
- case "closeProject":
32272
- this.closeProject(req);
32273
- break;
32274
- case "typesRegistry": {
32275
- const typesRegistry = {};
32276
- this.typesRegistry.forEach((value, key) => {
32277
- typesRegistry[key] = value;
32278
- });
32279
- const response = { kind: EventTypesRegistry, typesRegistry };
32280
- this.sendResponse(response);
32281
- break;
32282
- }
32283
- case "installPackage": {
32284
- this.installPackage(req);
32285
- break;
32286
- }
32287
- default:
32288
- Debug.assertNever(req);
32289
- }
32311
+ super.handleRequest(req);
32290
32312
  }
32291
32313
  sendResponse(response) {
32292
32314
  if (this.log.isEnabled()) {
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-56301-7",
5
+ "version": "5.4.0-pr-56403-3",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -115,5 +115,5 @@
115
115
  "node": "20.1.0",
116
116
  "npm": "8.19.4"
117
117
  },
118
- "gitHead": "b196684ca20864d35919dfa131d6cd753ab8c8d5"
118
+ "gitHead": "7b7725db2ed53b6e61c2ab6b8cba53fc297baf7c"
119
119
  }