typescript 7.1.0-dev.20260828.1 → 7.1.0-dev.20260829.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 +35 -17
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +82 -17
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/async/types.d.ts +12 -3
- package/dist/api/async/types.d.ts.map +1 -1
- package/dist/api/proto.d.ts.map +1 -1
- package/dist/api/proto.generated.d.ts +35 -9
- package/dist/api/proto.generated.d.ts.map +1 -1
- package/dist/api/proto.generated.js +12 -1
- package/dist/api/proto.generated.js.map +1 -1
- package/dist/api/proto.js +6 -0
- package/dist/api/proto.js.map +1 -1
- package/dist/api/sync/api.d.ts +47 -20
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +130 -28
- package/dist/api/sync/api.js.map +1 -1
- package/dist/api/sync/types.d.ts +18 -3
- package/dist/api/sync/types.d.ts.map +1 -1
- package/dist/enums/symbolFlags.enum.d.ts +1 -1
- package/dist/enums/symbolFlags.enum.d.ts.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/package.json +9 -9
package/dist/api/sync/api.js
CHANGED
|
@@ -4,7 +4,9 @@ import { CompletionItemKind } from "#enums/completionItemKind";
|
|
|
4
4
|
import { DiagnosticCategory } from "#enums/diagnosticCategory";
|
|
5
5
|
import { ElementFlags } from "#enums/elementFlags";
|
|
6
6
|
import { EmitOnly } from "#enums/emitOnly";
|
|
7
|
+
import { JsxEmit } from "#enums/jsxEmit";
|
|
7
8
|
import { ModuleKind } from "#enums/moduleKind";
|
|
9
|
+
import { ModuleResolutionKind } from "#enums/moduleResolutionKind";
|
|
8
10
|
import { NewLineKind } from "#enums/newLineKind";
|
|
9
11
|
import { NodeBuilderFlags } from "#enums/nodeBuilderFlags";
|
|
10
12
|
import { ObjectFlags } from "#enums/objectFlags";
|
|
@@ -25,7 +27,7 @@ import { SourceFileCache } from "../sourceFileCache.js";
|
|
|
25
27
|
import { Client, } from "./client.js";
|
|
26
28
|
export { formatDiagnostics, formatDiagnosticsWithColorAndContext } from "../diagnosticFormatter.js";
|
|
27
29
|
export { documentURIToFileName, fileNameToDocumentURI } from "../path.js";
|
|
28
|
-
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, ModifierFlags, ModuleKind, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
|
|
30
|
+
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, JsxEmit, ModifierFlags, ModuleKind, ModuleResolutionKind, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
|
|
29
31
|
export { all } from "./generatorSupport.js";
|
|
30
32
|
import { all, } from "./generatorSupport.js";
|
|
31
33
|
export class API {
|
|
@@ -158,12 +160,12 @@ export class API {
|
|
|
158
160
|
}
|
|
159
161
|
get transpileModuleFromFile() {
|
|
160
162
|
const owner = this;
|
|
161
|
-
return cacheGeneratorMethod(owner, "transpileModuleFromFile", function (
|
|
163
|
+
return cacheGeneratorMethod(owner, "transpileModuleFromFile", function (file, options = {}) {
|
|
162
164
|
owner.ensureInitialized();
|
|
163
|
-
return owner.client.apiRequest("transpileModuleFromFile", { fileName, options });
|
|
164
|
-
}, function* (
|
|
165
|
+
return owner.client.apiRequest("transpileModuleFromFile", { fileName: resolveFileName(file), options });
|
|
166
|
+
}, function* (file, options = {}) {
|
|
165
167
|
yield* owner.ensureInitialized.gen();
|
|
166
|
-
return yield* apiRequest("transpileModuleFromFile", { fileName, options });
|
|
168
|
+
return yield* apiRequest("transpileModuleFromFile", { fileName: resolveFileName(file), options });
|
|
167
169
|
});
|
|
168
170
|
}
|
|
169
171
|
get transpileDeclaration() {
|
|
@@ -178,12 +180,12 @@ export class API {
|
|
|
178
180
|
}
|
|
179
181
|
get transpileDeclarationFromFile() {
|
|
180
182
|
const owner = this;
|
|
181
|
-
return cacheGeneratorMethod(owner, "transpileDeclarationFromFile", function (
|
|
183
|
+
return cacheGeneratorMethod(owner, "transpileDeclarationFromFile", function (file, options = {}) {
|
|
182
184
|
owner.ensureInitialized();
|
|
183
|
-
return owner.client.apiRequest("transpileDeclarationFromFile", { fileName, options });
|
|
184
|
-
}, function* (
|
|
185
|
+
return owner.client.apiRequest("transpileDeclarationFromFile", { fileName: resolveFileName(file), options });
|
|
186
|
+
}, function* (file, options = {}) {
|
|
185
187
|
yield* owner.ensureInitialized.gen();
|
|
186
|
-
return yield* apiRequest("transpileDeclarationFromFile", { fileName, options });
|
|
188
|
+
return yield* apiRequest("transpileDeclarationFromFile", { fileName: resolveFileName(file), options });
|
|
187
189
|
});
|
|
188
190
|
}
|
|
189
191
|
get updateSnapshot() {
|
|
@@ -335,6 +337,72 @@ export class API {
|
|
|
335
337
|
return owner.client.resetTimingInfo();
|
|
336
338
|
});
|
|
337
339
|
}
|
|
340
|
+
isProgramActive(program) {
|
|
341
|
+
const project = program.getProject();
|
|
342
|
+
for (const snapshot of this.activeSnapshots) {
|
|
343
|
+
if (!snapshot.isDisposed() && snapshot.getProject(project.configFileName)?.program === program) {
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Creates a program from current filesystem state, or derives one from oldProgram after applying fileChanges.
|
|
351
|
+
*/
|
|
352
|
+
get createProgram() {
|
|
353
|
+
const owner = this;
|
|
354
|
+
return cacheGeneratorMethod(owner, "createProgram", function (rootFiles, createProgramOptions, oldProgram, fileChanges) {
|
|
355
|
+
owner.ensureInitialized();
|
|
356
|
+
if (fileChanges && !oldProgram) {
|
|
357
|
+
throw new Error("fileChanges requires an oldProgram");
|
|
358
|
+
}
|
|
359
|
+
if (oldProgram && !owner.isProgramActive(oldProgram)) {
|
|
360
|
+
throw new Error("oldProgram must belong to this API instance and reference an active snapshot");
|
|
361
|
+
}
|
|
362
|
+
const data = owner.client.apiRequest("createProgram", {
|
|
363
|
+
rootFiles,
|
|
364
|
+
createProgramOptions,
|
|
365
|
+
...(oldProgram ? { oldProgram: { snapshot: oldProgram.snapshotId, project: oldProgram.getProject().id } } : {}),
|
|
366
|
+
...(fileChanges ? { fileChanges } : {}),
|
|
367
|
+
});
|
|
368
|
+
if (!data.project) {
|
|
369
|
+
throw new Error("createProgram did not return a project");
|
|
370
|
+
}
|
|
371
|
+
const snapshot = new Snapshot({ snapshot: data.snapshot, projects: [data.project] }, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
372
|
+
owner.activeSnapshots.delete(snapshot);
|
|
373
|
+
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
374
|
+
});
|
|
375
|
+
const program = snapshot.getProjects()[0].program;
|
|
376
|
+
program.setOwnedSnapshot(snapshot);
|
|
377
|
+
owner.activeSnapshots.add(snapshot);
|
|
378
|
+
return program;
|
|
379
|
+
}, function* (rootFiles, createProgramOptions, oldProgram, fileChanges) {
|
|
380
|
+
yield* owner.ensureInitialized.gen();
|
|
381
|
+
if (fileChanges && !oldProgram) {
|
|
382
|
+
throw new Error("fileChanges requires an oldProgram");
|
|
383
|
+
}
|
|
384
|
+
if (oldProgram && !owner.isProgramActive(oldProgram)) {
|
|
385
|
+
throw new Error("oldProgram must belong to this API instance and reference an active snapshot");
|
|
386
|
+
}
|
|
387
|
+
const data = yield* apiRequest("createProgram", {
|
|
388
|
+
rootFiles,
|
|
389
|
+
createProgramOptions,
|
|
390
|
+
...(oldProgram ? { oldProgram: { snapshot: oldProgram.snapshotId, project: oldProgram.getProject().id } } : {}),
|
|
391
|
+
...(fileChanges ? { fileChanges } : {}),
|
|
392
|
+
});
|
|
393
|
+
if (!data.project) {
|
|
394
|
+
throw new Error("createProgram did not return a project");
|
|
395
|
+
}
|
|
396
|
+
const snapshot = new Snapshot({ snapshot: data.snapshot, projects: [data.project] }, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
397
|
+
owner.activeSnapshots.delete(snapshot);
|
|
398
|
+
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
399
|
+
});
|
|
400
|
+
const program = snapshot.getProjects()[0].program;
|
|
401
|
+
program.setOwnedSnapshot(snapshot);
|
|
402
|
+
owner.activeSnapshots.add(snapshot);
|
|
403
|
+
return program;
|
|
404
|
+
});
|
|
405
|
+
}
|
|
338
406
|
}
|
|
339
407
|
export class InternalAPI {
|
|
340
408
|
client;
|
|
@@ -1172,6 +1240,7 @@ export class LanguageService {
|
|
|
1172
1240
|
}
|
|
1173
1241
|
}
|
|
1174
1242
|
export class Program {
|
|
1243
|
+
/** @internal */
|
|
1175
1244
|
snapshotId;
|
|
1176
1245
|
project;
|
|
1177
1246
|
client;
|
|
@@ -1180,6 +1249,7 @@ export class Program {
|
|
|
1180
1249
|
formatDiagnosticsHost;
|
|
1181
1250
|
decoder = new Wtf8Decoder();
|
|
1182
1251
|
sourceFileMetadataCache = new Map();
|
|
1252
|
+
ownedSnapshot;
|
|
1183
1253
|
constructor(snapshotId, project, client, sourceFileCache, toPath, formatDiagnosticsHost) {
|
|
1184
1254
|
this.snapshotId = snapshotId;
|
|
1185
1255
|
this.project = project;
|
|
@@ -1197,6 +1267,27 @@ export class Program {
|
|
|
1197
1267
|
getNewLine() {
|
|
1198
1268
|
return this.project.compilerOptions.newLine === NewLineKind.CRLF ? "\r\n" : "\n";
|
|
1199
1269
|
}
|
|
1270
|
+
/** @internal */
|
|
1271
|
+
setOwnedSnapshot(snapshot) {
|
|
1272
|
+
this.ownedSnapshot = snapshot;
|
|
1273
|
+
}
|
|
1274
|
+
[globalThis.Symbol.dispose]() {
|
|
1275
|
+
this.dispose();
|
|
1276
|
+
}
|
|
1277
|
+
get dispose() {
|
|
1278
|
+
const owner = this;
|
|
1279
|
+
return cacheGeneratorMethod(owner, "dispose", function () {
|
|
1280
|
+
const snapshot = owner.ownedSnapshot;
|
|
1281
|
+
owner.ownedSnapshot = undefined;
|
|
1282
|
+
if (snapshot)
|
|
1283
|
+
snapshot.dispose();
|
|
1284
|
+
}, function* () {
|
|
1285
|
+
const snapshot = owner.ownedSnapshot;
|
|
1286
|
+
owner.ownedSnapshot = undefined;
|
|
1287
|
+
if (snapshot)
|
|
1288
|
+
yield* snapshot.dispose.gen();
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1200
1291
|
getCompilerOptions() {
|
|
1201
1292
|
return this.project.compilerOptions;
|
|
1202
1293
|
}
|
|
@@ -1273,10 +1364,10 @@ export class Program {
|
|
|
1273
1364
|
*/
|
|
1274
1365
|
get getSourceFileMetadata() {
|
|
1275
1366
|
const owner = this;
|
|
1276
|
-
return cacheGeneratorMethod(owner, "getSourceFileMetadata", function (
|
|
1277
|
-
return owner.getSourceFileMetadataByPath(owner.toPath(
|
|
1278
|
-
}, function* (
|
|
1279
|
-
return yield* owner.getSourceFileMetadataByPath.gen(owner.toPath(
|
|
1367
|
+
return cacheGeneratorMethod(owner, "getSourceFileMetadata", function (file) {
|
|
1368
|
+
return owner.getSourceFileMetadataByPath(owner.toPath(resolveFileName(file)));
|
|
1369
|
+
}, function* (file) {
|
|
1370
|
+
return yield* owner.getSourceFileMetadataByPath.gen(owner.toPath(resolveFileName(file)));
|
|
1280
1371
|
});
|
|
1281
1372
|
}
|
|
1282
1373
|
/**
|
|
@@ -1691,6 +1782,9 @@ export class Program {
|
|
|
1691
1782
|
return toEmitOutput(response);
|
|
1692
1783
|
});
|
|
1693
1784
|
}
|
|
1785
|
+
getProject() {
|
|
1786
|
+
return this.project;
|
|
1787
|
+
}
|
|
1694
1788
|
}
|
|
1695
1789
|
function toEmitOutput(response) {
|
|
1696
1790
|
const outputFiles = new Map();
|
|
@@ -2585,17 +2679,17 @@ export class Checker {
|
|
|
2585
2679
|
get isTupleType() {
|
|
2586
2680
|
const owner = this;
|
|
2587
2681
|
return cacheGeneratorMethod(owner, "isTupleType", function (type) {
|
|
2588
|
-
return
|
|
2589
|
-
snapshot: owner.snapshotId,
|
|
2590
|
-
project: owner.project.id,
|
|
2591
|
-
type: type.id,
|
|
2592
|
-
});
|
|
2682
|
+
return type.isTupleType();
|
|
2593
2683
|
}, function* (type) {
|
|
2594
|
-
return
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2684
|
+
return type.isTupleType();
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
get isTupleTypeTarget() {
|
|
2688
|
+
const owner = this;
|
|
2689
|
+
return cacheGeneratorMethod(owner, "isTupleTypeTarget", function (type) {
|
|
2690
|
+
return type.isTupleTypeTarget();
|
|
2691
|
+
}, function* (type) {
|
|
2692
|
+
return type.isTupleTypeTarget();
|
|
2599
2693
|
});
|
|
2600
2694
|
}
|
|
2601
2695
|
/**
|
|
@@ -3368,6 +3462,7 @@ class TypeObject {
|
|
|
3368
3462
|
freshType;
|
|
3369
3463
|
regularType;
|
|
3370
3464
|
target;
|
|
3465
|
+
tupleType;
|
|
3371
3466
|
typeParameters;
|
|
3372
3467
|
outerTypeParameters;
|
|
3373
3468
|
localTypeParameters;
|
|
@@ -3427,16 +3522,17 @@ class TypeObject {
|
|
|
3427
3522
|
this.regularType = data.regularType;
|
|
3428
3523
|
if (data.target !== undefined)
|
|
3429
3524
|
this.target = data.target;
|
|
3525
|
+
this.tupleType = data.isTupleType ?? false;
|
|
3430
3526
|
this.typeParameters = data.typeParameters ?? [];
|
|
3431
3527
|
this.outerTypeParameters = data.outerTypeParameters ?? [];
|
|
3432
3528
|
this.localTypeParameters = data.localTypeParameters ?? [];
|
|
3433
3529
|
this.aliasTypeArguments = data.aliasTypeArguments ?? [];
|
|
3434
3530
|
if (data.aliasSymbol !== undefined)
|
|
3435
3531
|
this.aliasSymbol = data.aliasSymbol;
|
|
3436
|
-
if (data.
|
|
3437
|
-
this.elementFlags = data.elementFlags;
|
|
3438
|
-
if (data.fixedLength !== undefined)
|
|
3532
|
+
if (data.fixedLength !== undefined) {
|
|
3533
|
+
this.elementFlags = data.elementFlags ?? [];
|
|
3439
3534
|
this.fixedLength = data.fixedLength;
|
|
3535
|
+
}
|
|
3440
3536
|
if (data.readonly !== undefined)
|
|
3441
3537
|
this.readonly = data.readonly;
|
|
3442
3538
|
if (data.texts !== undefined)
|
|
@@ -3882,7 +3978,10 @@ class TypeObject {
|
|
|
3882
3978
|
return isTypeReference(this);
|
|
3883
3979
|
}
|
|
3884
3980
|
isTupleType() {
|
|
3885
|
-
return
|
|
3981
|
+
return this.tupleType;
|
|
3982
|
+
}
|
|
3983
|
+
isTupleTypeTarget() {
|
|
3984
|
+
return this.fixedLength !== undefined;
|
|
3886
3985
|
}
|
|
3887
3986
|
isIndexType() {
|
|
3888
3987
|
return isIndexType(this);
|
|
@@ -3949,7 +4048,10 @@ export function isTypeReference(type) {
|
|
|
3949
4048
|
return isObjectType(type) && (type.objectFlags & ObjectFlags.Reference) !== 0;
|
|
3950
4049
|
}
|
|
3951
4050
|
export function isTupleType(type) {
|
|
3952
|
-
return
|
|
4051
|
+
return type.isTupleType();
|
|
4052
|
+
}
|
|
4053
|
+
export function isTupleTypeTarget(type) {
|
|
4054
|
+
return type.isTupleTypeTarget();
|
|
3953
4055
|
}
|
|
3954
4056
|
export function isIndexType(type) {
|
|
3955
4057
|
return (type.flags & TypeFlags.Index) !== 0;
|