typescript 5.4.0-dev.20231113 → 5.4.0-dev.20231115

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-dev.20231113`;
21
+ var version = `${versionMajorMinor}.0-dev.20231115`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -31217,6 +31217,9 @@ var Parser;
31217
31217
  function nextTokenIsStringLiteral() {
31218
31218
  return nextToken() === 11 /* StringLiteral */;
31219
31219
  }
31220
+ function nextTokenIsFromKeyword() {
31221
+ return nextToken() === 161 /* FromKeyword */;
31222
+ }
31220
31223
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
31221
31224
  nextToken();
31222
31225
  return !scanner.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
@@ -31912,7 +31915,7 @@ var Parser;
31912
31915
  identifier = parseIdentifier();
31913
31916
  }
31914
31917
  let isTypeOnly = false;
31915
- if (token() !== 161 /* FromKeyword */ && (identifier == null ? void 0 : identifier.escapedText) === "type" && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
31918
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
31916
31919
  isTypeOnly = true;
31917
31920
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
31918
31921
  }
@@ -40407,6 +40410,9 @@ function createBinder() {
40407
40410
  for (let i = 0; i < clauses.length; i++) {
40408
40411
  const clauseStart = i;
40409
40412
  while (!clauses[i].statements.length && i + 1 < clauses.length) {
40413
+ if (fallthroughFlow === unreachableFlow) {
40414
+ currentFlow = preSwitchCaseFlow;
40415
+ }
40410
40416
  bind(clauses[i]);
40411
40417
  i++;
40412
40418
  }
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-dev.20231113`;
2333
+ var version = `${versionMajorMinor}.0-dev.20231115`;
2334
2334
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2335
2335
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2336
2336
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -35625,6 +35625,9 @@ var Parser;
35625
35625
  function nextTokenIsStringLiteral() {
35626
35626
  return nextToken() === 11 /* StringLiteral */;
35627
35627
  }
35628
+ function nextTokenIsFromKeyword() {
35629
+ return nextToken() === 161 /* FromKeyword */;
35630
+ }
35628
35631
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
35629
35632
  nextToken();
35630
35633
  return !scanner2.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
@@ -36320,7 +36323,7 @@ var Parser;
36320
36323
  identifier = parseIdentifier();
36321
36324
  }
36322
36325
  let isTypeOnly = false;
36323
- if (token() !== 161 /* FromKeyword */ && (identifier == null ? void 0 : identifier.escapedText) === "type" && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
36326
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
36324
36327
  isTypeOnly = true;
36325
36328
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
36326
36329
  }
