typescript 7.1.0-dev.20260916.1 → 7.1.0-dev.20260918.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.
@@ -10,6 +10,7 @@ import { ModuleResolutionKind } from "#enums/moduleResolutionKind";
10
10
  import { NewLineKind } from "#enums/newLineKind";
11
11
  import { NodeBuilderFlags } from "#enums/nodeBuilderFlags";
12
12
  import { ObjectFlags } from "#enums/objectFlags";
13
+ import { ScriptKind } from "#enums/scriptKind";
13
14
  import { SignatureFlags } from "#enums/signatureFlags";
14
15
  import { SignatureKind } from "#enums/signatureKind";
15
16
  import { SymbolFlags } from "#enums/symbolFlags";
@@ -22,30 +23,33 @@ import { encodeNode, uint8ArrayToBase64, } from "../node/encoder.js";
22
23
  import { decodeNode, getNodeId, parseNodeHandle, readParseOptionsKey, readSourceFileHash, RemoteSourceFile, } from "../node/node.js";
23
24
  import { Wtf8Decoder } from "../node/wtf8.js";
24
25
  import { createGetCanonicalFileName, toPath, } from "../path.js";
25
- import { resolveFileName, toUpdateSnapshotRequest, } from "../proto.js";
26
+ import { resolveFileName, toCreateSnapshotRequest, } from "../proto.js";
26
27
  import { SourceFileCache } from "../sourceFileCache.js";
27
28
  import { Client, } from "./client.js";
28
29
  export { formatDiagnostics, formatDiagnosticsWithColorAndContext } from "../diagnosticFormatter.js";
29
30
  export { documentURIToFileName, fileNameToDocumentURI } from "../path.js";
30
- export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, IndexKind, JsxEmit, ModifierFlags, ModuleKind, ModuleResolutionKind, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
31
+ export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, IndexKind, JsxEmit, ModifierFlags, ModuleKind, ModuleResolutionKind, NodeBuilderFlags, ObjectFlags, ScriptKind, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
31
32
  // @sync-only-start
32
33
  // export { all, defer, type APIRequestGenerator, type AnyAPIRequestGenerator, type AllAPIRequestGenerator, type DeferredAPIRequestGenerator, type ExecutedGeneratorsResults } from "./generatorSupport.ts";
33
34
  // import {executeRequestGenerators, type ExecutedGeneratorsResults, type AnyAPIRequestGenerator} from "./generatorSupport.ts";
35
+ // import { sourceFileResponseToUint8Array } from "../node/encoder.ts";
34
36
  // @sync-only-end
