typescript 7.1.0-dev.20260923.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 +54 -4
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +120 -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/proto.generated.d.ts +43 -3
- package/dist/api/proto.generated.d.ts.map +1 -1
- package/dist/api/sync/api.d.ts +65 -4
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +183 -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/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/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() {
|
|
@@ -3973,6 +4105,7 @@ class TypeObject {
|
|
|
3973
4105
|
constructSignatures;
|
|
3974
4106
|
indexInfos;
|
|
3975
4107
|
baseTypes;
|
|
4108
|
+
types;
|
|
3976
4109
|
stringIndexType;
|
|
3977
4110
|
numberIndexType;
|
|
3978
4111
|
constructor(data, objectRegistry) {
|
|
@@ -4069,6 +4202,7 @@ class TypeObject {
|
|
|
4069
4202
|
this.constructSignatures = false;
|
|
4070
4203
|
this.indexInfos = false;
|
|
4071
4204
|
this.baseTypes = false;
|
|
4205
|
+
this.types = false;
|
|
4072
4206
|
this.stringIndexType = false;
|
|
4073
4207
|
this.numberIndexType = false;
|
|
4074
4208
|
}
|
|
@@ -4283,7 +4417,10 @@ class TypeObject {
|
|
|
4283
4417
|
if (!(owner.flags & (TypeFlags.UnionOrIntersection | TypeFlags.TemplateLiteral))) {
|
|
4284
4418
|
return undefined;
|
|
4285
4419
|
}
|
|
4286
|
-
|
|
4420
|
+
if (owner.types === false) {
|
|
4421
|
+
owner.types = owner.objectRegistry.fetchTypes(owner, "getTypesOfType");
|
|
4422
|
+
}
|
|
4423
|
+
return owner.types;
|
|
4287
4424
|
}, function* () {
|
|
4288
4425
|
// Only union, intersection, and template literal types have constituent
|
|
4289
4426
|
// types; any other kind has none, so return undefined rather than sending
|
|
@@ -4291,7 +4428,10 @@ class TypeObject {
|
|
|
4291
4428
|
if (!(owner.flags & (TypeFlags.UnionOrIntersection | TypeFlags.TemplateLiteral))) {
|
|
4292
4429
|
return undefined;
|
|
4293
4430
|
}
|
|
4294
|
-
|
|
4431
|
+
if (owner.types === false) {
|
|
4432
|
+
owner.types = yield* owner.objectRegistry.fetchTypes.gen(owner, "getTypesOfType");
|
|
4433
|
+
}
|
|
4434
|
+
return owner.types;
|
|
4295
4435
|
});
|
|
4296
4436
|
}
|
|
4297
4437
|
get getTypeParameters() {
|