@@ -45070,6 +45073,9 @@ function createBinder() {
45070
45073
  for (let i = 0; i < clauses.length; i++) {
45071
45074
  const clauseStart = i;
45072
45075
  while (!clauses[i].statements.length && i + 1 < clauses.length) {
45076
+ if (fallthroughFlow === unreachableFlow) {
45077
+ currentFlow = preSwitchCaseFlow;
45078
+ }
45073
45079
  bind(clauses[i]);
45074
45080
  i++;
45075
45081
  }
@@ -161078,6 +161084,11 @@ function getImportStatementCompletionInfo(contextToken, sourceFile) {
161078
161084
  }
161079
161085
  return void 0;
161080
161086
  }
161087
+ if (isExportDeclaration(parent2) && contextToken.kind === 42 /* AsteriskToken */ || isNamedExports(parent2) && contextToken.kind === 20 /* CloseBraceToken */) {
161088
+ isKeywordOnlyCompletion = true;
161089
+ keywordCompletion = 161 /* FromKeyword */;
161090
+ return void 0;
161091
+ }
161081
161092
  if (isImportKeyword(contextToken) && isSourceFile(parent2)) {
161082
161093
  keywordCompletion = 156 /* TypeKeyword */;
161083
161094
  return contextToken;
@@ -175244,6 +175255,7 @@ __export(ts_server_exports3, {
175244
175255
  TextStorage: () => TextStorage,
175245
175256
  ThrottledOperations: () => ThrottledOperations,
175246
175257
  TypingsCache: () => TypingsCache,
175258
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
175247
175259
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
175248
175260
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
175249
175261
  asNormalizedPath: () => asNormalizedPath,
@@ -175365,6 +175377,32 @@ var TypingsInstaller = class {
175365
175377
  }
175366
175378
  this.processCacheLocation(this.globalCachePath);
175367
175379
  }
175380
+ /** @internal */
175381
+ handleRequest(req) {
175382
+ switch (req.kind) {
175383
+ case "discover":
175384
+ this.install(req);
175385
+ break;
175386
+ case "closeProject":
175387
+ this.closeProject(req);
175388
+ break;
175389
+ case "typesRegistry": {
175390
+ const typesRegistry = {};
175391
+ this.typesRegistry.forEach((value, key) => {
175392
+ typesRegistry[key] = value;
175393
+ });
175394
+ const response = { kind: EventTypesRegistry, typesRegistry };
175395
+ this.sendResponse(response);
175396
+ break;
175397
+ }
175398
+ case "installPackage": {
175399
+ this.installPackage(req);
175400
+ break;
175401
+ }
175402
+ default:
175403
+ Debug.assertNever(req);
175404
+ }
175405
+ }
175368
175406
  closeProject(req) {
175369
175407
  this.closeWatchers(req.projectName);
175370
175408
  }
@@ -176693,8 +176731,9 @@ var TypingsCache = class {
176693
176731
  return !typeAcquisition || !typeAcquisition.enable ? emptyArray2 : typings;
176694
176732
  }
176695
176733
  onProjectClosed(project) {
176696
- this.perProjectCache.delete(project.getProjectName());
176697
- this.installer.onProjectClosed(project);
176734
+ if (this.perProjectCache.delete(project.getProjectName())) {
176735
+ this.installer.onProjectClosed(project);
176736
+ }
176698
176737
  }
176699
176738
  };
176700
176739
 
@@ -186622,6 +186661,179 @@ var LineLeaf = class {
186622
186661
  }
186623
186662
  };
186624
186663
 
186664
+ // src/server/typingInstallerAdapter.ts
186665
+ var _TypingsInstallerAdapter = class _TypingsInstallerAdapter {
186666
+ constructor(telemetryEnabled, logger, host, globalTypingsCacheLocation, event, maxActiveRequestCount) {
186667
+ this.telemetryEnabled = telemetryEnabled;
186668
+ this.logger = logger;
186669
+ this.host = host;
186670
+ this.globalTypingsCacheLocation = globalTypingsCacheLocation;
186671
+ this.event = event;
186672
+ this.maxActiveRequestCount = maxActiveRequestCount;
186673
+ this.activeRequestCount = 0;
186674
+ this.requestQueue = createQueue();
186675
+ this.requestMap = /* @__PURE__ */ new Map();
186676
+ // Maps project name to newest requestQueue entry for that project
186677
+ /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
186678
+ this.requestedRegistry = false;
186679
+ }
186680
+ isKnownTypesPackageName(name) {
186681
+ var _a;
186682
+ const validationResult = ts_JsTyping_exports.validatePackageName(name);
186683
+ if (validationResult !== ts_JsTyping_exports.NameValidationResult.Ok) {
186684
+ return false;
186685
+ }
186686
+ if (!this.requestedRegistry) {
186687
+ this.requestedRegistry = true;
186688
+ this.installer.send({ kind: "typesRegistry" });
186689
+ }
186690
+ return !!((_a = this.typesRegistryCache) == null ? void 0 : _a.has(name));
186691
+ }
186692
+ installPackage(options) {
186693
+ this.installer.send({ kind: "installPackage", ...options });
186694
+ Debug.assert(this.packageInstalledPromise === void 0);
186695
+ return new Promise((resolve, reject) => {
186696
+ this.packageInstalledPromise = { resolve, reject };
186697
+ });
186698
+ }
186699
+ attach(projectService) {
186700
+ this.projectService = projectService;
186701
+ this.installer = this.createInstallerProcess();
186702
+ }
186703
+ onProjectClosed(p) {
186704
+ this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" });
186705
+ }
186706
+ enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports) {
186707
+ const request = createInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
186708
+ if (this.logger.hasLevel(3 /* verbose */)) {
186709
+ this.logger.info(`TIAdapter:: Scheduling throttled operation:${stringifyIndented(request)}`);
186710
+ }
186711
+ if (this.activeRequestCount < this.maxActiveRequestCount) {
186712
+ this.scheduleRequest(request);
186713
+ } else {
186714
+ if (this.logger.hasLevel(3 /* verbose */)) {
186715
+ this.logger.info(`TIAdapter:: Deferring request for: ${request.projectName}`);
186716
+ }
186717
+ this.requestQueue.enqueue(request);
186718
+ this.requestMap.set(request.projectName, request);
186719
+ }
186720
+ }
186721
+ handleMessage(response) {
186722
+ if (this.logger.hasLevel(3 /* verbose */)) {
186723
+ this.logger.info(`TIAdapter:: Received response:${stringifyIndented(response)}`);
186724
+ }
186725
+ switch (response.kind) {
186726
+ case EventTypesRegistry:
186727
+ this.typesRegistryCache = new Map(Object.entries(response.typesRegistry));
186728
+ break;
186729
+ case ActionPackageInstalled: {
186730
+ const { success, message } = response;
186731
+ if (success) {
186732
+ this.packageInstalledPromise.resolve({ successMessage: message });
186733
+ } else {
186734
+ this.packageInstalledPromise.reject(message);
186735
+ }
186736
+ this.packageInstalledPromise = void 0;
186737
+ this.projectService.updateTypingsForProject(response);
186738
+ this.event(response, "setTypings");
186739
+ break;
186740
+ }
186741
+ case EventInitializationFailed: {
186742
+ const body = {
186743
+ message: response.message
186744
+ };
186745
+ const eventName = "typesInstallerInitializationFailed";
186746
+ this.event(body, eventName);
186747
+ break;
186748
+ }
186749
+ case EventBeginInstallTypes: {
186750
+ const body = {
186751
+ eventId: response.eventId,
186752
+ packages: response.packagesToInstall
186753
+ };
186754
+ const eventName = "beginInstallTypes";
186755
+ this.event(body, eventName);
186756
+ break;
186757
+ }
186758
+ case EventEndInstallTypes: {
186759
+ if (this.telemetryEnabled) {
186760
+ const body2 = {
186761
+ telemetryEventName: "typingsInstalled",
186762
+ payload: {
186763
+ installedPackages: response.packagesToInstall.join(","),
186764
+ installSuccess: response.installSuccess,
186765
+ typingsInstallerVersion: response.typingsInstallerVersion
186766
+ }
186767
+ };
186768
+ const eventName2 = "telemetry";
186769
+ this.event(body2, eventName2);
186770
+ }
186771
+ const body = {
186772
+ eventId: response.eventId,
186773
+ packages: response.packagesToInstall,
186774
+ success: response.installSuccess
186775
+ };
186776
+ const eventName = "endInstallTypes";
186777
+ this.event(body, eventName);
186778
+ break;
186779
+ }
186780
+ case ActionInvalidate: {
186781
+ this.projectService.updateTypingsForProject(response);
186782
+ break;
186783
+ }
186784
+ case ActionSet: {
186785
+ if (this.activeRequestCount > 0) {
186786
+ this.activeRequestCount--;
186787
+ } else {
186788
+ Debug.fail("TIAdapter:: Received too many responses");
186789
+ }
186790
+ while (!this.requestQueue.isEmpty()) {
186791
+ const queuedRequest = this.requestQueue.dequeue();
186792
+ if (this.requestMap.get(queuedRequest.projectName) === queuedRequest) {
186793
+ this.requestMap.delete(queuedRequest.projectName);
186794
+ this.scheduleRequest(queuedRequest);
186795
+ break;
186796
+ }
186797
+ if (this.logger.hasLevel(3 /* verbose */)) {
186798
+ this.logger.info(`TIAdapter:: Skipping defunct request for: ${queuedRequest.projectName}`);
186799
+ }
186800
+ }
186801
+ this.projectService.updateTypingsForProject(response);
186802
+ this.event(response, "setTypings");
186803
+ break;
186804
+ }
186805
+ case ActionWatchTypingLocations:
186806
+ this.projectService.watchTypingLocations(response);
186807
+ break;
186808
+ default:
186809
+ assertType(response);
186810
+ }
186811
+ }
186812
+ scheduleRequest(request) {
186813
+ if (this.logger.hasLevel(3 /* verbose */)) {
186814
+ this.logger.info(`TIAdapter:: Scheduling request for: ${request.projectName}`);
186815
+ }
186816
+ this.activeRequestCount++;
186817
+ this.host.setTimeout(
186818
+ () => {
186819
+ if (this.logger.hasLevel(3 /* verbose */)) {
186820
+ this.logger.info(`TIAdapter:: Sending request:${stringifyIndented(request)}`);
186821
+ }
186822
+ this.installer.send(request);
186823
+ },
186824
+ _TypingsInstallerAdapter.requestDelayMillis,
186825
+ `${request.projectName}::${request.kind}`
186826
+ );
186827
+ }
186828
+ };
186829
+ // This number is essentially arbitrary. Processing more than one typings request
186830
+ // at a time makes sense, but having too many in the pipe results in a hang
186831
+ // (see https://github.com/nodejs/node/issues/7657).
186832
+ // It would be preferable to base our limit on the amount of space left in the
186833
+ // buffer, but we have yet to find a way to retrieve that value.
186834
+ _TypingsInstallerAdapter.requestDelayMillis = 100;
186835
+ var TypingsInstallerAdapter = _TypingsInstallerAdapter;
186836
+
186625
186837
  // src/tsserver/_namespaces/ts.server.ts