35
37
  export class API {
36
38
  client;
37
39
  sourceFileCache;
38
40
  toPath;
39
41
  currentDirectory;
42
+ decoder = new Wtf8Decoder();
40
43
  getCanonicalFileNameWorker;
41
44
  initialized = false;
42
45
  initializing;
43
46
  activeSnapshots = new Set();
44
- latestSnapshot;
47
+ printer;
45
48
  internal;
46
49
  constructor(options = {}) {
47
50
  this.client = new Client(options);
48
51
  this.sourceFileCache = new SourceFileCache();
52
+ this.printer = new Printer(this.client);
49
53
  this.internal = new InternalAPI(this.client, () => this.ensureInitialized()); // @sync: this.internal = new InternalAPI(this.client, this.ensureInitialized);
50
54
  }
51
55
  /**
@@ -118,6 +122,22 @@ export class API {
118
122
  await this.ensureInitialized();
119
123
  return this.client.apiRequest("parseJsonConfigFileContent", { json, ...options });
120
124
  }
125
+ async createSourceFile(fileName, sourceText, options = {}) {
126
+ await this.ensureInitialized();
127
+ const data = await this.client.apiRequestBinary("createSourceFile", { fileName, sourceText, options });
128
+ if (!data) {
129
+ throw new Error("createSourceFile returned no source file");
130
+ }
131
+ return new RemoteSourceFile(data, this.decoder, this.client.getTimingCollector());
132
+ }
133
+ async createSourceFileFromFile(file, options = {}) {
134
+ await this.ensureInitialized();
135
+ const data = await this.client.apiRequestBinary("createSourceFileFromFile", { fileName: resolveFileName(file), options });
136
+ if (!data) {
137
+ throw new Error("createSourceFileFromFile returned no source file");
138
+ }
139
+ return new RemoteSourceFile(data, this.decoder, this.client.getTimingCollector());
140
+ }
121
141
  async transpileModule(input, options = {}) {
122
142
  await this.ensureInitialized();
123
143
  return this.client.apiRequest("transpileModule", { input, options });
@@ -134,39 +154,60 @@ export class API {
134
154
  await this.ensureInitialized();
135
155
  return this.client.apiRequest("transpileDeclarationFromFile", { fileName: resolveFileName(file), options });
136
156
  }
137
- async updateSnapshot(params) {
138
- return this.updateSnapshotWorker(params);
157
+ async createSnapshot(params) {
158
+ await this.ensureInitialized();
159
+ const requestParams = toCreateSnapshotRequest(params);
160
+ const data = await this.client.apiRequest("createSnapshot", requestParams);
161
+ const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
162
+ this.activeSnapshots.delete(snapshot);
163
+ this.sourceFileCache.releaseSnapshot(snapshot.id);
164
+ }, this.createSnapshotUpdater(() => snapshot), undefined);
165
+ this.activeSnapshots.add(snapshot);
166
+ return snapshot;
139
167
  }
140
- /** @internal */
141
- async updateSnapshotFrom(baseSnapshot, params) {
168
+ async updateSnapshot(baseSnapshot, params) {
169
+ await this.ensureInitialized();
142
170
  if (!this.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed()) {
143
171
  throw new Error("Cannot update an inactive snapshot");
144
172
  }
145
- if (baseSnapshot !== this.latestSnapshot) {
146
- // TODO: Support forking active memory/cache snapshots once the server-side
147
- // ownership, project state, and cache semantics have been worked out.
148
- throw new Error("Snapshot.update can only update the latest snapshot");
149
- }
150
- return this.updateSnapshotWorker(params, baseSnapshot);
173
+ const data = await this.client.apiRequest("updateSnapshot", {
174
+ snapshot: baseSnapshot.id,
175
+ changes: toCreateSnapshotRequest(params),
176
+ });
177
+ this.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
178
+ const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
179
+ this.activeSnapshots.delete(snapshot);
180
+ this.sourceFileCache.releaseSnapshot(snapshot.id);
181
+ }, this.createSnapshotUpdater(() => snapshot), baseSnapshot);
182
+ this.activeSnapshots.add(snapshot);
183
+ return snapshot;
151
184
  }
152
- async updateSnapshotWorker(params, baseSnapshot) {
185
+ createSnapshotUpdater(getSnapshot) {
186
+ const update = params => this.updateSnapshot(getSnapshot(), params); // @sync: const update = ((params: CreateSnapshotParams) => this.updateSnapshot(getSnapshot(), params)) as SnapshotUpdater;
187
+ // @sync-only-start
188
+ // const owner = this;
189
+ // update.gen = function* (params: CreateSnapshotParams) { return yield* owner.updateSnapshot.gen(getSnapshot(), params); };
190
+ // @sync-only-end
191
+ return update;
192
+ }
193
+ async getCurrentLanguageServerSnapshot(...args) {
153
194
  await this.ensureInitialized();
154
- const requestParams = toUpdateSnapshotRequest(params, baseSnapshot?.id);
155
- const data = await this.client.apiRequest("updateSnapshot", requestParams);
156
- // Retain cached source files from previous snapshot for unchanged files
157
- if (this.latestSnapshot) {
158
- this.sourceFileCache.retainForSnapshot(data.snapshot, this.latestSnapshot.id, data.changes);
159
- if (this.latestSnapshot.isDisposed()) {
160
- this.sourceFileCache.releaseSnapshot(this.latestSnapshot.id);
161
- }
195
+ const changes = args[0];
196
+ const baseSnapshot = args[1];
197
+ if (baseSnapshot && (!this.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed())) {
198
+ throw new Error("Cannot use an inactive snapshot as a response base");
199
+ }
200
+ const data = await this.client.apiRequest("getCurrentLanguageServerSnapshot", {
201
+ ...(baseSnapshot ? { baseSnapshot: baseSnapshot.id } : {}),
202
+ ...(changes ? { changes } : {}),
203
+ });
204
+ if (baseSnapshot) {
205
+ this.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
162
206
  }
163
207
  const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
164
208
  this.activeSnapshots.delete(snapshot);
165
- if (snapshot !== this.latestSnapshot) {
166
- this.sourceFileCache.releaseSnapshot(snapshot.id);
167
- }
168
- });
169
- this.latestSnapshot = snapshot;
209
+ this.sourceFileCache.releaseSnapshot(snapshot.id);
210
+ }, this.createSnapshotUpdater(() => snapshot), baseSnapshot);
170
211
  this.activeSnapshots.add(snapshot);
