typescript 7.1.0-dev.20260922.1 → 7.1.0-dev.20260924.1
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/dist/api/async/api.d.ts +64 -5
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +147 -22
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/async/client.d.ts +1 -0
- package/dist/api/async/client.d.ts.map +1 -1
- package/dist/api/async/client.js +7 -0
- package/dist/api/async/client.js.map +1 -1
- package/dist/api/async/types.d.ts +13 -0
- package/dist/api/async/types.d.ts.map +1 -1
- package/dist/api/fs.d.ts +1 -1
- package/dist/api/fs.d.ts.map +1 -1
- package/dist/api/fs.js +2 -42
- package/dist/api/fs.js.map +1 -1
- package/dist/api/path.d.ts.map +1 -1
- package/dist/api/path.js +7 -1
- package/dist/api/path.js.map +1 -1
- package/dist/api/proto.generated.d.ts +61 -4
- package/dist/api/proto.generated.d.ts.map +1 -1
- package/dist/api/sync/api.d.ts +87 -5
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +230 -43
- package/dist/api/sync/api.js.map +1 -1
- package/dist/api/sync/client.d.ts +1 -0
- package/dist/api/sync/client.d.ts.map +1 -1
- package/dist/api/sync/client.js +4 -0
- package/dist/api/sync/client.js.map +1 -1
- package/dist/api/sync/types.d.ts +25 -0
- package/dist/api/sync/types.d.ts.map +1 -1
- package/dist/api/syncChannel.d.ts +1 -0
- package/dist/api/syncChannel.d.ts.map +1 -1
- package/dist/api/syncChannel.js +3 -0
- package/dist/api/syncChannel.js.map +1 -1
- package/dist/enums/checkFlags.enum.js +1 -1
- package/dist/enums/checkFlags.enum.js.map +1 -1
- package/dist/enums/checkFlags.js +1 -1
- package/dist/enums/checkFlags.js.map +1 -1
- package/dist/enums/completionItemKind.enum.js +1 -1
- package/dist/enums/completionItemKind.enum.js.map +1 -1
- package/dist/enums/completionItemKind.js +1 -1
- package/dist/enums/completionItemKind.js.map +1 -1
- package/dist/enums/diagnosticCategory.enum.js +1 -1
- package/dist/enums/diagnosticCategory.enum.js.map +1 -1
- package/dist/enums/diagnosticCategory.js +1 -1
- package/dist/enums/diagnosticCategory.js.map +1 -1
- package/dist/enums/diagnosticDirectivePolicy.enum.js +1 -1
- package/dist/enums/diagnosticDirectivePolicy.enum.js.map +1 -1
- package/dist/enums/diagnosticDirectivePolicy.js +1 -1
- package/dist/enums/diagnosticDirectivePolicy.js.map +1 -1
- package/dist/enums/elementFlags.enum.js +1 -1
- package/dist/enums/elementFlags.enum.js.map +1 -1
- package/dist/enums/elementFlags.js +1 -1
- package/dist/enums/elementFlags.js.map +1 -1
- package/dist/enums/emitOnly.enum.js +1 -1
- package/dist/enums/emitOnly.enum.js.map +1 -1
- package/dist/enums/emitOnly.js +1 -1
- package/dist/enums/emitOnly.js.map +1 -1
- package/dist/enums/indexKind.enum.js +1 -1
- package/dist/enums/indexKind.enum.js.map +1 -1
- package/dist/enums/indexKind.js +1 -1
- package/dist/enums/indexKind.js.map +1 -1
- package/dist/enums/internalSymbolName.enum.js +1 -1
- package/dist/enums/internalSymbolName.enum.js.map +1 -1
- package/dist/enums/internalSymbolName.js +1 -1
- package/dist/enums/internalSymbolName.js.map +1 -1
- package/dist/enums/jsxEmit.enum.js +1 -1
- package/dist/enums/jsxEmit.enum.js.map +1 -1
- package/dist/enums/jsxEmit.js +1 -1
- package/dist/enums/jsxEmit.js.map +1 -1
- package/dist/enums/modifierFlags.enum.js +1 -1
- package/dist/enums/modifierFlags.enum.js.map +1 -1
- package/dist/enums/modifierFlags.js +1 -1
- package/dist/enums/modifierFlags.js.map +1 -1
- package/dist/enums/moduleDetectionKind.enum.js +1 -1
- package/dist/enums/moduleDetectionKind.enum.js.map +1 -1
- package/dist/enums/moduleDetectionKind.js +1 -1
- package/dist/enums/moduleDetectionKind.js.map +1 -1
- package/dist/enums/moduleKind.enum.js +1 -1
- package/dist/enums/moduleKind.enum.js.map +1 -1
- package/dist/enums/moduleKind.js +1 -1
- package/dist/enums/moduleKind.js.map +1 -1
- package/dist/enums/moduleResolutionKind.enum.js +1 -1
- package/dist/enums/moduleResolutionKind.enum.js.map +1 -1
- package/dist/enums/moduleResolutionKind.js +1 -1
- package/dist/enums/moduleResolutionKind.js.map +1 -1
- package/dist/enums/newLineKind.enum.js +1 -1
- package/dist/enums/newLineKind.enum.js.map +1 -1
- package/dist/enums/newLineKind.js +1 -1
- package/dist/enums/newLineKind.js.map +1 -1
- package/dist/enums/nodeBuilderFlags.enum.js +1 -1
- package/dist/enums/nodeBuilderFlags.enum.js.map +1 -1
- package/dist/enums/nodeBuilderFlags.js +1 -1
- package/dist/enums/nodeBuilderFlags.js.map +1 -1
- package/dist/enums/nodeFlags.enum.js +1 -1
- package/dist/enums/nodeFlags.enum.js.map +1 -1
- package/dist/enums/nodeFlags.js +1 -1
- package/dist/enums/nodeFlags.js.map +1 -1
- package/dist/enums/objectFlags.enum.js +1 -1
- package/dist/enums/objectFlags.enum.js.map +1 -1
- package/dist/enums/objectFlags.js +1 -1
- package/dist/enums/objectFlags.js.map +1 -1
- package/dist/enums/outerExpressionKinds.enum.js +1 -1
- package/dist/enums/outerExpressionKinds.enum.js.map +1 -1
- package/dist/enums/outerExpressionKinds.js +1 -1
- package/dist/enums/outerExpressionKinds.js.map +1 -1
- package/dist/enums/scriptKind.enum.js +1 -1
- package/dist/enums/scriptKind.enum.js.map +1 -1
- package/dist/enums/scriptKind.js +1 -1
- package/dist/enums/scriptKind.js.map +1 -1
- package/dist/enums/signatureFlags.enum.js +1 -1
- package/dist/enums/signatureFlags.enum.js.map +1 -1
- package/dist/enums/signatureFlags.js +1 -1
- package/dist/enums/signatureFlags.js.map +1 -1
- package/dist/enums/signatureKind.enum.js +1 -1
- package/dist/enums/signatureKind.enum.js.map +1 -1
- package/dist/enums/signatureKind.js +1 -1
- package/dist/enums/signatureKind.js.map +1 -1
- package/dist/enums/spanMapFeature.enum.js +1 -1
- package/dist/enums/spanMapFeature.enum.js.map +1 -1
- package/dist/enums/spanMapFeature.js +1 -1
- package/dist/enums/spanMapFeature.js.map +1 -1
- package/dist/enums/spanMapFidelity.enum.js +1 -1
- package/dist/enums/spanMapFidelity.enum.js.map +1 -1
- package/dist/enums/spanMapFidelity.js +1 -1
- package/dist/enums/spanMapFidelity.js.map +1 -1
- package/dist/enums/spanMapKind.enum.js +1 -1
- package/dist/enums/spanMapKind.enum.js.map +1 -1
- package/dist/enums/spanMapKind.js +1 -1
- package/dist/enums/spanMapKind.js.map +1 -1
- package/dist/enums/symbolFlags.enum.js +1 -1
- package/dist/enums/symbolFlags.enum.js.map +1 -1
- package/dist/enums/symbolFlags.js +1 -1
- package/dist/enums/symbolFlags.js.map +1 -1
- package/dist/enums/syntaxKind.enum.js +1 -1
- package/dist/enums/syntaxKind.enum.js.map +1 -1
- package/dist/enums/syntaxKind.js +1 -1
- package/dist/enums/syntaxKind.js.map +1 -1
- package/dist/enums/tokenFlags.enum.js +1 -1
- package/dist/enums/tokenFlags.enum.js.map +1 -1
- package/dist/enums/tokenFlags.js +1 -1
- package/dist/enums/tokenFlags.js.map +1 -1
- package/dist/enums/typeFlags.enum.js +1 -1
- package/dist/enums/typeFlags.enum.js.map +1 -1
- package/dist/enums/typeFlags.js +1 -1
- package/dist/enums/typeFlags.js.map +1 -1
- package/dist/enums/typeFormatFlags.enum.js +1 -1
- package/dist/enums/typeFormatFlags.enum.js.map +1 -1
- package/dist/enums/typeFormatFlags.js +1 -1
- package/dist/enums/typeFormatFlags.js.map +1 -1
- package/dist/enums/typePredicateKind.enum.js +1 -1
- package/dist/enums/typePredicateKind.enum.js.map +1 -1
- package/dist/enums/typePredicateKind.js +1 -1
- package/dist/enums/typePredicateKind.js.map +1 -1
- package/package.json +9 -9
package/dist/api/sync/api.js
CHANGED
|
@@ -30,6 +30,22 @@ import { Client, } from "./client.js";
|
|
|
30
30
|
export { formatDiagnostics, formatDiagnosticsWithColorAndContext } from "../diagnosticFormatter.js";
|
|
31
31
|
export { documentURIToFileName, fileNameToDocumentURI } from "../path.js";
|
|
32
32
|
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, IndexKind, JsxEmit, ModifierFlags, ModuleKind, ModuleResolutionKind, NodeBuilderFlags, ObjectFlags, ScriptKind, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
|
|
33
|
+
let nextModuleResolutionCallbackId = 0;
|
|
34
|
+
function registerModuleResolutionCallback(client, callback, getSnapshot) {
|
|
35
|
+
const name = `resolveModuleName/${++nextModuleResolutionCallbackId}`;
|
|
36
|
+
const dispose = client.registerCallback(name, params => {
|
|
37
|
+
const { moduleName, containingDirectory, resolutionMode, snapshot: snapshotId, inProgressSnapshot } = params;
|
|
38
|
+
let snapshot = snapshotId === undefined ? undefined : getSnapshot(snapshotId);
|
|
39
|
+
if (snapshotId !== undefined && snapshot === undefined) {
|
|
40
|
+
throw new Error(`Snapshot ${snapshotId} is inactive`);
|
|
41
|
+
}
|
|
42
|
+
if (inProgressSnapshot !== undefined) {
|
|
43
|
+
snapshot = -inProgressSnapshot;
|
|
44
|
+
}
|
|
45
|
+
return callback(moduleName, containingDirectory, resolutionMode, { snapshot });
|
|
46
|
+
});
|
|
47
|
+
return { name, dispose };
|
|
48
|
+
}
|
|
33
49
|
export { all, defer } from "./generatorSupport.js";
|
|
34
50
|
import { sourceFileResponseToUint8Array } from "../node/encoder.js";
|
|
35
51
|
import { executeRequestGenerators, } from "./generatorSupport.js";
|
|
@@ -42,7 +58,7 @@ export class API {
|
|
|
42
58
|
getCanonicalFileNameWorker;
|
|
43
59
|
initialized = false;
|
|
44
60
|
initializing;
|
|
45
|
-
activeSnapshots = new
|
|
61
|
+
activeSnapshots = new Map();
|
|
46
62
|
printer;
|
|
47
63
|
internal;
|
|
48
64
|
constructor(options = {}) {
|
|
@@ -249,24 +265,24 @@ export class API {
|
|
|
249
265
|
const owner = this;
|
|
250
266
|
function createSnapshot(params) {
|
|
251
267
|
owner.ensureInitialized();
|
|
252
|
-
const requestParams = toCreateSnapshotRequest(params);
|
|
268
|
+
const requestParams = toCreateSnapshotRequest(owner.prepareCreateSnapshotParams(params));
|
|
253
269
|
const data = owner.client.apiRequest("createSnapshot", requestParams);
|
|
254
270
|
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
255
|
-
owner.activeSnapshots.delete(snapshot);
|
|
271
|
+
owner.activeSnapshots.delete(snapshot.id);
|
|
256
272
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
257
273
|
}, owner.createSnapshotUpdater(() => snapshot), undefined);
|
|
258
|
-
owner.activeSnapshots.
|
|
274
|
+
owner.activeSnapshots.set(snapshot.id, snapshot);
|
|
259
275
|
return snapshot;
|
|
260
276
|
}
|
|
261
277
|
function* gen(params) {
|
|
262
278
|
yield* owner.ensureInitialized.gen();
|
|
263
|
-
const requestParams = toCreateSnapshotRequest(params);
|
|
279
|
+
const requestParams = toCreateSnapshotRequest(owner.prepareCreateSnapshotParams(params));
|
|
264
280
|
const data = yield* apiRequest("createSnapshot", requestParams);
|
|
265
281
|
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
266
|
-
owner.activeSnapshots.delete(snapshot);
|
|
282
|
+
owner.activeSnapshots.delete(snapshot.id);
|
|
267
283
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
268
284
|
}, owner.createSnapshotUpdater(() => snapshot), undefined);
|
|
269
|
-
owner.activeSnapshots.
|
|
285
|
+
owner.activeSnapshots.set(snapshot.id, snapshot);
|
|
270
286
|
return snapshot;
|
|
271
287
|
}
|
|
272
288
|
return cacheGeneratorMethod(owner, "createSnapshot", createSnapshot, gen);
|
|
@@ -275,12 +291,12 @@ export class API {
|
|
|
275
291
|
const owner = this;
|
|
276
292
|
return cacheGeneratorMethod(owner, "updateSnapshot", function (baseSnapshot, params) {
|
|
277
293
|
owner.ensureInitialized();
|
|
278
|
-
if (
|
|
294
|
+
if (owner.activeSnapshots.get(baseSnapshot.id) !== baseSnapshot || baseSnapshot.isDisposed()) {
|
|
279
295
|
throw new Error("Cannot update an inactive snapshot");
|
|
280
296
|
}
|
|
281
297
|
const data = owner.client.apiRequest("updateSnapshot", {
|
|
282
298
|
snapshot: baseSnapshot.id,
|
|
283
|
-
changes: toCreateSnapshotRequest(params),
|
|
299
|
+
changes: toCreateSnapshotRequest(owner.prepareCreateSnapshotParams(params)),
|
|
284
300
|
});
|
|
285
301
|
if (data.snapshot === baseSnapshot.id) {
|
|
286
302
|
owner.client.apiRequest("release", { snapshot: data.snapshot });
|
|
@@ -288,19 +304,19 @@ export class API {
|
|
|
288
304
|
}
|
|
289
305
|
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
290
306
|
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
291
|
-
owner.activeSnapshots.delete(snapshot);
|
|
307
|
+
owner.activeSnapshots.delete(snapshot.id);
|
|
292
308
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
293
309
|
}, owner.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
294
|
-
owner.activeSnapshots.
|
|
310
|
+
owner.activeSnapshots.set(snapshot.id, snapshot);
|
|
295
311
|
return snapshot;
|
|
296
312
|
}, function* (baseSnapshot, params) {
|
|
297
313
|
yield* owner.ensureInitialized.gen();
|
|
298
|
-
if (
|
|
314
|
+
if (owner.activeSnapshots.get(baseSnapshot.id) !== baseSnapshot || baseSnapshot.isDisposed()) {
|
|
299
315
|
throw new Error("Cannot update an inactive snapshot");
|
|
300
316
|
}
|
|
301
317
|
const data = yield* apiRequest("updateSnapshot", {
|
|
302
318
|
snapshot: baseSnapshot.id,
|
|
303
|
-
changes: toCreateSnapshotRequest(params),
|
|
319
|
+
changes: toCreateSnapshotRequest(owner.prepareCreateSnapshotParams(params)),
|
|
304
320
|
});
|
|
305
321
|
if (data.snapshot === baseSnapshot.id) {
|
|
306
322
|
yield* apiRequest("release", { snapshot: data.snapshot });
|
|
@@ -308,13 +324,38 @@ export class API {
|
|
|
308
324
|
}
|
|
309
325
|
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
310
326
|
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
311
|
-
owner.activeSnapshots.delete(snapshot);
|
|
327
|
+
owner.activeSnapshots.delete(snapshot.id);
|
|
312
328
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
313
329
|
}, owner.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
314
|
-
owner.activeSnapshots.
|
|
330
|
+
owner.activeSnapshots.set(snapshot.id, snapshot);
|
|
315
331
|
return snapshot;
|
|
316
332
|
});
|
|
317
333
|
}
|
|
334
|
+
prepareCreateSnapshotParams(params) {
|
|
335
|
+
if (!params)
|
|
336
|
+
return undefined;
|
|
337
|
+
const prepareOptions = (options) => {
|
|
338
|
+
if (!options)
|
|
339
|
+
return undefined;
|
|
340
|
+
const { moduleResolver, ...rest } = options;
|
|
341
|
+
moduleResolver?.ensureNotDisposed();
|
|
342
|
+
return {
|
|
343
|
+
...rest,
|
|
344
|
+
moduleResolver: moduleResolver?.id,
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
return {
|
|
348
|
+
...params,
|
|
349
|
+
createPrograms: params.createPrograms?.map(program => ({ ...program, options: prepareOptions(program.options) })),
|
|
350
|
+
reconfigurePrograms: params.reconfigurePrograms?.map(program => ({ ...program, options: prepareOptions(program.options) })),
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
prepareLanguageServerSnapshotChanges(changes) {
|
|
354
|
+
if (!changes)
|
|
355
|
+
return undefined;
|
|
356
|
+
const prepared = this.prepareCreateSnapshotParams(changes);
|
|
357
|
+
return prepared;
|
|
358
|
+
}
|
|
318
359
|
createSnapshotUpdater(getSnapshot) {
|
|
319
360
|
const update = ((params) => this.updateSnapshot(getSnapshot(), params));
|
|
320
361
|
const owner = this;
|
|
@@ -333,42 +374,42 @@ export class API {
|
|
|
333
374
|
owner.ensureInitialized();
|
|
334
375
|
const changes = args[0];
|
|
335
376
|
const baseSnapshot = args[1];
|
|
336
|
-
if (baseSnapshot && (
|
|
377
|
+
if (baseSnapshot && (owner.activeSnapshots.get(baseSnapshot.id) !== baseSnapshot || baseSnapshot.isDisposed())) {
|
|
337
378
|
throw new Error("Cannot use an inactive snapshot as a response base");
|
|
338
379
|
}
|
|
339
380
|
const data = owner.client.apiRequest("getCurrentLanguageServerSnapshot", {
|
|
340
381
|
baseSnapshot: baseSnapshot?.id,
|
|
341
|
-
changes,
|
|
382
|
+
changes: owner.prepareLanguageServerSnapshotChanges(changes),
|
|
342
383
|
});
|
|
343
384
|
if (baseSnapshot) {
|
|
344
385
|
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
345
386
|
}
|
|
346
387
|
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
347
|
-
owner.activeSnapshots.delete(snapshot);
|
|
388
|
+
owner.activeSnapshots.delete(snapshot.id);
|
|
348
389
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
349
390
|
}, owner.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
350
|
-
owner.activeSnapshots.
|
|
391
|
+
owner.activeSnapshots.set(snapshot.id, snapshot);
|
|
351
392
|
return snapshot;
|
|
352
393
|
}
|
|
353
394
|
function* gen(...args) {
|
|
354
395
|
yield* owner.ensureInitialized.gen();
|
|
355
396
|
const changes = args[0];
|
|
356
397
|
const baseSnapshot = args[1];
|
|
357
|
-
if (baseSnapshot && (
|
|
398
|
+
if (baseSnapshot && (owner.activeSnapshots.get(baseSnapshot.id) !== baseSnapshot || baseSnapshot.isDisposed())) {
|
|
358
399
|
throw new Error("Cannot use an inactive snapshot as a response base");
|
|
359
400
|
}
|
|
360
401
|
const data = yield* apiRequest("getCurrentLanguageServerSnapshot", {
|
|
361
402
|
baseSnapshot: baseSnapshot?.id,
|
|
362
|
-
changes,
|
|
403
|
+
changes: owner.prepareLanguageServerSnapshotChanges(changes),
|
|
363
404
|
});
|
|
364
405
|
if (baseSnapshot) {
|
|
365
406
|
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
366
407
|
}
|
|
367
408
|
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
368
|
-
owner.activeSnapshots.delete(snapshot);
|
|
409
|
+
owner.activeSnapshots.delete(snapshot.id);
|
|
369
410
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
370
411
|
}, owner.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
371
|
-
owner.activeSnapshots.
|
|
412
|
+
owner.activeSnapshots.set(snapshot.id, snapshot);
|
|
372
413
|
return snapshot;
|
|
373
414
|
}
|
|
374
415
|
return cacheGeneratorMethod(owner, "getCurrentLanguageServerSnapshot", getCurrentLanguageServerSnapshot, gen);
|
|
@@ -381,7 +422,7 @@ export class API {
|
|
|
381
422
|
return cacheGeneratorMethod(owner, "close", function () {
|
|
382
423
|
// Dispose all active snapshots
|
|
383
424
|
try {
|
|
384
|
-
for (const snapshot of [...owner.activeSnapshots]) {
|
|
425
|
+
for (const snapshot of [...owner.activeSnapshots.values()]) {
|
|
385
426
|
snapshot.dispose();
|
|
386
427
|
}
|
|
387
428
|
owner.sourceFileCache.clear();
|
|
@@ -392,7 +433,7 @@ export class API {
|
|
|
392
433
|
}, function* () {
|
|
393
434
|
// Dispose all active snapshots
|
|
394
435
|
try {
|
|
395
|
-
for (const snapshot of [...owner.activeSnapshots]) {
|
|
436
|
+
for (const snapshot of [...owner.activeSnapshots.values()]) {
|
|
396
437
|
yield* snapshot.dispose.gen();
|
|
397
438
|
}
|
|
398
439
|
owner.sourceFileCache.clear();
|
|
@@ -402,6 +443,44 @@ export class API {
|
|
|
402
443
|
}
|
|
403
444
|
});
|
|
404
445
|
}
|
|
446
|
+
get createModuleResolver() {
|
|
447
|
+
const owner = this;
|
|
448
|
+
return cacheGeneratorMethod(owner, "createModuleResolver", function (compilerOptions, options) {
|
|
449
|
+
owner.ensureInitialized();
|
|
450
|
+
const callback = options?.resolveModuleName
|
|
451
|
+
? registerModuleResolutionCallback(owner.client, options.resolveModuleName, id => owner.activeSnapshots.get(id))
|
|
452
|
+
: undefined;
|
|
453
|
+
try {
|
|
454
|
+
const id = owner.client.apiRequest("createModuleResolver", {
|
|
455
|
+
compilerOptions,
|
|
456
|
+
moduleResolutions: options?.moduleResolutions,
|
|
457
|
+
resolveModuleNameCallback: callback?.name,
|
|
458
|
+
});
|
|
459
|
+
return new ModuleResolver(id, owner.client, callback?.dispose);
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
callback?.dispose();
|
|
463
|
+
throw error;
|
|
464
|
+
}
|
|
465
|
+
}, function* (compilerOptions, options) {
|
|
466
|
+
yield* owner.ensureInitialized.gen();
|
|
467
|
+
const callback = options?.resolveModuleName
|
|
468
|
+
? registerModuleResolutionCallback(owner.client, options.resolveModuleName, id => owner.activeSnapshots.get(id))
|
|
469
|
+
: undefined;
|
|
470
|
+
try {
|
|
471
|
+
const id = yield* apiRequest("createModuleResolver", {
|
|
472
|
+
compilerOptions,
|
|
473
|
+
moduleResolutions: options?.moduleResolutions,
|
|
474
|
+
resolveModuleNameCallback: callback?.name,
|
|
475
|
+
});
|
|
476
|
+
return new ModuleResolver(id, owner.client, callback?.dispose);
|
|
477
|
+
}
|
|
478
|
+
catch (error) {
|
|
479
|
+
callback?.dispose();
|
|
480
|
+
throw error;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
405
484
|
clearSourceFileCache() {
|
|
406
485
|
this.sourceFileCache.clear();
|
|
407
486
|
}
|
|
@@ -409,7 +488,7 @@ export class API {
|
|
|
409
488
|
const owner = this;
|
|
410
489
|
return cacheGeneratorMethod(owner, "runWithTemporaryFileUpdate", function (baseSnapshot, file, newText, cb) {
|
|
411
490
|
owner.ensureInitialized();
|
|
412
|
-
if (
|
|
491
|
+
if (owner.activeSnapshots.get(baseSnapshot.id) !== baseSnapshot || baseSnapshot.isDisposed()) {
|
|
413
492
|
throw new Error("Cannot run a temporary file update on an inactive snapshot");
|
|
414
493
|
}
|
|
415
494
|
const snapshot = baseSnapshot.update({
|
|
@@ -427,7 +506,7 @@ export class API {
|
|
|
427
506
|
}
|
|
428
507
|
}, function* (baseSnapshot, file, newText, cb) {
|
|
429
508
|
yield* owner.ensureInitialized.gen();
|
|
430
|
-
if (
|
|
509
|
+
if (owner.activeSnapshots.get(baseSnapshot.id) !== baseSnapshot || baseSnapshot.isDisposed()) {
|
|
431
510
|
throw new Error("Cannot run a temporary file update on an inactive snapshot");
|
|
432
511
|
}
|
|
433
512
|
const snapshot = yield* baseSnapshot.update.gen({
|
|
@@ -701,6 +780,71 @@ export class Snapshot {
|
|
|
701
780
|
return project;
|
|
702
781
|
}
|
|
703
782
|
}
|
|
783
|
+
export class ModuleResolver {
|
|
784
|
+
id;
|
|
785
|
+
client;
|
|
786
|
+
disposeCallback;
|
|
787
|
+
disposed = false;
|
|
788
|
+
constructor(id, client, disposeCallback) {
|
|
789
|
+
this.id = id;
|
|
790
|
+
this.client = client;
|
|
791
|
+
this.disposeCallback = disposeCallback;
|
|
792
|
+
}
|
|
793
|
+
get resolveModuleName() {
|
|
794
|
+
const owner = this;
|
|
795
|
+
return cacheGeneratorMethod(owner, "resolveModuleName", function (moduleName, containingDirectory, resolutionMode, options) {
|
|
796
|
+
owner.ensureNotDisposed();
|
|
797
|
+
if (options?.snapshot instanceof Snapshot && options.snapshot.isDisposed()) {
|
|
798
|
+
throw new Error("Snapshot is disposed");
|
|
799
|
+
}
|
|
800
|
+
return owner.client.apiRequest("resolveModuleName", {
|
|
801
|
+
snapshot: options?.snapshot instanceof Snapshot ? options.snapshot.id : undefined,
|
|
802
|
+
inProgressSnapshot: typeof options?.snapshot === "number" ? -options.snapshot : undefined,
|
|
803
|
+
resolver: owner.id,
|
|
804
|
+
moduleName,
|
|
805
|
+
containingDirectory,
|
|
806
|
+
resolutionMode,
|
|
807
|
+
});
|
|
808
|
+
}, function* (moduleName, containingDirectory, resolutionMode, options) {
|
|
809
|
+
owner.ensureNotDisposed();
|
|
810
|
+
if (options?.snapshot instanceof Snapshot && options.snapshot.isDisposed()) {
|
|
811
|
+
throw new Error("Snapshot is disposed");
|
|
812
|
+
}
|
|
813
|
+
return yield* apiRequest("resolveModuleName", {
|
|
814
|
+
snapshot: options?.snapshot instanceof Snapshot ? options.snapshot.id : undefined,
|
|
815
|
+
inProgressSnapshot: typeof options?.snapshot === "number" ? -options.snapshot : undefined,
|
|
816
|
+
resolver: owner.id,
|
|
817
|
+
moduleName,
|
|
818
|
+
containingDirectory,
|
|
819
|
+
resolutionMode,
|
|
820
|
+
});
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
[globalThis.Symbol.dispose]() {
|
|
824
|
+
return this.dispose();
|
|
825
|
+
}
|
|
826
|
+
get dispose() {
|
|
827
|
+
const owner = this;
|
|
828
|
+
return cacheGeneratorMethod(owner, "dispose", function () {
|
|
829
|
+
if (owner.disposed)
|
|
830
|
+
return;
|
|
831
|
+
owner.client.apiRequest("releaseModuleResolver", { resolver: owner.id });
|
|
832
|
+
owner.disposed = true;
|
|
833
|
+
owner.disposeCallback?.();
|
|
834
|
+
}, function* () {
|
|
835
|
+
if (owner.disposed)
|
|
836
|
+
return;
|
|
837
|
+
yield* apiRequest("releaseModuleResolver", { resolver: owner.id });
|
|
838
|
+
owner.disposed = true;
|
|
839
|
+
owner.disposeCallback?.();
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
/** @internal */
|
|
843
|
+
ensureNotDisposed() {
|
|
844
|
+
if (this.disposed)
|
|
845
|
+
throw new Error("ModuleResolver is disposed");
|
|
846
|
+
}
|
|
847
|
+
}
|
|
704
848
|
class SnapshotObjectRegistry {
|
|
705
849
|
symbols = new Map();
|
|
706
850
|
client;
|
|
@@ -3196,21 +3340,9 @@ export class Checker {
|
|
|
3196
3340
|
get getIndexTypeOfType() {
|
|
3197
3341
|
const owner = this;
|
|
3198
3342
|
return cacheGeneratorMethod(owner, "getIndexTypeOfType", function (type, kind) {
|
|
3199
|
-
|
|
3200
|
-
snapshot: owner.snapshotId,
|
|
3201
|
-
project: owner.project.id,
|
|
3202
|
-
type: type.id,
|
|
3203
|
-
kind,
|
|
3204
|
-
});
|
|
3205
|
-
return data ? owner.objectRegistry.getOrCreateType(data) : undefined;
|
|
3343
|
+
return kind === IndexKind.String ? type.getStringIndexType() : type.getNumberIndexType();
|
|
3206
3344
|
}, function* (type, kind) {
|
|
3207
|
-
|
|
3208
|
-
snapshot: owner.snapshotId,
|
|
3209
|
-
project: owner.project.id,
|
|
3210
|
-
type: type.id,
|
|
3211
|
-
kind,
|
|
3212
|
-
});
|
|
3213
|
-
return data ? owner.objectRegistry.getOrCreateType(data) : undefined;
|
|
3345
|
+
return kind === IndexKind.String ? (yield* type.getStringIndexType.gen()) : (yield* type.getNumberIndexType.gen());
|
|
3214
3346
|
});
|
|
3215
3347
|
}
|
|
3216
3348
|
get getTypeOfPropertyOfType() {
|
|
@@ -3951,6 +4083,10 @@ class TypeObject {
|
|
|
3951
4083
|
extendsType;
|
|
3952
4084
|
baseType;
|
|
3953
4085
|
substConstraint;
|
|
4086
|
+
typeParameter;
|
|
4087
|
+
constraintType;
|
|
4088
|
+
nameType;
|
|
4089
|
+
templateType;
|
|
3954
4090
|
// Cached results of lazy fetches, not included in TypeResponse
|
|
3955
4091
|
// (typically because they require some amount of computation or
|
|
3956
4092
|
// could cause an arbitrarily large number of types to be cached
|
|
@@ -3969,6 +4105,7 @@ class TypeObject {
|
|
|
3969
4105
|
constructSignatures;
|
|
3970
4106
|
indexInfos;
|
|
3971
4107
|
baseTypes;
|
|
4108
|
+
types;
|
|
3972
4109
|
stringIndexType;
|
|
3973
4110
|
numberIndexType;
|
|
3974
4111
|
constructor(data, objectRegistry) {
|
|
@@ -4044,6 +4181,14 @@ class TypeObject {
|
|
|
4044
4181
|
this.baseType = data.baseType;
|
|
4045
4182
|
if (data.substConstraint !== undefined)
|
|
4046
4183
|
this.substConstraint = data.substConstraint;
|
|
4184
|
+
if (data.typeParameter !== undefined)
|
|
4185
|
+
this.typeParameter = data.typeParameter;
|
|
4186
|
+
if (data.constraintType !== undefined)
|
|
4187
|
+
this.constraintType = data.constraintType;
|
|
4188
|
+
if (data.nameType !== undefined)
|
|
4189
|
+
this.nameType = data.nameType;
|
|
4190
|
+
if (data.templateType !== undefined)
|
|
4191
|
+
this.templateType = data.templateType;
|
|
4047
4192
|
this.trueType = false;
|
|
4048
4193
|
this.falseType = false;
|
|
4049
4194
|
this.constraint = false;
|
|
@@ -4057,6 +4202,7 @@ class TypeObject {
|
|
|
4057
4202
|
this.constructSignatures = false;
|
|
4058
4203
|
this.indexInfos = false;
|
|
4059
4204
|
this.baseTypes = false;
|
|
4205
|
+
this.types = false;
|
|
4060
4206
|
this.stringIndexType = false;
|
|
4061
4207
|
this.numberIndexType = false;
|
|
4062
4208
|
}
|
|
@@ -4271,7 +4417,10 @@ class TypeObject {
|
|
|
4271
4417
|
if (!(owner.flags & (TypeFlags.UnionOrIntersection | TypeFlags.TemplateLiteral))) {
|
|
4272
4418
|
return undefined;
|
|
4273
4419
|
}
|
|
4274
|
-
|
|
4420
|
+
if (owner.types === false) {
|
|
4421
|
+
owner.types = owner.objectRegistry.fetchTypes(owner, "getTypesOfType");
|
|
4422
|
+
}
|
|
4423
|
+
return owner.types;
|
|
4275
4424
|
}, function* () {
|
|
4276
4425
|
// Only union, intersection, and template literal types have constituent
|
|
4277
4426
|
// types; any other kind has none, so return undefined rather than sending
|
|
@@ -4279,7 +4428,10 @@ class TypeObject {
|
|
|
4279
4428
|
if (!(owner.flags & (TypeFlags.UnionOrIntersection | TypeFlags.TemplateLiteral))) {
|
|
4280
4429
|
return undefined;
|
|
4281
4430
|
}
|
|
4282
|
-
|
|
4431
|
+
if (owner.types === false) {
|
|
4432
|
+
owner.types = yield* owner.objectRegistry.fetchTypes.gen(owner, "getTypesOfType");
|
|
4433
|
+
}
|
|
4434
|
+
return owner.types;
|
|
4283
4435
|
});
|
|
4284
4436
|
}
|
|
4285
4437
|
get getTypeParameters() {
|
|
@@ -4322,6 +4474,38 @@ class TypeObject {
|
|
|
4322
4474
|
return yield* owner.objectRegistry.fetchTypes.gen(owner, "getAliasTypeArgumentsOfType", owner.aliasTypeArguments);
|
|
4323
4475
|
});
|
|
4324
4476
|
}
|
|
4477
|
+
get getTypeParameter() {
|
|
4478
|
+
const owner = this;
|
|
4479
|
+
return cacheGeneratorMethod(owner, "getTypeParameter", function () {
|
|
4480
|
+
return owner.objectRegistry.fetchType(owner, "getTypeParameterOfMappedType", owner.typeParameter);
|
|
4481
|
+
}, function* () {
|
|
4482
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getTypeParameterOfMappedType", owner.typeParameter);
|
|
4483
|
+
});
|
|
4484
|
+
}
|
|
4485
|
+
get getConstraintType() {
|
|
4486
|
+
const owner = this;
|
|
4487
|
+
return cacheGeneratorMethod(owner, "getConstraintType", function () {
|
|
4488
|
+
return owner.objectRegistry.fetchType(owner, "getConstraintTypeOfMappedType", owner.constraintType);
|
|
4489
|
+
}, function* () {
|
|
4490
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getConstraintTypeOfMappedType", owner.constraintType);
|
|
4491
|
+
});
|
|
4492
|
+
}
|
|
4493
|
+
get getNameType() {
|
|
4494
|
+
const owner = this;
|
|
4495
|
+
return cacheGeneratorMethod(owner, "getNameType", function () {
|
|
4496
|
+
return owner.objectRegistry.fetchOptionalType(owner, "getNameTypeOfMappedType", owner.nameType);
|
|
4497
|
+
}, function* () {
|
|
4498
|
+
return yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getNameTypeOfMappedType", owner.nameType);
|
|
4499
|
+
});
|
|
4500
|
+
}
|
|
4501
|
+
get getTemplateType() {
|
|
4502
|
+
const owner = this;
|
|
4503
|
+
return cacheGeneratorMethod(owner, "getTemplateType", function () {
|
|
4504
|
+
return owner.objectRegistry.fetchType(owner, "getTemplateTypeOfMappedType", owner.templateType);
|
|
4505
|
+
}, function* () {
|
|
4506
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getTemplateTypeOfMappedType", owner.templateType);
|
|
4507
|
+
});
|
|
4508
|
+
}
|
|
4325
4509
|
get getObjectType() {
|
|
4326
4510
|
const owner = this;
|
|
4327
4511
|
return cacheGeneratorMethod(owner, "getObjectType", function () {
|
|
@@ -4507,6 +4691,9 @@ class TypeObject {
|
|
|
4507
4691
|
isTypeParameter() {
|
|
4508
4692
|
return isTypeParameter(this);
|
|
4509
4693
|
}
|
|
4694
|
+
isMappedType() {
|
|
4695
|
+
return !!(this.flags & TypeFlags.Object) && !!(this.objectFlags & ObjectFlags.Mapped);
|
|
4696
|
+
}
|
|
4510
4697
|
}
|
|
4511
4698
|
export function isUnionType(type) {
|
|
4512
4699
|
return (type.flags & TypeFlags.Union) !== 0;
|