186626
186838
  var ts_server_exports4 = {};
186627
186839
  __export(ts_server_exports4, {
@@ -186669,6 +186881,7 @@ __export(ts_server_exports4, {
186669
186881
  TextStorage: () => TextStorage,
186670
186882
  ThrottledOperations: () => ThrottledOperations,
186671
186883
  TypingsCache: () => TypingsCache,
186884
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
186672
186885
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
186673
186886
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
186674
186887
  asNormalizedPath: () => asNormalizedPath,
@@ -186788,7 +187001,7 @@ function initializeNodeSystem() {
186788
187001
  const sys2 = Debug.checkDefined(sys);
186789
187002
  const childProcess = require("child_process");
186790
187003
  const fs = require("fs");
186791
- class Logger6 {
187004
+ class Logger7 {
186792
187005
  constructor(logFilename, traceToConsole, level) {
186793
187006
  this.logFilename = logFilename;
186794
187007
  this.traceToConsole = traceToConsole;
@@ -186855,7 +187068,7 @@ function initializeNodeSystem() {
186855
187068
  s = `[${nowString()}] ${s}
186856
187069
  `;
186857
187070
  if (!this.inGroup || this.firstInGroup) {
186858
- const prefix = Logger6.padStringRight(type + " " + this.seq.toString(), " ");
187071
+ const prefix = Logger7.padStringRight(type + " " + this.seq.toString(), " ");
186859
187072
  s = prefix + s;
186860
187073
  }
186861
187074
  this.write(s, type);
@@ -186992,7 +187205,7 @@ function initializeNodeSystem() {
186992
187205
  const unsubstitutedLogFileName = cmdLineLogFileName ? stripQuotes(cmdLineLogFileName) : envLogOptions.logToFile ? envLogOptions.file || libDirectory + "/.log" + process.pid.toString() : void 0;
186993
187206
  const substitutedLogFileName = unsubstitutedLogFileName ? unsubstitutedLogFileName.replace("PID", process.pid.toString()) : void 0;
186994
187207
  const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
186995
- return new Logger6(substitutedLogFileName, envLogOptions.traceToConsole, logVerbosity);
187208
+ return new Logger7(substitutedLogFileName, envLogOptions.traceToConsole, logVerbosity);
186996
187209
  }
186997
187210
  function writeMessage(buf) {
186998
187211
  if (!canWrite) {
@@ -187052,45 +187265,22 @@ function startNodeSession(options, logger, cancellationToken) {
187052
187265
  output: process.stdout,
187053
187266
  terminal: false
187054
187267
  });
187055
- const _NodeTypingsInstaller = class _NodeTypingsInstaller {
187268
+ const _NodeTypingsInstallerAdapter = class _NodeTypingsInstallerAdapter extends TypingsInstallerAdapter {
187056
187269
  constructor(telemetryEnabled2, logger2, host, globalTypingsCacheLocation, typingSafeListLocation2, typesMapLocation2, npmLocation2, validateDefaultNpmLocation2, event) {
187057
- this.telemetryEnabled = telemetryEnabled2;
187058
- this.logger = logger2;
187059
- this.host = host;
187060
- this.globalTypingsCacheLocation = globalTypingsCacheLocation;
187270
+ super(
187271
+ telemetryEnabled2,
187272
+ logger2,
187273
+ host,
187274
+ globalTypingsCacheLocation,
187275
+ event,
187276
+ _NodeTypingsInstallerAdapter.maxActiveRequestCount
187277
+ );
187061
187278
  this.typingSafeListLocation = typingSafeListLocation2;
187062
187279
  this.typesMapLocation = typesMapLocation2;
187063
187280
  this.npmLocation = npmLocation2;
187064
187281
  this.validateDefaultNpmLocation = validateDefaultNpmLocation2;
187065
- this.event = event;
187066
- this.activeRequestCount = 0;
187067
- this.requestQueue = createQueue();
187068
- this.requestMap = /* @__PURE__ */ new Map();
187069
- // Maps operation ID to newest requestQueue entry with that ID
187070
- /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
187071
- this.requestedRegistry = false;
187072
- }
187073
- isKnownTypesPackageName(name) {
187074
- const validationResult = ts_JsTyping_exports.validatePackageName(name);
187075
- if (validationResult !== ts_JsTyping_exports.NameValidationResult.Ok) {
187076
- return false;
187077
- }
187078
- if (this.requestedRegistry) {
187079
- return !!this.typesRegistryCache && this.typesRegistryCache.has(name);
187080
- }
187081
- this.requestedRegistry = true;
187082
- this.send({ kind: "typesRegistry" });
187083
- return false;
187084
- }
187085
- installPackage(options2) {
187086
- this.send({ kind: "installPackage", ...options2 });
187087
- Debug.assert(this.packageInstalledPromise === void 0);
187088
- return new Promise((resolve, reject) => {
187089
- this.packageInstalledPromise = { resolve, reject };
187090
- });
187091
187282
  }
187092
- attach(projectService) {
187093
- this.projectService = projectService;
187283
+ createInstallerProcess() {
187094
187284
  if (this.logger.hasLevel(2 /* requestTime */)) {
187095
187285
  this.logger.info("Binding...");
187096
187286
  }
@@ -187129,135 +187319,7 @@ function startNodeSession(options, logger, cancellationToken) {
187129
187319
  process.on("exit", () => {
187130
187320
  this.installer.kill();
187131
187321
  });
187132
- }
187133
- onProjectClosed(p) {
187134
- this.send({ projectName: p.getProjectName(), kind: "closeProject" });
187135
- }
187136
- send(rq) {
187137
- this.installer.send(rq);
187138
- }
187139
- enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports) {
187140
- const request = createInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
187141
- if (this.logger.hasLevel(3 /* verbose */)) {
187142
- if (this.logger.hasLevel(3 /* verbose */)) {
187143
- this.logger.info(`Scheduling throttled operation:${stringifyIndented(request)}`);
187144
- }
187145
- }
187146
- const operationId = project.getProjectName();
187147
- const operation = () => {
187148
- if (this.logger.hasLevel(3 /* verbose */)) {
187149
- this.logger.info(`Sending request:${stringifyIndented(request)}`);
187150
- }
187151
- this.send(request);
187152
- };
187153
- const queuedRequest = { operationId, operation };
187154
- if (this.activeRequestCount < _NodeTypingsInstaller.maxActiveRequestCount) {
187155
- this.scheduleRequest(queuedRequest);
187156
- } else {
187157
- if (this.logger.hasLevel(3 /* verbose */)) {
187158
- this.logger.info(`Deferring request for: ${operationId}`);
187159
- }
187160
- this.requestQueue.enqueue(queuedRequest);
187161
- this.requestMap.set(operationId, queuedRequest);
187162
- }
187163
- }
187164
- handleMessage(response) {
187165
- if (this.logger.hasLevel(3 /* verbose */)) {
187166
- this.logger.info(`Received response:${stringifyIndented(response)}`);
187167
- }
187168
- switch (response.kind) {
187169
- case EventTypesRegistry:
187170
- this.typesRegistryCache = new Map(Object.entries(response.typesRegistry));
187171
- break;
187172
- case ActionPackageInstalled: {
187173
- const { success, message } = response;
187174
- if (success) {
187175
- this.packageInstalledPromise.resolve({ successMessage: message });
187176
- } else {
187177
- this.packageInstalledPromise.reject(message);
187178
- }
187179
- this.packageInstalledPromise = void 0;
187180
- this.projectService.updateTypingsForProject(response);
187181
- this.event(response, "setTypings");
187182
- break;
187183
- }
187184
- case EventInitializationFailed: {
187185
- const body = {
187186
- message: response.message
187187
- };
187188
- const eventName = "typesInstallerInitializationFailed";
187189
- this.event(body, eventName);
187190
- break;
187191
- }
187192
- case EventBeginInstallTypes: {
187193
- const body = {
187194
- eventId: response.eventId,
187195
- packages: response.packagesToInstall
187196
- };
187197
- const eventName = "beginInstallTypes";
187198
- this.event(body, eventName);
187199
- break;
187200
- }
187201
- case EventEndInstallTypes: {
187202
- if (this.telemetryEnabled) {
187203
- const body2 = {
187204
- telemetryEventName: "typingsInstalled",
187205
- payload: {
187206
- installedPackages: response.packagesToInstall.join(","),
187207
- installSuccess: response.installSuccess,
187208
- typingsInstallerVersion: response.typingsInstallerVersion
187209
- }
187210
- };
187211
- const eventName2 = "telemetry";
187212
- this.event(body2, eventName2);
187213
- }
187214
- const body = {
187215
- eventId: response.eventId,
187216
- packages: response.packagesToInstall,
187217
- success: response.installSuccess
187218
- };
187219
- const eventName = "endInstallTypes";
187220
- this.event(body, eventName);
187221
- break;
187222
- }
187223
- case ActionInvalidate: {
187224
- this.projectService.updateTypingsForProject(response);
187225
- break;
187226
- }
187227
- case ActionSet: {
187228
- if (this.activeRequestCount > 0) {
187229
- this.activeRequestCount--;
187230
- } else {
187231
- Debug.fail("Received too many responses");
187232
- }
187233
- while (!this.requestQueue.isEmpty()) {
187234
- const queuedRequest = this.requestQueue.dequeue();
187235
- if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) {
187236
- this.requestMap.delete(queuedRequest.operationId);
187237
- this.scheduleRequest(queuedRequest);
187238
- break;
187239
- }
187240
- if (this.logger.hasLevel(3 /* verbose */)) {
187241
- this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`);
187242
- }
187243
- }
187244
- this.projectService.updateTypingsForProject(response);
187245
- this.event(response, "setTypings");
187246
- break;
187247
- }
187248
- case ActionWatchTypingLocations:
187249
- this.projectService.watchTypingLocations(response);
187250
- break;
187251
- default:
187252
- assertType(response);
187253
- }
187254
- }
187255
- scheduleRequest(request) {
187256
- if (this.logger.hasLevel(3 /* verbose */)) {
187257
- this.logger.info(`Scheduling request for: ${request.operationId}`);
187258
- }
187259
- this.activeRequestCount++;
187260
- this.host.setTimeout(request.operation, _NodeTypingsInstaller.requestDelayMillis);
187322
+ return this.installer;
187261
187323
  }
187262
187324
  };
187263
187325
  // This number is essentially arbitrary. Processing more than one typings request
@@ -187265,21 +187327,20 @@ function startNodeSession(options, logger, cancellationToken) {
187265
187327
  // (see https://github.com/nodejs/node/issues/7657).
187266
187328
  // It would be preferable to base our limit on the amount of space left in the
187267
187329
  // buffer, but we have yet to find a way to retrieve that value.
187268
- _NodeTypingsInstaller.maxActiveRequestCount = 10;
187269
- _NodeTypingsInstaller.requestDelayMillis = 100;
187270
- let NodeTypingsInstaller = _NodeTypingsInstaller;
187330
+ _NodeTypingsInstallerAdapter.maxActiveRequestCount = 10;
187331
+ let NodeTypingsInstallerAdapter = _NodeTypingsInstallerAdapter;
187271
187332
  class IOSession extends Session3 {
187272
187333
  constructor() {
187273
187334
  const event = (body, eventName) => {
187274
187335
  this.event(body, eventName);
187275
187336
  };
187276
187337
  const host = sys;
187277
- const typingsInstaller = disableAutomaticTypingAcquisition ? void 0 : new NodeTypingsInstaller(telemetryEnabled, logger, host, getGlobalTypingsCacheLocation(), typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, event);
187338
+ const typingsInstaller = disableAutomaticTypingAcquisition ? void 0 : new NodeTypingsInstallerAdapter(telemetryEnabled, logger, host, getGlobalTypingsCacheLocation(), typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, event);
187278
187339
  super({
187279
187340
  host,
187280
187341
  cancellationToken,
187281
187342
  ...options,
187282
- typingsInstaller: typingsInstaller || nullTypingsInstaller,
187343
+ typingsInstaller,
187283
187344
  byteLength: Buffer.byteLength,
187284
187345
  hrtime: process.hrtime,
187285
187346
  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-dev.20231113`;
38
+ version = `${versionMajorMinor}.0-dev.20231115`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -33695,6 +33695,9 @@ ${lanes.join("\n")}
33695
33695
  function nextTokenIsStringLiteral() {
33696
33696
  return nextToken() === 11 /* StringLiteral */;
33697
33697
  }
33698
+ function nextTokenIsFromKeyword() {
33699
+ return nextToken() === 161 /* FromKeyword */;
33700
+ }
33698
33701
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
33699
33702
  nextToken();
33700
33703
  return !scanner2.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
@@ -34390,7 +34393,7 @@ ${lanes.join("\n")}
34390
34393
  identifier = parseIdentifier();
34391
34394
  }
34392
34395
  let isTypeOnly = false;
34393
- if (token() !== 161 /* FromKeyword */ && (identifier == null ? void 0 : identifier.escapedText) === "type" && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
34396
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
34394
34397
  isTypeOnly = true;
34395
34398
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
34396
34399
  }
@@ -42915,6 +42918,9 @@ ${lanes.join("\n")}
42915
42918
  for (let i = 0; i < clauses.length; i++) {
42916
42919
  const clauseStart = i;
42917
42920
  while (!clauses[i].statements.length && i + 1 < clauses.length) {
42921
+ if (fallthroughFlow === unreachableFlow) {
42922
+ currentFlow = preSwitchCaseFlow;
42923
+ }
42918
42924
  bind(clauses[i]);
42919
42925
  i++;
42920
42926
  }
@@ -160279,6 +160285,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160279
160285
  }
160280
160286
  return void 0;
160281
160287
  }
160288
+ if (isExportDeclaration(parent2) && contextToken.kind === 42 /* AsteriskToken */ || isNamedExports(parent2) && contextToken.kind === 20 /* CloseBraceToken */) {
160289
+ isKeywordOnlyCompletion = true;
160290
+ keywordCompletion = 161 /* FromKeyword */;
160291
+ return void 0;
160292
+ }
160282
160293
  if (isImportKeyword(contextToken) && isSourceFile(parent2)) {
160283
160294
  keywordCompletion = 156 /* TypeKeyword */;
160284
160295
  return contextToken;
@@ -172580,6 +172591,32 @@ ${options.prefix}` : "\n" : options.prefix
172580
172591
  }
172581
172592
  this.processCacheLocation(this.globalCachePath);
172582
172593
  }
172594
+ /** @internal */
172595
+ handleRequest(req) {
172596
+ switch (req.kind) {
172597
+ case "discover":
172598
+ this.install(req);
172599
+ break;
172600
+ case "closeProject":
172601
+ this.closeProject(req);
172602
+ break;
172603
+ case "typesRegistry": {
172604
+ const typesRegistry = {};
172605
+ this.typesRegistry.forEach((value, key) => {
172606
+ typesRegistry[key] = value;
172607
+ });
172608
+ const response = { kind: EventTypesRegistry, typesRegistry };
172609
+ this.sendResponse(response);
172610
+ break;
172611
+ }
172612
+ case "installPackage": {
172613
+ this.installPackage(req);
172614
+ break;
172615
+ }
172616
+ default:
172617
+ Debug.assertNever(req);
172618
+ }
172619
+ }
172583
172620
  closeProject(req) {
172584
172621
  this.closeWatchers(req.projectName);
172585
172622
  }
@@ -173978,8 +174015,9 @@ ${options.prefix}` : "\n" : options.prefix
173978
174015
  return !typeAcquisition || !typeAcquisition.enable ? emptyArray2 : typings;
173979
174016
  }
173980
174017
  onProjectClosed(project) {
173981
- this.perProjectCache.delete(project.getProjectName());
173982
- this.installer.onProjectClosed(project);
174018
+ if (this.perProjectCache.delete(project.getProjectName())) {
174019
+ this.installer.onProjectClosed(project);
174020
+ }
173983
174021
  }
173984
174022
  };
173985
174023
  }
@@ -183956,6 +183994,187 @@ ${e.message}`;
183956
183994
  }
183957
183995
  });
183958
183996
 
183997
+ // src/server/typingInstallerAdapter.ts
183998
+ var _TypingsInstallerAdapter, TypingsInstallerAdapter;
183999
+ var init_typingInstallerAdapter = __esm({
184000
+ "src/server/typingInstallerAdapter.ts"() {
184001
+ "use strict";
184002
+ init_ts7();
184003
+ init_ts_server3();
184004
+ _TypingsInstallerAdapter = class _TypingsInstallerAdapter {
184005
+ constructor(telemetryEnabled, logger, host, globalTypingsCacheLocation, event, maxActiveRequestCount) {
184006
+ this.telemetryEnabled = telemetryEnabled;
184007
+ this.logger = logger;
184008
+ this.host = host;
184009
+ this.globalTypingsCacheLocation = globalTypingsCacheLocation;
184010
+ this.event = event;
184011
+ this.maxActiveRequestCount = maxActiveRequestCount;
184012
+ this.activeRequestCount = 0;
184013
+ this.requestQueue = createQueue();
184014
+ this.requestMap = /* @__PURE__ */ new Map();
184015
+ // Maps project name to newest requestQueue entry for that project
184016
+ /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
184017
+ this.requestedRegistry = false;
184018
+ }
184019
+ isKnownTypesPackageName(name) {
184020
+ var _a;
184021
+ const validationResult = ts_JsTyping_exports.validatePackageName(name);
184022
+ if (validationResult !== ts_JsTyping_exports.NameValidationResult.Ok) {
184023
+ return false;
184024
+ }
184025
+ if (!this.requestedRegistry) {
184026
+ this.requestedRegistry = true;
184027
+ this.installer.send({ kind: "typesRegistry" });
184028
+ }
184029
+ return !!((_a = this.typesRegistryCache) == null ? void 0 : _a.has(name));
184030
+ }
184031
+ installPackage(options) {
184032
+ this.installer.send({ kind: "installPackage", ...options });
184033
+ Debug.assert(this.packageInstalledPromise === void 0);
184034
+ return new Promise((resolve, reject) => {
184035
+ this.packageInstalledPromise = { resolve, reject };
184036
+ });
184037
+ }
184038
+ attach(projectService) {
184039
+ this.projectService = projectService;
184040
+ this.installer = this.createInstallerProcess();
184041
+ }
184042
+ onProjectClosed(p) {
184043
+ this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" });
184044
+ }
184045
+ enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports) {
184046
+ const request = createInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
184047
+ if (this.logger.hasLevel(3 /* verbose */)) {
184048
+ this.logger.info(`TIAdapter:: Scheduling throttled operation:${stringifyIndented(request)}`);
184049
+ }
184050
+ if (this.activeRequestCount < this.maxActiveRequestCount) {
184051
+ this.scheduleRequest(request);
184052
+ } else {
184053
+ if (this.logger.hasLevel(3 /* verbose */)) {
184054
+ this.logger.info(`TIAdapter:: Deferring request for: ${request.projectName}`);
184055
+ }
184056
+ this.requestQueue.enqueue(request);
184057
+ this.requestMap.set(request.projectName, request);
184058
+ }
184059
+ }
184060
+ handleMessage(response) {
184061
+ if (this.logger.hasLevel(3 /* verbose */)) {
184062
+ this.logger.info(`TIAdapter:: Received response:${stringifyIndented(response)}`);
184063
+ }
184064
+ switch (response.kind) {
184065
+ case EventTypesRegistry:
184066
+ this.typesRegistryCache = new Map(Object.entries(response.typesRegistry));
184067
+ break;
184068
+ case ActionPackageInstalled: {
184069
+ const { success, message } = response;
184070
+ if (success) {
184071
+ this.packageInstalledPromise.resolve({ successMessage: message });
184072
+ } else {
184073
+ this.packageInstalledPromise.reject(message);
184074
+ }
184075
+ this.packageInstalledPromise = void 0;
184076
+ this.projectService.updateTypingsForProject(response);
184077
+ this.event(response, "setTypings");
184078
+ break;
184079
+ }
184080
+ case EventInitializationFailed: {
184081
+ const body = {
184082
+ message: response.message
184083
+ };
184084
+ const eventName = "typesInstallerInitializationFailed";
184085
+ this.event(body, eventName);
184086
+ break;
184087
+ }
184088
+ case EventBeginInstallTypes: {
184089
+ const body = {
184090
+ eventId: response.eventId,
184091
+ packages: response.packagesToInstall
184092
+ };
184093
+ const eventName = "beginInstallTypes";
184094
+ this.event(body, eventName);
184095
+ break;
184096
+ }
184097
+ case EventEndInstallTypes: {
184098
+ if (this.telemetryEnabled) {
184099
+ const body2 = {
184100
+ telemetryEventName: "typingsInstalled",
184101
+ payload: {
184102
+ installedPackages: response.packagesToInstall.join(","),
184103
+ installSuccess: response.installSuccess,
184104
+ typingsInstallerVersion: response.typingsInstallerVersion
184105
+ }
184106
+ };
184107
+ const eventName2 = "telemetry";
184108
+ this.event(body2, eventName2);
184109
+ }
184110
+ const body = {
184111
+ eventId: response.eventId,
184112
+ packages: response.packagesToInstall,
184113
+ success: response.installSuccess
184114
+ };
184115
+ const eventName = "endInstallTypes";
184116
+ this.event(body, eventName);
184117
+ break;
184118
+ }
184119
+ case ActionInvalidate: {
184120
+ this.projectService.updateTypingsForProject(response);
184121
+ break;
184122
+ }
184123
+ case ActionSet: {
184124
+ if (this.activeRequestCount > 0) {
184125
+ this.activeRequestCount--;
184126
+ } else {
184127
+ Debug.fail("TIAdapter:: Received too many responses");
184128
+ }
184129
+ while (!this.requestQueue.isEmpty()) {
184130
+ const queuedRequest = this.requestQueue.dequeue();
184131
+ if (this.requestMap.get(queuedRequest.projectName) === queuedRequest) {
184132
+ this.requestMap.delete(queuedRequest.projectName);
184133
+ this.scheduleRequest(queuedRequest);
184134
+ break;
184135
+ }
184136
+ if (this.logger.hasLevel(3 /* verbose */)) {
184137
+ this.logger.info(`TIAdapter:: Skipping defunct request for: ${queuedRequest.projectName}`);
184138
+ }
184139
+ }
184140
+ this.projectService.updateTypingsForProject(response);
184141
+ this.event(response, "setTypings");
184142
+ break;
184143
+ }
184144
+ case ActionWatchTypingLocations:
184145
+ this.projectService.watchTypingLocations(response);
184146
+ break;
184147
+ default:
184148
+ assertType(response);
184149
+ }
184150
+ }
184151
+ scheduleRequest(request) {
184152
+ if (this.logger.hasLevel(3 /* verbose */)) {
184153
+ this.logger.info(`TIAdapter:: Scheduling request for: ${request.projectName}`);
184154
+ }
184155
+ this.activeRequestCount++;
184156
+ this.host.setTimeout(
184157
+ () => {
184158
+ if (this.logger.hasLevel(3 /* verbose */)) {
184159
+ this.logger.info(`TIAdapter:: Sending request:${stringifyIndented(request)}`);
184160
+ }
184161
+ this.installer.send(request);
184162
+ },
184163
+ _TypingsInstallerAdapter.requestDelayMillis,
184164
+ `${request.projectName}::${request.kind}`
184165
+ );
184166
+ }
184167
+ };
184168
+ // This number is essentially arbitrary. Processing more than one typings request
184169
+ // at a time makes sense, but having too many in the pipe results in a hang
184170
+ // (see https://github.com/nodejs/node/issues/7657).
184171
+ // It would be preferable to base our limit on the amount of space left in the
184172
+ // buffer, but we have yet to find a way to retrieve that value.
184173
+ _TypingsInstallerAdapter.requestDelayMillis = 100;
184174
+ TypingsInstallerAdapter = _TypingsInstallerAdapter;
184175
+ }
184176
+ });
184177
+
183959
184178
  // src/server/_namespaces/ts.server.ts
183960
184179
  var ts_server_exports3 = {};
183961
184180
  __export(ts_server_exports3, {
@@ -184003,6 +184222,7 @@ ${e.message}`;
184003
184222
  TextStorage: () => TextStorage,
184004
184223
  ThrottledOperations: () => ThrottledOperations,
184005
184224
  TypingsCache: () => TypingsCache,
184225
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
184006
184226
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
184007
184227
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
184008
184228
  asNormalizedPath: () => asNormalizedPath,
@@ -184071,6 +184291,7 @@ ${e.message}`;
184071
184291
  init_packageJsonCache();
184072
184292
  init_session();
184073
184293
  init_scriptVersionCache();
184294
+ init_typingInstallerAdapter();
184074
184295
  }
184075
184296
  });
184076
184297
 
@@ -186425,6 +186646,7 @@ ${e.message}`;
186425
186646
  TextStorage: () => TextStorage,
186426
186647
  ThrottledOperations: () => ThrottledOperations,
186427
186648
  TypingsCache: () => TypingsCache,
186649
+ TypingsInstallerAdapter: () => TypingsInstallerAdapter,
186428
186650
  allFilesAreJsOrDts: () => allFilesAreJsOrDts,
186429
186651
  allRootFilesAreJsOrDts: () => allRootFilesAreJsOrDts,
186430
186652
  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-dev.20231113`;
57
+ var version = `${versionMajorMinor}.0-dev.20231115`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -23031,6 +23031,9 @@ var Parser;
23031
23031
  function nextTokenIsStringLiteral() {
23032
23032
  return nextToken() === 11 /* StringLiteral */;
23033
23033
  }
23034
+ function nextTokenIsFromKeyword() {
23035
+ return nextToken() === 161 /* FromKeyword */;
23036
+ }
23034
23037
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
23035
23038
  nextToken();
23036
23039
  return !scanner.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
@@ -23726,7 +23729,7 @@ var Parser;
23726
23729
  identifier = parseIdentifier();
23727
23730
  }
23728
23731
  let isTypeOnly = false;
23729
- if (token() !== 161 /* FromKeyword */ && (identifier == null ? void 0 : identifier.escapedText) === "type" && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
23732
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
23730
23733
  isTypeOnly = true;
23731
23734
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
23732
23735
  }
@@ -31847,6 +31850,32 @@ var TypingsInstaller = class {
31847
31850
  }
31848
31851
  this.processCacheLocation(this.globalCachePath);
31849
31852
  }
31853
+ /** @internal */
31854
+ handleRequest(req) {
31855
+ switch (req.kind) {
31856
+ case "discover":
31857
+ this.install(req);
31858
+ break;
31859
+ case "closeProject":
31860
+ this.closeProject(req);
31861
+ break;
31862
+ case "typesRegistry": {
31863
+ const typesRegistry = {};
31864
+ this.typesRegistry.forEach((value, key) => {
31865
+ typesRegistry[key] = value;
31866
+ });
31867
+ const response = { kind: EventTypesRegistry, typesRegistry };
31868
+ this.sendResponse(response);
31869
+ break;
31870
+ }
31871
+ case "installPackage": {
31872
+ this.installPackage(req);
31873
+ break;
31874
+ }
31875
+ default:
31876
+ Debug.assertNever(req);
31877
+ }
31878
+ }
31850
31879
  closeProject(req) {
31851
31880
  this.closeWatchers(req.projectName);
31852
31881
  }
@@ -32264,29 +32293,7 @@ var NodeTypingsInstaller = class extends TypingsInstaller {
32264
32293
  this.sendResponse(this.delayedInitializationError);
32265
32294
  this.delayedInitializationError = void 0;
32266
32295
  }
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
- }
32296
+ super.handleRequest(req);
32290
32297
  }
32291
32298
  sendResponse(response) {
32292
32299
  if (this.log.isEnabled()) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.4.0-dev.20231113",
5
+ "version": "5.4.0-dev.20231115",
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": "6e9ac5b617d4e69daded6440da8d393990feea96"
117
+ "gitHead": "e170bc59d4ba0d335ce86f66296bec71c5018317"
118
118
  }