171
212
  return snapshot;
172
213
  }
@@ -180,11 +221,6 @@ export class API {
180
221
  for (const snapshot of [...this.activeSnapshots]) {
181
222
  await snapshot.dispose();
182
223
  }
183
- // Release the latest snapshot's cache refs if still held
184
- if (this.latestSnapshot) {
185
- this.sourceFileCache.releaseSnapshot(this.latestSnapshot.id);
186
- this.latestSnapshot = undefined;
187
- }
188
224
  this.sourceFileCache.clear();
189
225
  }
190
226
  finally {
@@ -199,16 +235,13 @@ export class API {
199
235
  if (!this.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed()) {
200
236
  throw new Error("Cannot run a temporary file update on an inactive snapshot");
201
237
  }
202
- const data = await this.client.apiRequest("updateTemporarySnapshot", { snapshot: baseSnapshot.id, file, newText });
203
- // Retain cached source files from the base snapshot for files unchanged by
204
- // the temporary update. The temporary snapshot is not the latest snapshot, so
205
- // we never release the latest snapshot's cache here.
206
- this.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
207
- const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
208
- this.activeSnapshots.delete(snapshot);
209
- this.sourceFileCache.releaseSnapshot(snapshot.id);
238
+ const snapshot = await baseSnapshot.update({
239
+ fileSystem: {
240
+ kind: "layer",
241
+ files: { [resolveFileName(file)]: newText },
242
+ },
243
+ ensurePrograms: true,
210
244
  });
211
- this.activeSnapshots.add(snapshot);
212
245
  try {
213
246
  await cb(snapshot);
214
247
  }
@@ -234,42 +267,18 @@ export class API {
234
267
  resetTimingInfo() {
235
268
  return this.client.resetTimingInfo();
236
269
  }
237
- isProgramActive(program) {
238
- const project = program.getProject();
239
- for (const snapshot of this.activeSnapshots) {
240
- if (!snapshot.isDisposed() && snapshot.getProject(project.configFileName)?.program === program) {
241
- return true;
242
- }
243
- }
244
- return false;
245
- }
246
- /**
247
- * Creates a program from current filesystem state, or derives one from oldProgram after applying fileChanges.
248
- */
249
- async createProgram(rootFiles, createProgramOptions, oldProgram, fileChanges) {
270
+ /** Creates a program from current filesystem state. */
271
+ async createProgram(rootFiles, createProgramOptions) {
250
272
  await this.ensureInitialized();
251
- if (fileChanges && !oldProgram) {
252
- throw new Error("fileChanges requires an oldProgram");
253
- }
254
- if (oldProgram && !this.isProgramActive(oldProgram)) {
255
- throw new Error("oldProgram must belong to this API instance and reference an active snapshot");
256
- }
257
- const data = await this.client.apiRequest("createProgram", {
258
- rootFiles,
259
- createProgramOptions,
260
- oldProgram: oldProgram ? { snapshot: oldProgram.snapshotId, project: oldProgram.getProject().id } : undefined,
261
- fileChanges,
273
+ const snapshot = await this.createSnapshot({
274
+ createPrograms: [{ rootFiles, options: createProgramOptions }],
262
275
  });
263
- if (!data.project) {
276
+ const program = snapshot.operation.createdPrograms[0];
277
+ if (!program) {
278
+ await snapshot.dispose();
264
279
  throw new Error("createProgram did not return a project");
265
280
  }
266
- const snapshot = new Snapshot({ snapshot: data.snapshot, projects: [data.project] }, this.client, this.sourceFileCache, this.toPath, this, () => {
267
- this.activeSnapshots.delete(snapshot);
268
- this.sourceFileCache.releaseSnapshot(snapshot.id);
269
- });
270
- const program = snapshot.getProjects()[0].program;
271
281
  program.setOwnedSnapshot(snapshot);
272
- this.activeSnapshots.add(snapshot);
273
282
  return program;
274
283
  }
275
284
  }
@@ -298,37 +307,68 @@ export class InternalAPI {
298
307
  }
299
308
  export class Snapshot {
300
309
  id;
310
+ operation;
301
311
  projectMap;
302
312
  toPath;
303
313
  client;
304
314
  disposed = false;
305
315
  disposePromise;
306
316
  onDispose;
307
- api;
308
317
  snapshotRegistry;
318
+ projectDataMap;
319
+ updateSnapshot;
309
320
  internal;
310
- constructor(data, client, sourceFileCache, toPath, api, onDispose) {
321
+ constructor(data, client, sourceFileCache, toPath, formatDiagnosticsHost, onDispose, updateSnapshot, baseSnapshot) {
311
322
  this.id = data.snapshot;
312
323
  this.client = client;
313
324
  this.toPath = toPath;
314
- this.api = api;
315
325
  this.onDispose = onDispose;
326
+ this.updateSnapshot = updateSnapshot;
316
327
  this.projectMap = new Map();
328
+ const projectDataMap = new Map(baseSnapshot?.projectDataMap);
329
+ for (const projectId of data.changes?.removedProjects ?? []) {
330
+ projectDataMap.delete(projectId);
331
+ }
332
+ for (const projectData of data.projects) {
333
+ projectDataMap.set(projectData.id, projectData);
334
+ }
335
+ this.projectDataMap = new Map([...projectDataMap].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
317
336
  this.snapshotRegistry = new SnapshotObjectRegistry(client, this.id, projectId => this.projectMap.get(projectId));
318
- for (const projData of data.projects) {
319
- const project = new Project(projData, this.id, client, sourceFileCache, toPath, api, this.snapshotRegistry);
320
- this.projectMap.set(toPath(projData.configFileName), project);
337
+ for (const projData of this.projectDataMap.values()) {
338
+ const project = new Project(projData, this.id, client, sourceFileCache, toPath, formatDiagnosticsHost, this.snapshotRegistry);
339
+ this.projectMap.set(projData.id, project);
321
340
  }
341
+ this.operation = {
342
+ ...(data.operation.createdPrograms ? { createdPrograms: data.operation.createdPrograms.map(projectId => this.requireProject(projectId).program) } : {}),
343
+ ...(data.operation.openedFiles ? { openedFiles: data.operation.openedFiles.map(result => ({ project: this.requireProject(result.project) })) } : {}),
344
+ };
322
345
  this.internal = new SnapshotInternalAPI(this.id, client);
323
346
  }
324
347
  getProjects() {
325
348
  this.ensureNotDisposed();
326
349
  return [...this.projectMap.values()];
327
350
  }
328
- getProject(configFileName) {
351
+ getConfiguredProject(configFileName) {
329
352
  this.ensureNotDisposed();
330
353
  return this.projectMap.get(this.toPath(configFileName));
331
354
  }
355
+ getProject(projectId) {
356
+ this.ensureNotDisposed();
357
+ return this.projectMap.get(projectId);
358
+ }
359
+ getProgram(projectId) {
360
+ return this.getProject(projectId)?.program;
361
+ }
362
+ update(params) {
363
+ this.ensureNotDisposed();
364
+ return this.updateSnapshot(params);
365
+ }
366
+ /**
367
+ * Gets the default project for a given file from the configured projects and
368
+ * inferred project already loaded in the snapshot. Synthetic projects are not
369
+ * considered. Files that have been opened with `openFiles` are guaranteed to
370
+ * have a result.
371
+ */
332
372
  async getDefaultProjectForFile(file) {
333
373
  this.ensureNotDisposed();
334
374
  const data = await this.client.apiRequest("getDefaultProjectForFile", {
@@ -337,15 +377,7 @@ export class Snapshot {
337
377
  });
338
378
  if (!data)
339
379
  return undefined;
340
- return this.projectMap.get(this.toPath(data.configFileName));
341
- }
342
- /**
343
- * Creates the next snapshot, layering its filesystem over this snapshot's
344
- * filesystem. This snapshot must still be active and be the latest snapshot.
345
- */
346
- async update(params) {
347
- this.ensureNotDisposed();
348
- return this.api.updateSnapshotFrom(this, params);
380
+ return this.projectMap.get(data.id);
349
381
  }
350
382
  [globalThis.Symbol.dispose]() {
351
383
  void this.dispose();
@@ -377,6 +409,13 @@ export class Snapshot {
377
409
  throw new Error("Snapshot is disposed");
378
410
  }
379
411
  }
412
+ requireProject(projectId) {
413
+ const project = this.projectMap.get(projectId);
414
+ if (!project) {
415
+ throw new Error(`Snapshot operation returned unknown project '${projectId}'`);
416
+ }
417
+ return project;
418
+ }
380
419
  }
381
420
  class SnapshotObjectRegistry {
382
421
  symbols = new Map();
@@ -388,7 +427,7 @@ class SnapshotObjectRegistry {
388
427
  this.snapshotId = snapshotId;
389
428
  this.resolveProject = resolveProject;
390
429
  }
391
- /** Resolve a project id (a config file path) to its Project within this snapshot. */
430
+ /** Resolve a project ID to its Project within this snapshot. */
392
431
  getProject(projectId) {
393
432
  return this.resolveProject(projectId);
394
433
  }
@@ -639,6 +678,7 @@ export class Project {
639
678
  id;
640
679
  configFileName;
641
680
  currentDirectory;
681
+ dirty;
642
682
  parsedCommandLine;
643
683
  /** @deprecated Use `parsedCommandLine.options`. */
644
684
  compilerOptions;
@@ -646,7 +686,6 @@ export class Project {
646
686
  rootFiles;
647
687
  program;
648
688
  checker;
649
- emitter;
650
689
  languageService;
651
690
  client;
652
691
  snapshotId;
@@ -654,6 +693,7 @@ export class Project {
654
693
  this.id = data.id;
655
694
  this.configFileName = data.configFileName;
656
695
  this.currentDirectory = data.currentDirectory;
696
+ this.dirty = data.dirty;
657
697
  if (!data.parsedCommandLine?.options) {
658
698
  throw new Error(`Project '${data.configFileName}' has no parsed command line`);
659
699
  }
@@ -665,7 +705,6 @@ export class Project {
665
705
  this.program = new Program(snapshotId, this, client, sourceFileCache, toPath, formatDiagnosticsHost);
666
706
  const objectRegistry = new ProjectObjectRegistry(client, snapshotId, this, snapshotRegistry);
667
707
  this.checker = new Checker(snapshotId, this, client, objectRegistry);
668
- this.emitter = new Emitter(client);
669
708
  this.languageService = new LanguageService(snapshotId, this, client, objectRegistry);
670
709
  }
671
710
  /** @deprecated Use `languageService.getImportAdderEdits`. */
@@ -777,6 +816,7 @@ export class LanguageService {
777
816
  export class Program {
778
817
  /** @internal */
779
818
  snapshotId;
819
+ id;
780
820
  project;
781
821
  client;
782
822
  sourceFileCache;
@@ -788,6 +828,7 @@ export class Program {
788
828
  disposePromise;
789
829
  constructor(snapshotId, project, client, sourceFileCache, toPath, formatDiagnosticsHost) {
790
830
  this.snapshotId = snapshotId;
831
+ this.id = project.id;
791
832
  this.project = project;
792
833
  this.client = client;
793
834
  this.sourceFileCache = sourceFileCache;
@@ -856,6 +897,22 @@ export class Program {
856
897
  });
857
898
  return result ?? undefined;
858
899
  }
900
+ async getModeForUsageLocation(file, usage) {
901
+ return this.client.apiRequest("getModeForUsageLocation", {
902
+ snapshot: this.snapshotId,
903
+ project: this.project.id,
904
+ file,
905
+ usage: getNodeId(usage),
906
+ });
907
+ }
908
+ async getModeForResolutionAtIndex(file, index) {
909
+ return this.client.apiRequest("getModeForResolutionAtIndex", {
910
+ snapshot: this.snapshotId,
911
+ project: this.project.id,
912
+ file,
913
+ index,
914
+ });
915
+ }
859
916
  async getResolvedModuleFromModuleSpecifier(moduleSpecifier, sourceFile) {
860
917
  const result = await this.client.apiRequest("getResolvedModuleFromModuleSpecifier", {
861
918
  snapshot: this.snapshotId,
@@ -1703,7 +1760,19 @@ export class Checker {
1703
1760
  project: this.project.id,
1704
1761
  location: getNodeId(node),
1705
1762
  });
1706
- return typeof data === "string" || typeof data === "number" ? data : undefined;
1763
+ if (!data || (typeof data.value !== "string" && typeof data.value !== "number")) {
1764
+ return undefined;
1765
+ }
1766
+ if (data.isNumber && typeof data.value === "string") {
1767
+ if (data.value === "+Infinity") {
1768
+ return Infinity;
1769
+ }
1770
+ else if (data.value === "-Infinity") {
1771
+ return -Infinity;
1772
+ }
1773
+ return NaN;
1774
+ }
1775
+ return data.value;
1707
1776
  }
1708
1777
  /** Get the signature of a function-like declaration. Always returns a signature. */
1709
1778
  async getSignatureFromDeclaration(node) {
@@ -1870,7 +1939,7 @@ export class Checker {
1870
1939
  return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
1871
1940
  }
1872
1941
  }
1873
- export class Emitter {
1942
+ export class Printer {
1874
1943
  client;
1875
1944
  constructor(client) {
1876
1945
  this.client = client;
@@ -1885,6 +1954,16 @@ export class Emitter {
1885
1954
  terminateUnterminatedLiterals: options.terminateUnterminatedLiterals,
1886
1955
  });
1887
1956
  }
1957
+ async printFile(sourceFile, options = {}) {
1958
+ const encoded = encodeNode(sourceFile);
1959
+ const base64 = uint8ArrayToBase64(encoded);
1960
+ return this.client.apiRequest("printNode", {
1961
+ data: base64,
1962
+ preserveSourceNewlines: options.preserveSourceNewlines,
1963
+ neverAsciiEscape: options.neverAsciiEscape,
1964
+ terminateUnterminatedLiterals: options.terminateUnterminatedLiterals,
1965
+ });
1966
+ }
1888
1967
  }
1889
1968
  export class SnapshotInternalAPI {
1890
1969
  snapshotId;
@@ -2092,7 +2171,24 @@ class TypeObject {
2092
2171
  // BigInt literal values are serialized as decimal strings (e.g. "-123") because
2093
2172
  // JSON cannot represent bigint. Decode them back into a real bigint here.
2094
2173
  const value = data.value;
2095
- this.value = (data.flags & TypeFlags.BigIntLiteral) ? BigInt(value) : value;
2174
+ if (data.flags & TypeFlags.BigIntLiteral) {
2175
+ this.value = BigInt(value);
2176
+ }
2177
+ // JSON cannot represent infinities, so the API serializes them as strings.
2178
+ else if (data.flags & TypeFlags.NumberLiteral && typeof value === "string") {
2179
+ if (value === "+Infinity") {
2180
+ this.value = Infinity;
2181
+ }
2182
+ else if (value === "-Infinity") {
2183
+ this.value = -Infinity;
2184
+ }
2185
+ else {
2186
+ this.value = NaN;
2187
+ }
2188
+ }
2189
+ else {
2190
+ this.value = value;
2191
+ }
2096
2192
  }
2097
2193
  if (data.intrinsicName !== undefined)
2098
2194
  this.intrinsicName = data.intrinsicName;