@typescript/native-preview 7.0.0-dev.20260623.1 → 7.0.0-dev.20260626.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 +99 -10
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +386 -49
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/async/types.d.ts +48 -3
- package/dist/api/async/types.d.ts.map +1 -1
- package/dist/api/node/node.d.ts +8 -0
- package/dist/api/node/node.d.ts.map +1 -1
- package/dist/api/node/node.generated.d.ts +8 -0
- package/dist/api/node/node.generated.d.ts.map +1 -1
- package/dist/api/node/node.generated.js +26 -1
- package/dist/api/node/node.generated.js.map +1 -1
- package/dist/api/node/node.js +44 -6
- package/dist/api/node/node.js.map +1 -1
- package/dist/api/proto.d.ts +36 -1
- package/dist/api/proto.d.ts.map +1 -1
- package/dist/api/proto.js +15 -0
- package/dist/api/proto.js.map +1 -1
- package/dist/api/sync/api.d.ts +99 -10
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +386 -49
- package/dist/api/sync/api.js.map +1 -1
- package/dist/api/sync/types.d.ts +48 -3
- package/dist/api/sync/types.d.ts.map +1 -1
- package/dist/ast/ast.d.ts +8 -0
- package/dist/ast/ast.d.ts.map +1 -1
- package/dist/ast/factory.generated.d.ts +8 -0
- package/dist/ast/factory.generated.d.ts.map +1 -1
- package/dist/ast/factory.generated.js +36 -2
- package/dist/ast/factory.generated.js.map +1 -1
- package/dist/ast/is.generated.d.ts +2 -1
- package/dist/ast/is.generated.d.ts.map +1 -1
- package/dist/ast/is.generated.js +3 -0
- package/dist/ast/is.generated.js.map +1 -1
- package/dist/ast/utils.d.ts +2 -0
- package/dist/ast/utils.d.ts.map +1 -1
- package/dist/ast/utils.js +20 -0
- package/dist/ast/utils.js.map +1 -1
- package/lib/version.cjs +3 -0
- package/lib/version.d.cts +2 -0
- package/package.json +14 -12
- package/dist/api/objectRegistry.d.ts +0 -40
- package/dist/api/objectRegistry.d.ts.map +0 -1
- package/dist/api/objectRegistry.js +0 -61
- package/dist/api/objectRegistry.js.map +0 -1
package/dist/api/async/api.js
CHANGED
|
@@ -12,9 +12,8 @@ import { TypePredicateKind } from "#enums/typePredicateKind";
|
|
|
12
12
|
import { ModifierFlags, } from "../../ast/index.js";
|
|
13
13
|
import { encodeNode, uint8ArrayToBase64, } from "../node/encoder.js";
|
|
14
14
|
import { decodeNode, getNodeId, parseNodeHandle, readParseOptionsKey, readSourceFileHash, RemoteSourceFile, } from "../node/node.js";
|
|
15
|
-
import { ObjectRegistry, } from "../objectRegistry.js";
|
|
16
15
|
import { createGetCanonicalFileName, toPath, } from "../path.js";
|
|
17
|
-
import { resolveFileName } from "../proto.js";
|
|
16
|
+
import { resolveFileName, toUpdateSnapshotRequest, } from "../proto.js";
|
|
18
17
|
import { SourceFileCache } from "../sourceFileCache.js";
|
|
19
18
|
import { Client, } from "./client.js";
|
|
20
19
|
export { CompletionItemKind, DiagnosticCategory, ElementFlags, ModifierFlags, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypePredicateKind };
|
|
@@ -56,10 +55,7 @@ export class API {
|
|
|
56
55
|
}
|
|
57
56
|
async updateSnapshot(params) {
|
|
58
57
|
await this.ensureInitialized();
|
|
59
|
-
const requestParams = params
|
|
60
|
-
if (requestParams.openProject) {
|
|
61
|
-
requestParams.openProject = resolveFileName(requestParams.openProject);
|
|
62
|
-
}
|
|
58
|
+
const requestParams = toUpdateSnapshotRequest(params);
|
|
63
59
|
const data = await this.client.apiRequest("updateSnapshot", requestParams);
|
|
64
60
|
// Retain cached source files from previous snapshot for unchanged files
|
|
65
61
|
if (this.latestSnapshot) {
|
|
@@ -123,23 +119,18 @@ export class Snapshot {
|
|
|
123
119
|
projectMap;
|
|
124
120
|
toPath;
|
|
125
121
|
client;
|
|
126
|
-
objectRegistry;
|
|
127
122
|
disposed = false;
|
|
128
123
|
onDispose;
|
|
124
|
+
snapshotRegistry;
|
|
129
125
|
constructor(data, client, sourceFileCache, toPath, onDispose) {
|
|
130
126
|
this.id = data.snapshot;
|
|
131
127
|
this.client = client;
|
|
132
128
|
this.toPath = toPath;
|
|
133
129
|
this.onDispose = onDispose;
|
|
134
|
-
this.
|
|
135
|
-
createSymbol: symbolData => new Symbol(symbolData, this.objectRegistry),
|
|
136
|
-
createType: typeData => new TypeObject(typeData, this.objectRegistry),
|
|
137
|
-
createSignature: sigData => new Signature(sigData, this.objectRegistry),
|
|
138
|
-
}, client, this.id);
|
|
139
|
-
// Create projects
|
|
130
|
+
this.snapshotRegistry = new SnapshotObjectRegistry(client, this.id);
|
|
140
131
|
this.projectMap = new Map();
|
|
141
132
|
for (const projData of data.projects) {
|
|
142
|
-
const project = new Project(projData, this.id, client,
|
|
133
|
+
const project = new Project(projData, this.id, client, sourceFileCache, toPath, this.snapshotRegistry);
|
|
143
134
|
this.projectMap.set(toPath(projData.configFileName), project);
|
|
144
135
|
}
|
|
145
136
|
}
|
|
@@ -168,7 +159,11 @@ export class Snapshot {
|
|
|
168
159
|
if (this.disposed)
|
|
169
160
|
return;
|
|
170
161
|
this.disposed = true;
|
|
171
|
-
this.
|
|
162
|
+
for (const project of this.projectMap.values()) {
|
|
163
|
+
project.dispose();
|
|
164
|
+
}
|
|
165
|
+
this.projectMap.clear();
|
|
166
|
+
this.snapshotRegistry.clear();
|
|
172
167
|
this.onDispose();
|
|
173
168
|
await this.client.apiRequest("release", { snapshot: this.id });
|
|
174
169
|
}
|
|
@@ -181,41 +176,131 @@ export class Snapshot {
|
|
|
181
176
|
}
|
|
182
177
|
}
|
|
183
178
|
}
|
|
184
|
-
class SnapshotObjectRegistry
|
|
179
|
+
class SnapshotObjectRegistry {
|
|
180
|
+
symbols = new Map();
|
|
185
181
|
client;
|
|
186
182
|
snapshotId;
|
|
187
|
-
constructor(
|
|
188
|
-
super(factories);
|
|
183
|
+
constructor(client, snapshotId) {
|
|
189
184
|
this.client = client;
|
|
190
185
|
this.snapshotId = snapshotId;
|
|
191
186
|
}
|
|
192
|
-
|
|
187
|
+
getOrCreateSymbol(data) {
|
|
188
|
+
let symbol = this.symbols.get(data.id);
|
|
189
|
+
if (!symbol) {
|
|
190
|
+
symbol = new Symbol(data, this);
|
|
191
|
+
this.symbols.set(data.id, symbol);
|
|
192
|
+
}
|
|
193
|
+
return symbol;
|
|
194
|
+
}
|
|
195
|
+
getSymbol(id) {
|
|
196
|
+
return this.symbols.get(id);
|
|
197
|
+
}
|
|
198
|
+
clear() {
|
|
199
|
+
this.symbols.clear();
|
|
200
|
+
}
|
|
201
|
+
async fetchSymbol(source, method, handle, projectId) {
|
|
193
202
|
if (!handle)
|
|
194
203
|
return undefined;
|
|
195
|
-
const cached = this.
|
|
204
|
+
const cached = this.getSymbol(handle);
|
|
196
205
|
if (cached)
|
|
197
206
|
return cached;
|
|
198
207
|
const data = await this.client.apiRequest(method, {
|
|
199
208
|
snapshot: this.snapshotId,
|
|
209
|
+
project: projectId,
|
|
200
210
|
objectId: source.id,
|
|
201
211
|
});
|
|
202
212
|
if (!data)
|
|
203
|
-
throw new Error(`${method} returned null
|
|
204
|
-
return this.
|
|
213
|
+
throw new Error(`${method} returned null symbol for ${source.constructor.name} ${source.id}`);
|
|
214
|
+
return this.getOrCreateSymbol(data);
|
|
205
215
|
}
|
|
206
|
-
async
|
|
216
|
+
async fetchSymbols(source, method, handles, projectId) {
|
|
217
|
+
if (handles) {
|
|
218
|
+
const result = new Array(handles.length);
|
|
219
|
+
let allCached = true;
|
|
220
|
+
for (let i = 0; i < handles.length; i++) {
|
|
221
|
+
const cached = this.getSymbol(handles[i]);
|
|
222
|
+
if (!cached) {
|
|
223
|
+
allCached = false;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
result[i] = cached;
|
|
227
|
+
}
|
|
228
|
+
if (allCached)
|
|
229
|
+
return result;
|
|
230
|
+
}
|
|
231
|
+
const symbolData = await this.client.apiRequest(method, {
|
|
232
|
+
snapshot: this.snapshotId,
|
|
233
|
+
project: projectId,
|
|
234
|
+
objectId: source.id,
|
|
235
|
+
});
|
|
236
|
+
if (symbolData == null)
|
|
237
|
+
return [];
|
|
238
|
+
else
|
|
239
|
+
return symbolData.map(data => this.getOrCreateSymbol(data));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
class ProjectObjectRegistry {
|
|
243
|
+
client;
|
|
244
|
+
snapshotId;
|
|
245
|
+
projectId;
|
|
246
|
+
snapshotRegistry;
|
|
247
|
+
types = new Map();
|
|
248
|
+
signatures = new Map();
|
|
249
|
+
constructor(client, snapshotId, projectId, snapshotRegistry) {
|
|
250
|
+
this.client = client;
|
|
251
|
+
this.snapshotId = snapshotId;
|
|
252
|
+
this.projectId = projectId;
|
|
253
|
+
this.snapshotRegistry = snapshotRegistry;
|
|
254
|
+
}
|
|
255
|
+
getOrCreateSymbol(data) {
|
|
256
|
+
return this.snapshotRegistry.getOrCreateSymbol(data);
|
|
257
|
+
}
|
|
258
|
+
getSymbol(id) {
|
|
259
|
+
return this.snapshotRegistry.getSymbol(id);
|
|
260
|
+
}
|
|
261
|
+
getOrCreateType(data) {
|
|
262
|
+
let type = this.types.get(data.id);
|
|
263
|
+
if (!type) {
|
|
264
|
+
type = new TypeObject(data, this);
|
|
265
|
+
this.types.set(data.id, type);
|
|
266
|
+
}
|
|
267
|
+
return type;
|
|
268
|
+
}
|
|
269
|
+
getType(id) {
|
|
270
|
+
return this.types.get(id);
|
|
271
|
+
}
|
|
272
|
+
getOrCreateSignature(data) {
|
|
273
|
+
let sig = this.signatures.get(data.id);
|
|
274
|
+
if (!sig) {
|
|
275
|
+
sig = new Signature(data, this);
|
|
276
|
+
this.signatures.set(data.id, sig);
|
|
277
|
+
}
|
|
278
|
+
return sig;
|
|
279
|
+
}
|
|
280
|
+
getSignature(id) {
|
|
281
|
+
return this.signatures.get(id);
|
|
282
|
+
}
|
|
283
|
+
clear() {
|
|
284
|
+
this.types.clear();
|
|
285
|
+
this.signatures.clear();
|
|
286
|
+
}
|
|
287
|
+
async fetchType(source, method, handle) {
|
|
207
288
|
if (!handle)
|
|
208
289
|
return undefined;
|
|
209
|
-
const cached = this.
|
|
290
|
+
const cached = this.getType(handle);
|
|
210
291
|
if (cached)
|
|
211
292
|
return cached;
|
|
212
293
|
const data = await this.client.apiRequest(method, {
|
|
213
294
|
snapshot: this.snapshotId,
|
|
295
|
+
project: this.projectId,
|
|
214
296
|
objectId: source.id,
|
|
215
297
|
});
|
|
216
298
|
if (!data)
|
|
217
|
-
throw new Error(`${method} returned null
|
|
218
|
-
return this.
|
|
299
|
+
throw new Error(`${method} returned null type for ${source.constructor.name} ${source.id}`);
|
|
300
|
+
return this.getOrCreateType(data);
|
|
301
|
+
}
|
|
302
|
+
async fetchSymbol(source, method, handle) {
|
|
303
|
+
return this.snapshotRegistry.fetchSymbol(source, method, handle, this.projectId);
|
|
219
304
|
}
|
|
220
305
|
async fetchSignature(source, method, handle) {
|
|
221
306
|
if (!handle)
|
|
@@ -225,6 +310,7 @@ class SnapshotObjectRegistry extends ObjectRegistry {
|
|
|
225
310
|
return cached;
|
|
226
311
|
const data = await this.client.apiRequest(method, {
|
|
227
312
|
snapshot: this.snapshotId,
|
|
313
|
+
project: this.projectId,
|
|
228
314
|
objectId: source.id,
|
|
229
315
|
});
|
|
230
316
|
if (!data)
|
|
@@ -248,6 +334,7 @@ class SnapshotObjectRegistry extends ObjectRegistry {
|
|
|
248
334
|
}
|
|
249
335
|
const typesData = await this.client.apiRequest(method, {
|
|
250
336
|
snapshot: this.snapshotId,
|
|
337
|
+
project: this.projectId,
|
|
251
338
|
objectId: source.id,
|
|
252
339
|
});
|
|
253
340
|
if (typesData == null)
|
|
@@ -256,28 +343,7 @@ class SnapshotObjectRegistry extends ObjectRegistry {
|
|
|
256
343
|
return typesData.map(data => this.getOrCreateType(data));
|
|
257
344
|
}
|
|
258
345
|
async fetchSymbols(source, method, handles) {
|
|
259
|
-
|
|
260
|
-
const result = new Array(handles.length);
|
|
261
|
-
let allCached = true;
|
|
262
|
-
for (let i = 0; i < handles.length; i++) {
|
|
263
|
-
const cached = this.getSymbol(handles[i]);
|
|
264
|
-
if (!cached) {
|
|
265
|
-
allCached = false;
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
result[i] = cached;
|
|
269
|
-
}
|
|
270
|
-
if (allCached)
|
|
271
|
-
return result;
|
|
272
|
-
}
|
|
273
|
-
const symbolData = await this.client.apiRequest(method, {
|
|
274
|
-
snapshot: this.snapshotId,
|
|
275
|
-
objectId: source.id,
|
|
276
|
-
});
|
|
277
|
-
if (symbolData == null)
|
|
278
|
-
return [];
|
|
279
|
-
else
|
|
280
|
-
return symbolData.map(data => this.getOrCreateSymbol(data));
|
|
346
|
+
return this.snapshotRegistry.fetchSymbols(source, method, handles, this.projectId);
|
|
281
347
|
}
|
|
282
348
|
}
|
|
283
349
|
export class Project {
|
|
@@ -289,16 +355,20 @@ export class Project {
|
|
|
289
355
|
checker;
|
|
290
356
|
emitter;
|
|
291
357
|
client;
|
|
292
|
-
constructor(data, snapshotId, client,
|
|
358
|
+
constructor(data, snapshotId, client, sourceFileCache, toPath, snapshotRegistry) {
|
|
293
359
|
this.id = data.id;
|
|
294
360
|
this.configFileName = data.configFileName;
|
|
295
361
|
this.compilerOptions = data.compilerOptions;
|
|
296
362
|
this.rootFiles = data.rootFiles;
|
|
297
363
|
this.client = client;
|
|
298
364
|
this.program = new Program(snapshotId, this.id, client, sourceFileCache, toPath);
|
|
365
|
+
const objectRegistry = new ProjectObjectRegistry(client, snapshotId, this.id, snapshotRegistry);
|
|
299
366
|
this.checker = new Checker(snapshotId, this.id, client, objectRegistry);
|
|
300
367
|
this.emitter = new Emitter(client);
|
|
301
368
|
}
|
|
369
|
+
dispose() {
|
|
370
|
+
this.checker.dispose();
|
|
371
|
+
}
|
|
302
372
|
}
|
|
303
373
|
export class Program {
|
|
304
374
|
snapshotId;
|
|
@@ -338,6 +408,13 @@ export class Program {
|
|
|
338
408
|
const sourceFile = new RemoteSourceFile(binaryData, this.decoder);
|
|
339
409
|
return this.sourceFileCache.set(path, sourceFile, parseOptionsKey, contentHash, this.snapshotId, this.projectId);
|
|
340
410
|
}
|
|
411
|
+
async getSourceFileNames() {
|
|
412
|
+
const data = await this.client.apiRequest("getSourceFileNames", {
|
|
413
|
+
snapshot: this.snapshotId,
|
|
414
|
+
project: this.projectId,
|
|
415
|
+
});
|
|
416
|
+
return data ?? [];
|
|
417
|
+
}
|
|
341
418
|
/**
|
|
342
419
|
* Get syntactic (parse) diagnostics for a specific file or all files.
|
|
343
420
|
* @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
@@ -350,6 +427,18 @@ export class Program {
|
|
|
350
427
|
});
|
|
351
428
|
return data ?? [];
|
|
352
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Get binder diagnostics for a specific file or all files.
|
|
432
|
+
* @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
433
|
+
*/
|
|
434
|
+
async getBindDiagnostics(file) {
|
|
435
|
+
const data = await this.client.apiRequest("getBindDiagnostics", {
|
|
436
|
+
snapshot: this.snapshotId,
|
|
437
|
+
project: this.projectId,
|
|
438
|
+
...(file !== undefined ? { file } : {}),
|
|
439
|
+
});
|
|
440
|
+
return data ?? [];
|
|
441
|
+
}
|
|
353
442
|
/**
|
|
354
443
|
* Get semantic (type-check) diagnostics for a specific file or all files.
|
|
355
444
|
* @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
@@ -386,6 +475,26 @@ export class Program {
|
|
|
386
475
|
});
|
|
387
476
|
return data ?? [];
|
|
388
477
|
}
|
|
478
|
+
/**
|
|
479
|
+
* Get program-wide diagnostics for the project, including compiler options diagnostics.
|
|
480
|
+
*/
|
|
481
|
+
async getProgramDiagnostics() {
|
|
482
|
+
const data = await this.client.apiRequest("getProgramDiagnostics", {
|
|
483
|
+
snapshot: this.snapshotId,
|
|
484
|
+
project: this.projectId,
|
|
485
|
+
});
|
|
486
|
+
return data ?? [];
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Get global (non-file-specific) semantic diagnostics for the project.
|
|
490
|
+
*/
|
|
491
|
+
async getGlobalDiagnostics() {
|
|
492
|
+
const data = await this.client.apiRequest("getGlobalDiagnostics", {
|
|
493
|
+
snapshot: this.snapshotId,
|
|
494
|
+
project: this.projectId,
|
|
495
|
+
});
|
|
496
|
+
return data ?? [];
|
|
497
|
+
}
|
|
389
498
|
/**
|
|
390
499
|
* Get config file parsing diagnostics for the project.
|
|
391
500
|
*/
|
|
@@ -408,6 +517,9 @@ export class Checker {
|
|
|
408
517
|
this.client = client;
|
|
409
518
|
this.objectRegistry = objectRegistry;
|
|
410
519
|
}
|
|
520
|
+
dispose() {
|
|
521
|
+
this.objectRegistry.clear();
|
|
522
|
+
}
|
|
411
523
|
async getSymbolAtLocation(nodeOrNodes) {
|
|
412
524
|
if (Array.isArray(nodeOrNodes)) {
|
|
413
525
|
const data = await this.client.apiRequest("getSymbolsAtLocations", {
|
|
@@ -752,6 +864,20 @@ export class Checker {
|
|
|
752
864
|
location: getNodeId(node),
|
|
753
865
|
});
|
|
754
866
|
}
|
|
867
|
+
async isArrayType(type) {
|
|
868
|
+
return this.client.apiRequest("isArrayType", {
|
|
869
|
+
snapshot: this.snapshotId,
|
|
870
|
+
project: this.projectId,
|
|
871
|
+
type: type.id,
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
async isTupleType(type) {
|
|
875
|
+
return this.client.apiRequest("isTupleType", {
|
|
876
|
+
snapshot: this.snapshotId,
|
|
877
|
+
project: this.projectId,
|
|
878
|
+
type: type.id,
|
|
879
|
+
});
|
|
880
|
+
}
|
|
755
881
|
async getReturnTypeOfSignature(signature) {
|
|
756
882
|
const data = await this.client.apiRequest("getReturnTypeOfSignature", {
|
|
757
883
|
snapshot: this.snapshotId,
|
|
@@ -791,6 +917,14 @@ export class Checker {
|
|
|
791
917
|
});
|
|
792
918
|
return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
|
|
793
919
|
}
|
|
920
|
+
async getApparentType(type) {
|
|
921
|
+
const data = await this.client.apiRequest("getApparentType", {
|
|
922
|
+
snapshot: this.snapshotId,
|
|
923
|
+
project: this.projectId,
|
|
924
|
+
type: type.id,
|
|
925
|
+
});
|
|
926
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
927
|
+
}
|
|
794
928
|
async getPropertiesOfType(type) {
|
|
795
929
|
const data = await this.client.apiRequest("getPropertiesOfType", {
|
|
796
930
|
snapshot: this.snapshotId,
|
|
@@ -822,6 +956,95 @@ export class Checker {
|
|
|
822
956
|
});
|
|
823
957
|
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
824
958
|
}
|
|
959
|
+
async getBaseConstraintOfType(type) {
|
|
960
|
+
const data = await this.client.apiRequest("getBaseConstraintOfType", {
|
|
961
|
+
snapshot: this.snapshotId,
|
|
962
|
+
project: this.projectId,
|
|
963
|
+
type: type.id,
|
|
964
|
+
});
|
|
965
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
966
|
+
}
|
|
967
|
+
async getPropertyOfType(type, name) {
|
|
968
|
+
const data = await this.client.apiRequest("getPropertyOfType", {
|
|
969
|
+
snapshot: this.snapshotId,
|
|
970
|
+
project: this.projectId,
|
|
971
|
+
type: type.id,
|
|
972
|
+
name,
|
|
973
|
+
});
|
|
974
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
975
|
+
}
|
|
976
|
+
async getConstantValue(node) {
|
|
977
|
+
const data = await this.client.apiRequest("getConstantValue", {
|
|
978
|
+
snapshot: this.snapshotId,
|
|
979
|
+
project: this.projectId,
|
|
980
|
+
location: getNodeId(node),
|
|
981
|
+
});
|
|
982
|
+
return data ?? undefined;
|
|
983
|
+
}
|
|
984
|
+
async getSignatureFromDeclaration(node) {
|
|
985
|
+
const data = await this.client.apiRequest("getSignatureFromDeclaration", {
|
|
986
|
+
snapshot: this.snapshotId,
|
|
987
|
+
project: this.projectId,
|
|
988
|
+
location: getNodeId(node),
|
|
989
|
+
});
|
|
990
|
+
return data ? this.objectRegistry.getOrCreateSignature(data) : undefined;
|
|
991
|
+
}
|
|
992
|
+
async getExportSpecifierLocalTargetSymbol(node) {
|
|
993
|
+
const data = await this.client.apiRequest("getExportSpecifierLocalTargetSymbol", {
|
|
994
|
+
snapshot: this.snapshotId,
|
|
995
|
+
project: this.projectId,
|
|
996
|
+
location: getNodeId(node),
|
|
997
|
+
});
|
|
998
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
999
|
+
}
|
|
1000
|
+
async getAliasedSymbol(symbol) {
|
|
1001
|
+
const data = await this.client.apiRequest("getAliasedSymbol", {
|
|
1002
|
+
snapshot: this.snapshotId,
|
|
1003
|
+
project: this.projectId,
|
|
1004
|
+
symbol: symbol.id,
|
|
1005
|
+
});
|
|
1006
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1007
|
+
}
|
|
1008
|
+
async getImmediateAliasedSymbol(symbol) {
|
|
1009
|
+
const data = await this.client.apiRequest("getImmediateAliasedSymbol", {
|
|
1010
|
+
snapshot: this.snapshotId,
|
|
1011
|
+
project: this.projectId,
|
|
1012
|
+
symbol: symbol.id,
|
|
1013
|
+
});
|
|
1014
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1015
|
+
}
|
|
1016
|
+
async getExportsOfModule(symbol) {
|
|
1017
|
+
const data = await this.client.apiRequest("getExportsOfModule", {
|
|
1018
|
+
snapshot: this.snapshotId,
|
|
1019
|
+
project: this.projectId,
|
|
1020
|
+
symbol: symbol.id,
|
|
1021
|
+
});
|
|
1022
|
+
return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
1023
|
+
}
|
|
1024
|
+
async getMemberInModuleExports(symbol, name) {
|
|
1025
|
+
const data = await this.client.apiRequest("getMemberInModuleExports", {
|
|
1026
|
+
snapshot: this.snapshotId,
|
|
1027
|
+
project: this.projectId,
|
|
1028
|
+
symbol: symbol.id,
|
|
1029
|
+
name,
|
|
1030
|
+
});
|
|
1031
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1032
|
+
}
|
|
1033
|
+
async getJsDocTagsOfSymbol(symbol) {
|
|
1034
|
+
const data = await this.client.apiRequest("getJsDocTags", {
|
|
1035
|
+
snapshot: this.snapshotId,
|
|
1036
|
+
project: this.projectId,
|
|
1037
|
+
symbol: symbol.id,
|
|
1038
|
+
});
|
|
1039
|
+
return data ?? [];
|
|
1040
|
+
}
|
|
1041
|
+
async getDocumentationCommentOfSymbol(symbol) {
|
|
1042
|
+
return this.client.apiRequest("getDocumentationComment", {
|
|
1043
|
+
snapshot: this.snapshotId,
|
|
1044
|
+
project: this.projectId,
|
|
1045
|
+
symbol: symbol.id,
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
825
1048
|
async getTypeArguments(type) {
|
|
826
1049
|
const data = await this.client.apiRequest("getTypeArguments", {
|
|
827
1050
|
snapshot: this.snapshotId,
|
|
@@ -904,6 +1127,12 @@ export class Symbol {
|
|
|
904
1127
|
return this;
|
|
905
1128
|
return this.objectRegistry.fetchSymbol(this, "getExportSymbolOfSymbol", this.exportSymbol);
|
|
906
1129
|
}
|
|
1130
|
+
async getJsDocTags(checker) {
|
|
1131
|
+
return checker.getJsDocTagsOfSymbol(this);
|
|
1132
|
+
}
|
|
1133
|
+
async getDocumentationComment(checker) {
|
|
1134
|
+
return checker.getDocumentationCommentOfSymbol(this);
|
|
1135
|
+
}
|
|
907
1136
|
}
|
|
908
1137
|
class TypeObject {
|
|
909
1138
|
objectRegistry;
|
|
@@ -1030,6 +1259,114 @@ class TypeObject {
|
|
|
1030
1259
|
async getConstraint() {
|
|
1031
1260
|
return this.objectRegistry.fetchType(this, "getConstraintOfType", this.substConstraint);
|
|
1032
1261
|
}
|
|
1262
|
+
isUnionType() {
|
|
1263
|
+
return isUnionType(this);
|
|
1264
|
+
}
|
|
1265
|
+
isIntersectionType() {
|
|
1266
|
+
return isIntersectionType(this);
|
|
1267
|
+
}
|
|
1268
|
+
isObjectType() {
|
|
1269
|
+
return isObjectType(this);
|
|
1270
|
+
}
|
|
1271
|
+
isIntrinsicType() {
|
|
1272
|
+
return isIntrinsicType(this);
|
|
1273
|
+
}
|
|
1274
|
+
isLiteralType() {
|
|
1275
|
+
return isLiteralType(this);
|
|
1276
|
+
}
|
|
1277
|
+
isStringLiteralType() {
|
|
1278
|
+
return isStringLiteralType(this);
|
|
1279
|
+
}
|
|
1280
|
+
isNumberLiteralType() {
|
|
1281
|
+
return isNumberLiteralType(this);
|
|
1282
|
+
}
|
|
1283
|
+
isBigIntLiteralType() {
|
|
1284
|
+
return isBigIntLiteralType(this);
|
|
1285
|
+
}
|
|
1286
|
+
isBooleanLiteralType() {
|
|
1287
|
+
return isBooleanLiteralType(this);
|
|
1288
|
+
}
|
|
1289
|
+
isTypeReference() {
|
|
1290
|
+
return isTypeReference(this);
|
|
1291
|
+
}
|
|
1292
|
+
isTupleType() {
|
|
1293
|
+
return isTupleType(this);
|
|
1294
|
+
}
|
|
1295
|
+
isIndexType() {
|
|
1296
|
+
return isIndexType(this);
|
|
1297
|
+
}
|
|
1298
|
+
isIndexedAccessType() {
|
|
1299
|
+
return isIndexedAccessType(this);
|
|
1300
|
+
}
|
|
1301
|
+
isConditionalType() {
|
|
1302
|
+
return isConditionalType(this);
|
|
1303
|
+
}
|
|
1304
|
+
isSubstitutionType() {
|
|
1305
|
+
return isSubstitutionType(this);
|
|
1306
|
+
}
|
|
1307
|
+
isTemplateLiteralType() {
|
|
1308
|
+
return isTemplateLiteralType(this);
|
|
1309
|
+
}
|
|
1310
|
+
isStringMappingType() {
|
|
1311
|
+
return isStringMappingType(this);
|
|
1312
|
+
}
|
|
1313
|
+
isTypeParameter() {
|
|
1314
|
+
return isTypeParameter(this);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
export function isUnionType(type) {
|
|
1318
|
+
return (type.flags & TypeFlags.Union) !== 0;
|
|
1319
|
+
}
|
|
1320
|
+
export function isIntersectionType(type) {
|
|
1321
|
+
return (type.flags & TypeFlags.Intersection) !== 0;
|
|
1322
|
+
}
|
|
1323
|
+
export function isObjectType(type) {
|
|
1324
|
+
return (type.flags & TypeFlags.Object) !== 0;
|
|
1325
|
+
}
|
|
1326
|
+
export function isIntrinsicType(type) {
|
|
1327
|
+
return (type.flags & TypeFlags.Intrinsic) !== 0;
|
|
1328
|
+
}
|
|
1329
|
+
export function isLiteralType(type) {
|
|
1330
|
+
return (type.flags & TypeFlags.Literal) !== 0;
|
|
1331
|
+
}
|
|
1332
|
+
export function isStringLiteralType(type) {
|
|
1333
|
+
return (type.flags & TypeFlags.StringLiteral) !== 0;
|
|
1334
|
+
}
|
|
1335
|
+
export function isNumberLiteralType(type) {
|
|
1336
|
+
return (type.flags & TypeFlags.NumberLiteral) !== 0;
|
|
1337
|
+
}
|
|
1338
|
+
export function isBigIntLiteralType(type) {
|
|
1339
|
+
return (type.flags & TypeFlags.BigIntLiteral) !== 0;
|
|
1340
|
+
}
|
|
1341
|
+
export function isBooleanLiteralType(type) {
|
|
1342
|
+
return (type.flags & TypeFlags.BooleanLiteral) !== 0;
|
|
1343
|
+
}
|
|
1344
|
+
export function isTypeReference(type) {
|
|
1345
|
+
return isObjectType(type) && (type.objectFlags & ObjectFlags.Reference) !== 0;
|
|
1346
|
+
}
|
|
1347
|
+
export function isTupleType(type) {
|
|
1348
|
+
return isObjectType(type) && (type.objectFlags & ObjectFlags.Tuple) !== 0;
|
|
1349
|
+
}
|
|
1350
|
+
export function isIndexType(type) {
|
|
1351
|
+
return (type.flags & TypeFlags.Index) !== 0;
|
|
1352
|
+
}
|
|
1353
|
+
export function isIndexedAccessType(type) {
|
|
1354
|
+
return (type.flags & TypeFlags.IndexedAccess) !== 0;
|
|
1355
|
+
}
|
|
1356
|
+
export function isConditionalType(type) {
|
|
1357
|
+
return (type.flags & TypeFlags.Conditional) !== 0;
|
|
1358
|
+
}
|
|
1359
|
+
export function isSubstitutionType(type) {
|
|
1360
|
+
return (type.flags & TypeFlags.Substitution) !== 0;
|
|
1361
|
+
}
|
|
1362
|
+
export function isTemplateLiteralType(type) {
|
|
1363
|
+
return (type.flags & TypeFlags.TemplateLiteral) !== 0;
|
|
1364
|
+
}
|
|
1365
|
+
export function isStringMappingType(type) {
|
|
1366
|
+
return (type.flags & TypeFlags.StringMapping) !== 0;
|
|
1367
|
+
}
|
|
1368
|
+
export function isTypeParameter(type) {
|
|
1369
|
+
return (type.flags & TypeFlags.TypeParameter) !== 0;
|
|
1033
1370
|
}
|
|
1034
1371
|
export class Signature {
|
|
1035
1372
|
flags;
|