@openpkg-ts/sdk 0.48.0 → 0.48.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/index.js CHANGED
@@ -1300,7 +1300,7 @@ function filterSpec(spec, criteria) {
1300
1300
  };
1301
1301
  }
1302
1302
  // src/primitives/get.ts
1303
- import ts11 from "typescript";
1303
+ import ts12 from "typescript";
1304
1304
 
1305
1305
  // src/ast/utils.ts
1306
1306
  import * as path2 from "node:path";
@@ -1846,13 +1846,84 @@ function createProgram(options) {
1846
1846
  }
1847
1847
 
1848
1848
  // src/serializers/classes.ts
1849
- import ts7 from "typescript";
1849
+ import ts8 from "typescript";
1850
1850
 
1851
1851
  // src/types/parameters.ts
1852
- import ts4 from "typescript";
1852
+ import ts5 from "typescript";
1853
1853
 
1854
1854
  // src/types/schema-builder.ts
1855
+ import ts4 from "typescript";
1856
+
1857
+ // src/ast/type-identity.ts
1858
+ import * as path4 from "node:path";
1855
1859
  import ts3 from "typescript";
1860
+ var NODE_MODULES_PKG = /node_modules\/(@[^/]+\/[^/]+|[^/]+)/;
1861
+ function packageLabel(fileName, workspacePackages) {
1862
+ const match = fileName.match(NODE_MODULES_PKG);
1863
+ let pkg = match?.[1];
1864
+ if (!pkg) {
1865
+ for (const [name, dir] of workspacePackages) {
1866
+ if (fileName.startsWith(`${path4.resolve(dir)}${path4.sep}`)) {
1867
+ pkg = name;
1868
+ break;
1869
+ }
1870
+ }
1871
+ }
1872
+ return (pkg ?? "local").replace(/^@/, "").replace(/\//g, "-");
1873
+ }
1874
+ function declKey(symbol, checker) {
1875
+ let resolved = symbol;
1876
+ if (symbol.flags & ts3.SymbolFlags.Alias) {
1877
+ try {
1878
+ resolved = checker.getAliasedSymbol(symbol);
1879
+ } catch {}
1880
+ }
1881
+ const decl = resolved.declarations?.[0];
1882
+ if (!decl)
1883
+ return;
1884
+ return `${decl.getSourceFile().fileName}#${decl.getStart()}`;
1885
+ }
1886
+ function resolveTypeId(symbol, ctx) {
1887
+ const cached = ctx.typeIds.get(symbol);
1888
+ if (cached)
1889
+ return cached;
1890
+ const key = declKey(symbol, ctx.typeChecker);
1891
+ if (key) {
1892
+ const existing = ctx.declIds.get(key);
1893
+ if (existing) {
1894
+ ctx.typeIds.set(symbol, existing);
1895
+ return existing;
1896
+ }
1897
+ }
1898
+ const claim = (id) => {
1899
+ ctx.typeIds.set(symbol, id);
1900
+ if (key)
1901
+ ctx.declIds.set(key, id);
1902
+ ctx.idOwner.set(id, key ?? id);
1903
+ return id;
1904
+ };
1905
+ const name = symbol.getName();
1906
+ const owner = ctx.idOwner.get(name);
1907
+ if (!owner || owner === key)
1908
+ return claim(name);
1909
+ const file = symbol.declarations?.[0]?.getSourceFile().fileName ?? "";
1910
+ const scoped = `${packageLabel(file, ctx.workspacePackages)}.${name}`;
1911
+ const scopedOwner = ctx.idOwner.get(scoped);
1912
+ if (!scopedOwner || scopedOwner === key)
1913
+ return claim(scoped);
1914
+ let n = 2;
1915
+ while (ctx.idOwner.has(`${name}_${n}`))
1916
+ n++;
1917
+ return claim(`${name}_${n}`);
1918
+ }
1919
+ function typeRefId(type, ctx) {
1920
+ const symbol = type.aliasSymbol ?? type.getSymbol();
1921
+ if (!symbol)
1922
+ return "";
1923
+ if (!ctx)
1924
+ return symbol.getName();
1925
+ return resolveTypeId(symbol, ctx);
1926
+ }
1856
1927
 
1857
1928
  // src/schema/builtins.ts
1858
1929
  var BUILTIN_TYPE_SCHEMAS = {
@@ -1889,11 +1960,11 @@ function escapeRegex(text) {
1889
1960
  }
1890
1961
  function buildTemplatePattern(type) {
1891
1962
  const slotPattern = (slot) => {
1892
- if (slot.flags & ts3.TypeFlags.NumberLike)
1963
+ if (slot.flags & ts4.TypeFlags.NumberLike)
1893
1964
  return "-?\\d+(?:\\.\\d+)?";
1894
- if (slot.flags & ts3.TypeFlags.BigIntLike)
1965
+ if (slot.flags & ts4.TypeFlags.BigIntLike)
1895
1966
  return "-?\\d+";
1896
- if (slot.flags & ts3.TypeFlags.BooleanLike)
1967
+ if (slot.flags & ts4.TypeFlags.BooleanLike)
1897
1968
  return "(?:true|false)";
1898
1969
  return ".*";
1899
1970
  };
@@ -1903,6 +1974,11 @@ function buildTemplatePattern(type) {
1903
1974
  });
1904
1975
  return `${pattern}$`;
1905
1976
  }
1977
+ function namedRefId(type, name, ctx) {
1978
+ if (!ctx)
1979
+ return name;
1980
+ return typeRefId(type, ctx) || name;
1981
+ }
1906
1982
  function builtinSchema(name) {
1907
1983
  const schema = { ...BUILTIN_TYPE_SCHEMAS[name] ?? { type: "object" } };
1908
1984
  setSchemaExtension(schema, "x-ts-type", name);
@@ -1915,12 +1991,12 @@ function scrubImportQualifiers(text) {
1915
1991
  return text.replace(/import\((?:"[^"]*"|'[^']*')\)\./g, "");
1916
1992
  }
1917
1993
  function renderTypeText(type, checker, enclosing, extraFlags = 0) {
1918
- return scrubImportQualifiers(checker.typeToString(type, enclosing, ts3.TypeFormatFlags.NoTruncation | extraFlags));
1994
+ return scrubImportQualifiers(checker.typeToString(type, enclosing, ts4.TypeFormatFlags.NoTruncation | extraFlags));
1919
1995
  }
1920
1996
  function stripUndefinedFromType(type, checker) {
1921
1997
  if (!type.isUnion())
1922
1998
  return type;
1923
- const nonUndefinedTypes = type.types.filter((t) => !(t.flags & ts3.TypeFlags.Undefined));
1999
+ const nonUndefinedTypes = type.types.filter((t) => !(t.flags & ts4.TypeFlags.Undefined));
1924
2000
  if (nonUndefinedTypes.length === 0)
1925
2001
  return type;
1926
2002
  if (nonUndefinedTypes.length === 1)
@@ -1929,13 +2005,13 @@ function stripUndefinedFromType(type, checker) {
1929
2005
  }
1930
2006
  function isReadonlyPropertySymbol(prop) {
1931
2007
  const decls = prop.getDeclarations() ?? [];
1932
- return decls.some((d) => (ts3.getCombinedModifierFlags(d) & ts3.ModifierFlags.Readonly) !== 0);
2008
+ return decls.some((d) => (ts4.getCombinedModifierFlags(d) & ts4.ModifierFlags.Readonly) !== 0);
1933
2009
  }
1934
2010
  function decoratePropertySchema(schema, prop, propType, checker) {
1935
2011
  if (typeof schema !== "object" || schema === null || Array.isArray(schema))
1936
2012
  return schema;
1937
2013
  const decl = prop.valueDeclaration ?? prop.getDeclarations()?.[0];
1938
- const optional = !!(prop.flags & ts3.SymbolFlags.Optional);
2014
+ const optional = !!(prop.flags & ts4.SymbolFlags.Optional);
1939
2015
  const textType = optional ? stripUndefinedFromType(propType, checker) : propType;
1940
2016
  const text = renderTypeText(textType, checker, decl);
1941
2017
  const obj = schema;
@@ -1948,13 +2024,13 @@ function decoratePropertySchema(schema, prop, propType, checker) {
1948
2024
  if (isReadonlyPropertySymbol(prop) && !("readOnly" in obj)) {
1949
2025
  result = { ...result, readOnly: true };
1950
2026
  }
1951
- if (prop.flags & ts3.SymbolFlags.Method && !("x-ts-method" in obj)) {
2027
+ if (prop.flags & ts4.SymbolFlags.Method && !("x-ts-method" in obj)) {
1952
2028
  result = { ...result, "x-ts-method": true };
1953
2029
  }
1954
2030
  return result;
1955
2031
  }
1956
2032
  function shouldEmitAliasTypeText(typeNode) {
1957
- return !ts3.isTypeLiteralNode(typeNode) && !ts3.isMappedTypeNode(typeNode);
2033
+ return !ts4.isTypeLiteralNode(typeNode) && !ts4.isMappedTypeNode(typeNode);
1958
2034
  }
1959
2035
  var PRIMITIVES = new Set([
1960
2036
  "string",
@@ -2205,7 +2281,7 @@ function buildSchema(type, checker, ctx) {
2205
2281
  return ensureNonEmptySchema(schema, type, checker);
2206
2282
  }
2207
2283
  function buildMaxDepthSchema(type, checker) {
2208
- if (type.flags & ts3.TypeFlags.TypeParameter && type.isThisType !== true) {
2284
+ if (type.flags & ts4.TypeFlags.TypeParameter && type.isThisType !== true) {
2209
2285
  return { "x-ts-type": checker.typeToString(type) };
2210
2286
  }
2211
2287
  const symbol = type.getSymbol() || type.aliasSymbol;
@@ -2218,19 +2294,19 @@ function buildMaxDepthSchema(type, checker) {
2218
2294
  return { $ref: `#/types/${name}` };
2219
2295
  }
2220
2296
  }
2221
- if (type.flags & ts3.TypeFlags.String)
2297
+ if (type.flags & ts4.TypeFlags.String)
2222
2298
  return { type: "string" };
2223
- if (type.flags & ts3.TypeFlags.Number)
2299
+ if (type.flags & ts4.TypeFlags.Number)
2224
2300
  return { type: "number" };
2225
- if (type.flags & ts3.TypeFlags.Boolean)
2301
+ if (type.flags & ts4.TypeFlags.Boolean)
2226
2302
  return { type: "boolean" };
2227
- if (type.flags & ts3.TypeFlags.Undefined)
2303
+ if (type.flags & ts4.TypeFlags.Undefined)
2228
2304
  return { type: "undefined" };
2229
- if (type.flags & ts3.TypeFlags.Null)
2305
+ if (type.flags & ts4.TypeFlags.Null)
2230
2306
  return { type: "null" };
2231
- if (type.flags & ts3.TypeFlags.Void)
2307
+ if (type.flags & ts4.TypeFlags.Void)
2232
2308
  return { type: "void" };
2233
- if (type.flags & ts3.TypeFlags.TemplateLiteral) {
2309
+ if (type.flags & ts4.TypeFlags.TemplateLiteral) {
2234
2310
  return {
2235
2311
  type: "string",
2236
2312
  pattern: buildTemplatePattern(type),
@@ -2262,59 +2338,59 @@ function buildSchemaInternal(type, checker, ctx) {
2262
2338
  if (BUILTIN_TYPES.has(name) || isBuiltinGeneric(name)) {
2263
2339
  return builtinSchema(name);
2264
2340
  }
2265
- return { $ref: `#/types/${name}` };
2341
+ return { $ref: `#/types/${namedRefId(type, name, ctx)}` };
2266
2342
  }
2267
2343
  return { type: checker.typeToString(type) };
2268
2344
  }
2269
- const addedToVisited = !!(ctx && type.flags & ts3.TypeFlags.Object);
2345
+ const addedToVisited = !!(ctx && type.flags & ts4.TypeFlags.Object);
2270
2346
  if (addedToVisited) {
2271
2347
  ctx.visitedTypes.add(type);
2272
2348
  }
2273
2349
  try {
2274
- if (type.flags & ts3.TypeFlags.String)
2350
+ if (type.flags & ts4.TypeFlags.String)
2275
2351
  return { type: "string" };
2276
- if (type.flags & ts3.TypeFlags.Number)
2352
+ if (type.flags & ts4.TypeFlags.Number)
2277
2353
  return { type: "number" };
2278
- if (type.flags & ts3.TypeFlags.Boolean)
2354
+ if (type.flags & ts4.TypeFlags.Boolean)
2279
2355
  return { type: "boolean" };
2280
- if (type.flags & ts3.TypeFlags.Undefined)
2356
+ if (type.flags & ts4.TypeFlags.Undefined)
2281
2357
  return { type: "undefined" };
2282
- if (type.flags & ts3.TypeFlags.Null)
2358
+ if (type.flags & ts4.TypeFlags.Null)
2283
2359
  return { type: "null" };
2284
- if (type.flags & ts3.TypeFlags.Void)
2360
+ if (type.flags & ts4.TypeFlags.Void)
2285
2361
  return { type: "void" };
2286
- if (type.flags & ts3.TypeFlags.Any)
2362
+ if (type.flags & ts4.TypeFlags.Any)
2287
2363
  return { type: "any" };
2288
- if (type.flags & ts3.TypeFlags.Unknown)
2364
+ if (type.flags & ts4.TypeFlags.Unknown)
2289
2365
  return { type: "unknown" };
2290
- if (type.flags & ts3.TypeFlags.Never)
2366
+ if (type.flags & ts4.TypeFlags.Never)
2291
2367
  return { type: "never" };
2292
- if (type.flags & ts3.TypeFlags.BigInt)
2368
+ if (type.flags & ts4.TypeFlags.BigInt)
2293
2369
  return { type: "bigint" };
2294
- if (type.flags & ts3.TypeFlags.ESSymbol)
2370
+ if (type.flags & ts4.TypeFlags.ESSymbol)
2295
2371
  return { type: "symbol" };
2296
2372
  if (type.isThisType === true) {
2297
2373
  const constraint = type.getConstraint?.();
2298
2374
  const symbol2 = constraint?.getSymbol() ?? type.getSymbol();
2299
2375
  if (symbol2 && !isAnonymous(type)) {
2300
2376
  return {
2301
- $ref: `#/types/${symbol2.getName()}`,
2377
+ $ref: `#/types/${ctx ? resolveTypeId(symbol2, ctx) : symbol2.getName()}`,
2302
2378
  "x-ts-type": "this"
2303
2379
  };
2304
2380
  }
2305
2381
  }
2306
- if (type.flags & ts3.TypeFlags.TypeParameter) {
2382
+ if (type.flags & ts4.TypeFlags.TypeParameter) {
2307
2383
  return { "x-ts-type": checker.typeToString(type) };
2308
2384
  }
2309
- if (type.flags & ts3.TypeFlags.StringLiteral) {
2385
+ if (type.flags & ts4.TypeFlags.StringLiteral) {
2310
2386
  const literal = type.value;
2311
2387
  return { type: "string", enum: [literal] };
2312
2388
  }
2313
- if (type.flags & ts3.TypeFlags.NumberLiteral) {
2389
+ if (type.flags & ts4.TypeFlags.NumberLiteral) {
2314
2390
  const literal = type.value;
2315
2391
  return { type: "number", enum: [literal] };
2316
2392
  }
2317
- if (type.flags & ts3.TypeFlags.BooleanLiteral) {
2393
+ if (type.flags & ts4.TypeFlags.BooleanLiteral) {
2318
2394
  const typeString2 = checker.typeToString(type);
2319
2395
  return { type: "boolean", enum: [typeString2 === "true"] };
2320
2396
  }
@@ -2322,40 +2398,40 @@ function buildSchemaInternal(type, checker, ctx) {
2322
2398
  const aliasName = type.aliasSymbol.getName();
2323
2399
  if (!aliasName.startsWith("__") && !isPrimitiveName(aliasName)) {
2324
2400
  const packageOrigin = getTypeOrigin(type, checker);
2325
- const schema = { $ref: `#/types/${aliasName}` };
2401
+ const schema = { $ref: `#/types/${namedRefId(type, aliasName, ctx)}` };
2326
2402
  if (packageOrigin) {
2327
2403
  setSchemaExtension(schema, "x-ts-package", packageOrigin);
2328
2404
  }
2329
2405
  return schema;
2330
2406
  }
2331
2407
  }
2332
- if (type.flags & ts3.TypeFlags.TemplateLiteral) {
2408
+ if (type.flags & ts4.TypeFlags.TemplateLiteral) {
2333
2409
  return {
2334
2410
  type: "string",
2335
2411
  pattern: buildTemplatePattern(type),
2336
2412
  "x-ts-type": renderTypeText(type, checker)
2337
2413
  };
2338
2414
  }
2339
- if (type.flags & ts3.TypeFlags.StringMapping) {
2415
+ if (type.flags & ts4.TypeFlags.StringMapping) {
2340
2416
  return { type: "string", "x-ts-type": renderTypeText(type, checker) };
2341
2417
  }
2342
2418
  if (type.isUnion()) {
2343
2419
  const types = type.types;
2344
- const allStringLiterals = types.every((t) => t.flags & ts3.TypeFlags.StringLiteral);
2420
+ const allStringLiterals = types.every((t) => t.flags & ts4.TypeFlags.StringLiteral);
2345
2421
  if (allStringLiterals) {
2346
2422
  const enumValues = types.map((t) => t.value);
2347
2423
  return { type: "string", enum: enumValues };
2348
2424
  }
2349
- const allNumberLiterals = types.every((t) => t.flags & ts3.TypeFlags.NumberLiteral);
2425
+ const allNumberLiterals = types.every((t) => t.flags & ts4.TypeFlags.NumberLiteral);
2350
2426
  if (allNumberLiterals) {
2351
2427
  const enumValues = types.map((t) => t.value);
2352
2428
  return { type: "number", enum: enumValues };
2353
2429
  }
2354
- const allBooleanLiterals = types.every((t) => t.flags & ts3.TypeFlags.BooleanLiteral);
2430
+ const allBooleanLiterals = types.every((t) => t.flags & ts4.TypeFlags.BooleanLiteral);
2355
2431
  if (allBooleanLiterals) {
2356
2432
  return { type: "boolean" };
2357
2433
  }
2358
- const isBoolLiteral = (t) => !!(t.flags & ts3.TypeFlags.BooleanLiteral);
2434
+ const isBoolLiteral = (t) => !!(t.flags & ts4.TypeFlags.BooleanLiteral);
2359
2435
  let members = types;
2360
2436
  if (types.filter(isBoolLiteral).length === 2) {
2361
2437
  const firstBool = types.findIndex(isBoolLiteral);
@@ -2369,10 +2445,10 @@ function buildSchemaInternal(type, checker, ctx) {
2369
2445
  }
2370
2446
  return { anyOf: members.map(buildBranch) };
2371
2447
  }
2372
- const isIntersectionType = type.isIntersection() || !!(type.flags & ts3.TypeFlags.Intersection);
2448
+ const isIntersectionType = type.isIntersection() || !!(type.flags & ts4.TypeFlags.Intersection);
2373
2449
  if (isIntersectionType && "types" in type) {
2374
2450
  const intersectionType = type;
2375
- const filteredTypes = intersectionType.types.filter((t) => !(t.flags & ts3.TypeFlags.Never));
2451
+ const filteredTypes = intersectionType.types.filter((t) => !(t.flags & ts4.TypeFlags.Never));
2376
2452
  if (filteredTypes.length === 0) {
2377
2453
  return { type: "never" };
2378
2454
  }
@@ -2461,7 +2537,7 @@ function buildSchemaInternal(type, checker, ctx) {
2461
2537
  if (ctx) {
2462
2538
  return withDepth(ctx, () => {
2463
2539
  const schema2 = {
2464
- $ref: `#/types/${name}`,
2540
+ $ref: `#/types/${namedRefId(typeRef.target, name, ctx)}`,
2465
2541
  typeArguments: typeArgs.map((t) => buildSchema(t, checker, ctx))
2466
2542
  };
2467
2543
  if (packageOrigin) {
@@ -2487,7 +2563,7 @@ function buildSchemaInternal(type, checker, ctx) {
2487
2563
  if (BUILTIN_TYPES.has(name)) {
2488
2564
  return builtinSchema(name);
2489
2565
  }
2490
- if (RESOLVED_UTILITY_TYPES.has(name) && type.flags & ts3.TypeFlags.Object) {
2566
+ if (RESOLVED_UTILITY_TYPES.has(name) && type.flags & ts4.TypeFlags.Object) {
2491
2567
  const props = type.getProperties();
2492
2568
  const hasIndex = checker.getIndexInfosOfType(type).length > 0;
2493
2569
  if (props.length > 0 || hasIndex) {
@@ -2506,7 +2582,7 @@ function buildSchemaInternal(type, checker, ctx) {
2506
2582
  if (ctx) {
2507
2583
  return withDepth(ctx, () => {
2508
2584
  const schema2 = {
2509
- $ref: `#/types/${name}`,
2585
+ $ref: `#/types/${namedRefId(type, name, ctx)}`,
2510
2586
  typeArguments: aliasTypeArgs.map((t) => buildSchema(t, checker, ctx))
2511
2587
  };
2512
2588
  if (packageOrigin) {
@@ -2525,7 +2601,7 @@ function buildSchemaInternal(type, checker, ctx) {
2525
2601
  return schema;
2526
2602
  }
2527
2603
  }
2528
- if (type.flags & ts3.TypeFlags.Object) {
2604
+ if (type.flags & ts4.TypeFlags.Object) {
2529
2605
  const callSignatures = type.getCallSignatures();
2530
2606
  if (callSignatures.length > 0) {
2531
2607
  return buildFunctionSchema(callSignatures, checker, ctx);
@@ -2544,17 +2620,17 @@ function buildSchemaInternal(type, checker, ctx) {
2544
2620
  }
2545
2621
  if (!name.startsWith("__")) {
2546
2622
  const packageOrigin = getTypeOrigin(type, checker);
2547
- const schema = { $ref: `#/types/${name}` };
2623
+ const schema = { $ref: `#/types/${namedRefId(type, name, ctx)}` };
2548
2624
  if (packageOrigin) {
2549
2625
  setSchemaExtension(schema, "x-ts-package", packageOrigin);
2550
2626
  }
2551
2627
  return schema;
2552
2628
  }
2553
2629
  }
2554
- if (type.flags & ts3.TypeFlags.Object) {
2630
+ if (type.flags & ts4.TypeFlags.Object) {
2555
2631
  const objectType = type;
2556
2632
  const properties = type.getProperties();
2557
- if (properties.length > 0 || objectType.objectFlags & ts3.ObjectFlags.Anonymous || checker.getIndexInfosOfType(type).length > 0) {
2633
+ if (properties.length > 0 || objectType.objectFlags & ts4.ObjectFlags.Anonymous || checker.getIndexInfosOfType(type).length > 0) {
2558
2634
  return buildObjectSchema(properties, checker, ctx, type);
2559
2635
  }
2560
2636
  }
@@ -2598,8 +2674,8 @@ function buildFunctionSchema(callSignatures, checker, ctx) {
2598
2674
  }
2599
2675
  function buildObjectSchema(properties, checker, ctx, originalType) {
2600
2676
  const isArrayLikeType = originalType ? checker.isArrayType(originalType) || checker.isTupleType(originalType) || originalType.symbol?.getName() === "Array" && isBuiltinSymbol(originalType.symbol) : false;
2601
- const isStringLikeType = !!(originalType && originalType.flags & ts3.TypeFlags.StringLike);
2602
- const isNumberLikeType = !!(originalType && originalType.flags & ts3.TypeFlags.NumberLike);
2677
+ const isStringLikeType = !!(originalType && originalType.flags & ts4.TypeFlags.StringLike);
2678
+ const isNumberLikeType = !!(originalType && originalType.flags & ts4.TypeFlags.NumberLike);
2603
2679
  const buildProps = () => {
2604
2680
  const props = {};
2605
2681
  const required = [];
@@ -2616,7 +2692,7 @@ function buildObjectSchema(properties, checker, ctx, originalType) {
2616
2692
  if (isNumberLikeType && NUMBER_PROTOTYPE_METHODS.has(propName)) {
2617
2693
  continue;
2618
2694
  }
2619
- const isOptionalProp = !!(prop.flags & ts3.SymbolFlags.Optional);
2695
+ const isOptionalProp = !!(prop.flags & ts4.SymbolFlags.Optional);
2620
2696
  const rawPropType = checker.getTypeOfSymbol(prop);
2621
2697
  const propType = isOptionalProp ? stripUndefinedFromType(rawPropType, checker) : rawPropType;
2622
2698
  let propSchema = buildSchema(propType, checker, ctx);
@@ -2634,7 +2710,7 @@ function buildObjectSchema(properties, checker, ctx, originalType) {
2634
2710
  }
2635
2711
  propSchema = decoratePropertySchema(propSchema, prop, propType, checker);
2636
2712
  props[propName] = propSchema;
2637
- if (!(prop.flags & ts3.SymbolFlags.Optional)) {
2713
+ if (!(prop.flags & ts4.SymbolFlags.Optional)) {
2638
2714
  required.push(propName);
2639
2715
  }
2640
2716
  }
@@ -2644,11 +2720,11 @@ function buildObjectSchema(properties, checker, ctx, originalType) {
2644
2720
  ...required.length > 0 ? { required } : {}
2645
2721
  };
2646
2722
  const indexInfos = originalType ? checker.getIndexInfosOfType(originalType) : [];
2647
- const stringIndex = indexInfos.find((i) => i.keyType.flags & ts3.TypeFlags.String);
2723
+ const stringIndex = indexInfos.find((i) => i.keyType.flags & ts4.TypeFlags.String);
2648
2724
  if (stringIndex) {
2649
2725
  schema.additionalProperties = buildSchema(stringIndex.type, checker, ctx);
2650
2726
  }
2651
- const numberIndex = indexInfos.find((i) => i.keyType.flags & ts3.TypeFlags.Number);
2727
+ const numberIndex = indexInfos.find((i) => i.keyType.flags & ts4.TypeFlags.Number);
2652
2728
  if (numberIndex) {
2653
2729
  schema.patternProperties = {
2654
2730
  "^\\d+$": buildSchema(numberIndex.type, checker, ctx)
@@ -2737,7 +2813,7 @@ function deduplicateSchemas(schemas) {
2737
2813
  function findDiscriminatorProperty(unionTypes, checker) {
2738
2814
  const memberProps = [];
2739
2815
  for (const t of unionTypes) {
2740
- if (t.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined)) {
2816
+ if (t.flags & (ts4.TypeFlags.Null | ts4.TypeFlags.Undefined)) {
2741
2817
  continue;
2742
2818
  }
2743
2819
  const props = t.getProperties();
@@ -2791,13 +2867,13 @@ function extractParameters(signature, ctx) {
2791
2867
  const { typeChecker: checker } = ctx;
2792
2868
  const result = [];
2793
2869
  const signatureDecl = signature.getDeclaration();
2794
- const jsdocTags = signatureDecl ? ts4.getJSDocTags(signatureDecl) : [];
2870
+ const jsdocTags = signatureDecl ? ts5.getJSDocTags(signatureDecl) : [];
2795
2871
  for (const param of signature.getParameters()) {
2796
2872
  const decl = param.valueDeclaration;
2797
2873
  if (!decl)
2798
2874
  continue;
2799
2875
  const type = checker.getTypeOfSymbolAtLocation(param, decl);
2800
- if (decl && ts4.isObjectBindingPattern(decl.name)) {
2876
+ if (decl && ts5.isObjectBindingPattern(decl.name)) {
2801
2877
  const expandedParams = expandBindingPattern(decl, type, jsdocTags, ctx);
2802
2878
  result.push(...expandedParams);
2803
2879
  } else {
@@ -2829,13 +2905,13 @@ function expandBindingPattern(paramDecl, paramType, jsdocTags, ctx) {
2829
2905
  const allProperties = getEffectiveProperties(paramType, checker);
2830
2906
  const inferredAlias = inferParamAlias(jsdocTags);
2831
2907
  for (const element of bindingPattern.elements) {
2832
- if (!ts4.isBindingElement(element))
2908
+ if (!ts5.isBindingElement(element))
2833
2909
  continue;
2834
- const propertyName = element.propertyName ? ts4.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText() : ts4.isIdentifier(element.name) ? element.name.text : element.name.getText();
2910
+ const propertyName = element.propertyName ? ts5.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText() : ts5.isIdentifier(element.name) ? element.name.text : element.name.getText();
2835
2911
  const propSymbol = allProperties.get(propertyName);
2836
2912
  if (!propSymbol)
2837
2913
  continue;
2838
- const isOptional = !!(propSymbol.flags & ts4.SymbolFlags.Optional) || element.initializer !== undefined;
2914
+ const isOptional = !!(propSymbol.flags & ts5.SymbolFlags.Optional) || element.initializer !== undefined;
2839
2915
  const propType = checker.getTypeOfSymbol(propSymbol);
2840
2916
  const effectiveType = isOptional ? stripUndefinedFromType(propType, checker) : propType;
2841
2917
  registerReferencedTypes(effectiveType, ctx);
@@ -2875,7 +2951,7 @@ function inferParamAlias(jsdocTags) {
2875
2951
  for (const tag of jsdocTags) {
2876
2952
  if (tag.tagName.text !== "param")
2877
2953
  continue;
2878
- const tagText = typeof tag.comment === "string" ? tag.comment : ts4.getTextOfJSDocComment(tag.comment) ?? "";
2954
+ const tagText = typeof tag.comment === "string" ? tag.comment : ts5.getTextOfJSDocComment(tag.comment) ?? "";
2879
2955
  const paramTag = tag;
2880
2956
  const paramName = paramTag.name?.getText() ?? "";
2881
2957
  if (paramName.includes(".")) {
@@ -2898,22 +2974,22 @@ function inferParamAlias(jsdocTags) {
2898
2974
  return Array.from(counts.entries()).sort((a, b) => b[1] - a[1])[0]?.[0];
2899
2975
  }
2900
2976
  function extractLiteralDefault(initializer) {
2901
- if (ts4.isStringLiteral(initializer)) {
2977
+ if (ts5.isStringLiteral(initializer)) {
2902
2978
  return { literal: true, value: initializer.text };
2903
2979
  }
2904
- if (ts4.isNumericLiteral(initializer)) {
2980
+ if (ts5.isNumericLiteral(initializer)) {
2905
2981
  return { literal: true, value: Number(initializer.text) };
2906
2982
  }
2907
- if (ts4.isPrefixUnaryExpression(initializer) && initializer.operator === ts4.SyntaxKind.MinusToken && ts4.isNumericLiteral(initializer.operand)) {
2983
+ if (ts5.isPrefixUnaryExpression(initializer) && initializer.operator === ts5.SyntaxKind.MinusToken && ts5.isNumericLiteral(initializer.operand)) {
2908
2984
  return { literal: true, value: -Number(initializer.operand.text) };
2909
2985
  }
2910
- if (initializer.kind === ts4.SyntaxKind.TrueKeyword) {
2986
+ if (initializer.kind === ts5.SyntaxKind.TrueKeyword) {
2911
2987
  return { literal: true, value: true };
2912
2988
  }
2913
- if (initializer.kind === ts4.SyntaxKind.FalseKeyword) {
2989
+ if (initializer.kind === ts5.SyntaxKind.FalseKeyword) {
2914
2990
  return { literal: true, value: false };
2915
2991
  }
2916
- if (initializer.kind === ts4.SyntaxKind.NullKeyword) {
2992
+ if (initializer.kind === ts5.SyntaxKind.NullKeyword) {
2917
2993
  return { literal: true, value: null };
2918
2994
  }
2919
2995
  return { literal: false, text: initializer.getText() };
@@ -2934,7 +3010,7 @@ function registerReferencedTypes(type, ctx, depth = 0) {
2934
3010
  return;
2935
3011
  if (ctx.registeredTypes.has(type))
2936
3012
  return;
2937
- const isPrimitive = type.flags & (ts4.TypeFlags.String | ts4.TypeFlags.Number | ts4.TypeFlags.Boolean | ts4.TypeFlags.Void | ts4.TypeFlags.Undefined | ts4.TypeFlags.Null | ts4.TypeFlags.Any | ts4.TypeFlags.Unknown | ts4.TypeFlags.Never | ts4.TypeFlags.StringLiteral | ts4.TypeFlags.NumberLiteral | ts4.TypeFlags.BooleanLiteral);
3013
+ const isPrimitive = type.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.Boolean | ts5.TypeFlags.Void | ts5.TypeFlags.Undefined | ts5.TypeFlags.Null | ts5.TypeFlags.Any | ts5.TypeFlags.Unknown | ts5.TypeFlags.Never | ts5.TypeFlags.StringLiteral | ts5.TypeFlags.NumberLiteral | ts5.TypeFlags.BooleanLiteral);
2938
3014
  if (!isPrimitive) {
2939
3015
  ctx.registeredTypes.add(type);
2940
3016
  }
@@ -2960,7 +3036,7 @@ function registerReferencedTypes(type, ctx, depth = 0) {
2960
3036
  if (typeSymbol && ctx.shouldExpandExternal && !typeSymbol.getName().startsWith("__") && !ctx.shouldExpandExternal(typeSymbol)) {
2961
3037
  return;
2962
3038
  }
2963
- if (type.flags & ts4.TypeFlags.Object) {
3039
+ if (type.flags & ts5.TypeFlags.Object) {
2964
3040
  const props = type.getProperties();
2965
3041
  const limit = ctx.maxProperties;
2966
3042
  if (props.length > limit && ctx.onTruncation) {
@@ -2975,10 +3051,10 @@ function registerReferencedTypes(type, ctx, depth = 0) {
2975
3051
  }
2976
3052
 
2977
3053
  // src/serializers/context.ts
2978
- import ts6 from "typescript";
3054
+ import ts7 from "typescript";
2979
3055
 
2980
3056
  // src/ast/registry.ts
2981
- import ts5 from "typescript";
3057
+ import ts6 from "typescript";
2982
3058
  var BUILTINS = new Set([
2983
3059
  "Array",
2984
3060
  "ArrayBuffer",
@@ -3082,18 +3158,19 @@ class TypeRegistry {
3082
3158
  return;
3083
3159
  if (name.startsWith("__"))
3084
3160
  return;
3085
- if (symbol.flags & ts5.SymbolFlags.EnumMember)
3161
+ if (symbol.flags & ts6.SymbolFlags.EnumMember)
3086
3162
  return;
3087
- if (symbol.flags & ts5.SymbolFlags.TypeParameter)
3163
+ if (symbol.flags & ts6.SymbolFlags.TypeParameter)
3088
3164
  return;
3089
- if (symbol.flags & ts5.SymbolFlags.Method)
3165
+ if (symbol.flags & ts6.SymbolFlags.Method)
3090
3166
  return;
3091
- if (symbol.flags & ts5.SymbolFlags.Function)
3167
+ if (symbol.flags & ts6.SymbolFlags.Function)
3092
3168
  return;
3093
3169
  if (isGenericTypeParameter(name))
3094
3170
  return;
3095
- if (this.has(name))
3096
- return name;
3171
+ const id = resolveTypeId(symbol, ctx);
3172
+ if (this.has(id))
3173
+ return id;
3097
3174
  if (ctx.shouldExpandExternal && !ctx.shouldExpandExternal(symbol)) {
3098
3175
  const origin = getTypeOrigin(type, ctx.typeChecker);
3099
3176
  const schema = {
@@ -3102,47 +3179,47 @@ class TypeRegistry {
3102
3179
  if (origin)
3103
3180
  schema["x-ts-package"] = origin;
3104
3181
  this.add({
3105
- id: name,
3182
+ id,
3106
3183
  name,
3107
3184
  kind: "external",
3108
3185
  external: true,
3109
3186
  schema
3110
3187
  });
3111
- return name;
3188
+ return id;
3112
3189
  }
3113
- if (this.processing.has(name))
3114
- return name;
3115
- this.processing.add(name);
3190
+ if (this.processing.has(id))
3191
+ return id;
3192
+ this.processing.add(id);
3116
3193
  try {
3117
- const specType = this.buildSpecType(type, symbol, ctx);
3194
+ const specType = this.buildSpecType(type, symbol, id, ctx);
3118
3195
  if (specType) {
3119
3196
  this.add(specType);
3120
3197
  return specType.id;
3121
3198
  }
3122
3199
  } finally {
3123
- this.processing.delete(name);
3200
+ this.processing.delete(id);
3124
3201
  }
3125
3202
  return;
3126
3203
  }
3127
- buildSpecType(type, symbol, ctx) {
3204
+ buildSpecType(type, symbol, id, ctx) {
3128
3205
  const name = symbol.getName();
3129
3206
  const decl = symbol.declarations?.[0];
3130
3207
  const checker = ctx.typeChecker;
3131
3208
  let kind = "type";
3132
3209
  const external = decl ? isExternalType(decl) : false;
3133
3210
  if (decl) {
3134
- if (ts5.isClassDeclaration(decl))
3211
+ if (ts6.isClassDeclaration(decl))
3135
3212
  kind = "class";
3136
- else if (ts5.isInterfaceDeclaration(decl))
3213
+ else if (ts6.isInterfaceDeclaration(decl))
3137
3214
  kind = "interface";
3138
- else if (ts5.isEnumDeclaration(decl))
3215
+ else if (ts6.isEnumDeclaration(decl))
3139
3216
  kind = "enum";
3140
3217
  }
3141
3218
  if (external) {
3142
3219
  kind = "external";
3143
3220
  }
3144
3221
  let schema = buildSchema(type, checker, ctx);
3145
- if (this.isSelfRef(schema, name)) {
3222
+ if (this.isSelfRef(schema, id)) {
3146
3223
  schema = this.resolveSelRefSchema(type, checker, ctx);
3147
3224
  }
3148
3225
  if (kind === "enum") {
@@ -3151,18 +3228,18 @@ class TypeRegistry {
3151
3228
  schema = enumSchema;
3152
3229
  }
3153
3230
  }
3154
- if (kind === "type" && decl && ts5.isTypeAliasDeclaration(decl) && shouldEmitAliasTypeText(decl.type) && typeof schema === "object" && schema !== null && !("x-ts-type" in schema)) {
3155
- const text = renderTypeText(type, checker, decl, ts5.TypeFormatFlags.InTypeAlias);
3231
+ if (kind === "type" && decl && ts6.isTypeAliasDeclaration(decl) && shouldEmitAliasTypeText(decl.type) && typeof schema === "object" && schema !== null && !("x-ts-type" in schema)) {
3232
+ const text = renderTypeText(type, checker, decl, ts6.TypeFormatFlags.InTypeAlias);
3156
3233
  if (!PRIMITIVES.has(text) && text !== name) {
3157
3234
  schema["x-ts-type"] = text;
3158
3235
  }
3159
3236
  }
3160
3237
  let typeParameters;
3161
- if (decl && (ts5.isTypeAliasDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isClassDeclaration(decl))) {
3238
+ if (decl && (ts6.isTypeAliasDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isClassDeclaration(decl))) {
3162
3239
  typeParameters = extractTypeParameters(decl, checker);
3163
3240
  }
3164
3241
  return {
3165
- id: name,
3242
+ id,
3166
3243
  name,
3167
3244
  kind,
3168
3245
  ...typeParameters && typeParameters.length > 0 ? { typeParameters } : {},
@@ -3179,14 +3256,14 @@ class TypeRegistry {
3179
3256
  resolveSelRefSchema(type, checker, ctx) {
3180
3257
  if (type.isUnion()) {
3181
3258
  const types = type.types;
3182
- const allStringLiterals = types.every((t) => t.flags & ts5.TypeFlags.StringLiteral);
3259
+ const allStringLiterals = types.every((t) => t.flags & ts6.TypeFlags.StringLiteral);
3183
3260
  if (allStringLiterals) {
3184
3261
  return {
3185
3262
  type: "string",
3186
3263
  enum: types.map((t) => t.value)
3187
3264
  };
3188
3265
  }
3189
- const allNumberLiterals = types.every((t) => t.flags & ts5.TypeFlags.NumberLiteral);
3266
+ const allNumberLiterals = types.every((t) => t.flags & ts6.TypeFlags.NumberLiteral);
3190
3267
  if (allNumberLiterals) {
3191
3268
  return {
3192
3269
  type: "number",
@@ -3221,18 +3298,18 @@ class TypeRegistry {
3221
3298
  const elementType = checker.getTypeArguments(type)?.[0];
3222
3299
  return elementType ? { type: "array", items: buildSchema(elementType, checker, ctx) } : { type: "array" };
3223
3300
  }
3224
- if (type.flags & ts5.TypeFlags.Conditional) {
3301
+ if (type.flags & ts6.TypeFlags.Conditional) {
3225
3302
  return { "x-ts-type": renderTypeText(type, checker) };
3226
3303
  }
3227
3304
  const constraint = checker.getBaseConstraintOfType(type);
3228
- const primitive = constraint && constraint.flags & ts5.TypeFlags.StringLike ? "string" : constraint && constraint.flags & ts5.TypeFlags.NumberLike ? "number" : constraint && constraint.flags & ts5.TypeFlags.BooleanLike ? "boolean" : undefined;
3305
+ const primitive = constraint && constraint.flags & ts6.TypeFlags.StringLike ? "string" : constraint && constraint.flags & ts6.TypeFlags.NumberLike ? "number" : constraint && constraint.flags & ts6.TypeFlags.BooleanLike ? "boolean" : undefined;
3229
3306
  if (primitive) {
3230
3307
  return { type: primitive, "x-ts-type": renderTypeText(type, checker) };
3231
3308
  }
3232
3309
  return this.buildObjectSchemaFromProperties(type, checker, ctx);
3233
3310
  }
3234
3311
  buildEnumSchema(symbol, checker) {
3235
- const decl = symbol.declarations?.find(ts5.isEnumDeclaration);
3312
+ const decl = symbol.declarations?.find(ts6.isEnumDeclaration);
3236
3313
  if (!decl)
3237
3314
  return;
3238
3315
  const members = [];
@@ -3259,8 +3336,8 @@ class TypeRegistry {
3259
3336
  buildObjectSchemaFromProperties(type, checker, ctx) {
3260
3337
  const properties = type.getProperties();
3261
3338
  const indexInfos = checker.getIndexInfosOfType(type);
3262
- const stringIndex = indexInfos.find((i) => i.keyType.flags & ts5.TypeFlags.String);
3263
- const numberIndex = indexInfos.find((i) => i.keyType.flags & ts5.TypeFlags.Number);
3339
+ const stringIndex = indexInfos.find((i) => i.keyType.flags & ts6.TypeFlags.String);
3340
+ const numberIndex = indexInfos.find((i) => i.keyType.flags & ts6.TypeFlags.Number);
3264
3341
  if (properties.length === 0 && !stringIndex && !numberIndex) {
3265
3342
  return { type: checker.typeToString(type) };
3266
3343
  }
@@ -3268,8 +3345,8 @@ class TypeRegistry {
3268
3345
  const required = [];
3269
3346
  const limit = ctx.maxProperties;
3270
3347
  const isArrayLike = checker.isArrayType(type) || checker.isTupleType(type) || type.symbol?.getName() === "Array" && type.symbol?.getDeclarations()?.[0]?.getSourceFile()?.fileName?.includes("/typescript/lib/lib.");
3271
- const isStringLike = type.flags & ts5.TypeFlags.StringLike;
3272
- const isNumberLike = type.flags & ts5.TypeFlags.NumberLike;
3348
+ const isStringLike = type.flags & ts6.TypeFlags.StringLike;
3349
+ const isNumberLike = type.flags & ts6.TypeFlags.NumberLike;
3273
3350
  const included = properties.filter((prop) => {
3274
3351
  const propName = prop.getName();
3275
3352
  if (propName.startsWith("__@"))
@@ -3289,7 +3366,7 @@ class TypeRegistry {
3289
3366
  for (const prop of included.slice(0, limit)) {
3290
3367
  const propName = prop.getName();
3291
3368
  const rawPropType = checker.getTypeOfSymbol(prop);
3292
- const propType = prop.flags & ts5.SymbolFlags.Optional ? stripUndefinedFromType(rawPropType, checker) : rawPropType;
3369
+ const propType = prop.flags & ts6.SymbolFlags.Optional ? stripUndefinedFromType(rawPropType, checker) : rawPropType;
3293
3370
  this.registerType(propType, ctx);
3294
3371
  let propSchema = buildSchema(propType, checker, ctx);
3295
3372
  const docComment = prop.getDocumentationComment(checker);
@@ -3306,7 +3383,7 @@ class TypeRegistry {
3306
3383
  }
3307
3384
  propSchema = decoratePropertySchema(propSchema, prop, propType, checker);
3308
3385
  props[propName] = propSchema;
3309
- if (!(prop.flags & ts5.SymbolFlags.Optional)) {
3386
+ if (!(prop.flags & ts6.SymbolFlags.Optional)) {
3310
3387
  required.push(propName);
3311
3388
  }
3312
3389
  }
@@ -3340,7 +3417,11 @@ function createContext(program, sourceFile, options = {}) {
3340
3417
  includePrivate: options.includePrivate ?? false,
3341
3418
  maxProperties: options.maxProperties ?? 500,
3342
3419
  onTruncation: options.onTruncation,
3343
- shouldExpandExternal: options.shouldExpandExternal
3420
+ shouldExpandExternal: options.shouldExpandExternal,
3421
+ typeIds: new Map,
3422
+ declIds: new Map,
3423
+ idOwner: new Map,
3424
+ workspacePackages: options.workspacePackages ?? new Map
3344
3425
  };
3345
3426
  }
3346
3427
  function getInheritedMembers(classType, ownMemberNames, ctx, isStatic = false) {
@@ -3409,15 +3490,15 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
3409
3490
  const type = checker.getTypeOfSymbol(symbol);
3410
3491
  registerReferencedTypes(type, ctx);
3411
3492
  let visibility;
3412
- if (decl && ts6.canHaveModifiers(decl)) {
3413
- const modifiers = ts6.getModifiers(decl);
3493
+ if (decl && ts7.canHaveModifiers(decl)) {
3494
+ const modifiers = ts7.getModifiers(decl);
3414
3495
  if (modifiers) {
3415
3496
  for (const mod of modifiers) {
3416
- if (mod.kind === ts6.SyntaxKind.PrivateKeyword)
3497
+ if (mod.kind === ts7.SyntaxKind.PrivateKeyword)
3417
3498
  visibility = "private";
3418
- else if (mod.kind === ts6.SyntaxKind.ProtectedKeyword)
3499
+ else if (mod.kind === ts7.SyntaxKind.ProtectedKeyword)
3419
3500
  visibility = "protected";
3420
- else if (mod.kind === ts6.SyntaxKind.PublicKeyword)
3501
+ else if (mod.kind === ts7.SyntaxKind.PublicKeyword)
3421
3502
  visibility = "public";
3422
3503
  }
3423
3504
  }
@@ -3429,17 +3510,17 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
3429
3510
  const callSigs = type.getCallSignatures();
3430
3511
  if (callSigs.length > 0) {
3431
3512
  kind = "method";
3432
- } else if (ts6.isGetAccessorDeclaration(decl)) {
3513
+ } else if (ts7.isGetAccessorDeclaration(decl)) {
3433
3514
  kind = "getter";
3434
- } else if (ts6.isSetAccessorDeclaration(decl)) {
3515
+ } else if (ts7.isSetAccessorDeclaration(decl)) {
3435
3516
  kind = "setter";
3436
3517
  }
3437
3518
  const flags = {};
3438
3519
  if (isStatic)
3439
3520
  flags.static = true;
3440
- if (decl && ts6.canHaveModifiers(decl)) {
3441
- const modifiers = ts6.getModifiers(decl);
3442
- if (modifiers?.some((m) => m.kind === ts6.SyntaxKind.ReadonlyKeyword)) {
3521
+ if (decl && ts7.canHaveModifiers(decl)) {
3522
+ const modifiers = ts7.getModifiers(decl);
3523
+ if (modifiers?.some((m) => m.kind === ts7.SyntaxKind.ReadonlyKeyword)) {
3443
3524
  flags.readonly = true;
3444
3525
  }
3445
3526
  }
@@ -3516,11 +3597,11 @@ function serializeClass(node, ctx) {
3516
3597
  const memberName = getMemberName(member);
3517
3598
  if (memberName?.startsWith("#"))
3518
3599
  continue;
3519
- if (ts7.isPropertyDeclaration(member)) {
3600
+ if (ts8.isPropertyDeclaration(member)) {
3520
3601
  const propMember = serializeProperty(member, ctx);
3521
3602
  if (propMember)
3522
3603
  members.push(propMember);
3523
- } else if (ts7.isMethodDeclaration(member)) {
3604
+ } else if (ts8.isMethodDeclaration(member)) {
3524
3605
  const methodMember = serializeMethod(member, ctx);
3525
3606
  if (methodMember?.name) {
3526
3607
  if (!methodsByName.has(methodMember.name)) {
@@ -3537,11 +3618,11 @@ function serializeClass(node, ctx) {
3537
3618
  }
3538
3619
  }
3539
3620
  }
3540
- } else if (ts7.isConstructorDeclaration(member)) {
3621
+ } else if (ts8.isConstructorDeclaration(member)) {
3541
3622
  const ctorSig = serializeConstructor(member, ctx);
3542
3623
  if (ctorSig)
3543
3624
  signatures.push(ctorSig);
3544
- } else if (ts7.isGetAccessorDeclaration(member) || ts7.isSetAccessorDeclaration(member)) {
3625
+ } else if (ts8.isGetAccessorDeclaration(member) || ts8.isSetAccessorDeclaration(member)) {
3545
3626
  const accessorMember = serializeAccessor(member, ctx);
3546
3627
  if (accessorMember)
3547
3628
  members.push(accessorMember);
@@ -3565,8 +3646,8 @@ function serializeClass(node, ctx) {
3565
3646
  const extendsClause = getExtendsClause(node, checker);
3566
3647
  const implementsClause = getImplementsClause(node, checker);
3567
3648
  const classFlags = {};
3568
- const classModifiers = ts7.getModifiers(node);
3569
- if (classModifiers?.some((m) => m.kind === ts7.SyntaxKind.AbstractKeyword)) {
3649
+ const classModifiers = ts8.getModifiers(node);
3650
+ if (classModifiers?.some((m) => m.kind === ts8.SyntaxKind.AbstractKeyword)) {
3570
3651
  classFlags.abstract = true;
3571
3652
  }
3572
3653
  return {
@@ -3587,37 +3668,37 @@ function serializeClass(node, ctx) {
3587
3668
  };
3588
3669
  }
3589
3670
  function getMemberName(member) {
3590
- if (ts7.isConstructorDeclaration(member))
3671
+ if (ts8.isConstructorDeclaration(member))
3591
3672
  return "constructor";
3592
3673
  if (!member.name)
3593
3674
  return;
3594
- if (ts7.isIdentifier(member.name))
3675
+ if (ts8.isIdentifier(member.name))
3595
3676
  return member.name.text;
3596
- if (ts7.isPrivateIdentifier(member.name))
3677
+ if (ts8.isPrivateIdentifier(member.name))
3597
3678
  return member.name.text;
3598
3679
  return member.name.getText();
3599
3680
  }
3600
3681
  function getVisibility(member) {
3601
- const modifiers = ts7.canHaveModifiers(member) ? ts7.getModifiers(member) : undefined;
3682
+ const modifiers = ts8.canHaveModifiers(member) ? ts8.getModifiers(member) : undefined;
3602
3683
  if (!modifiers)
3603
3684
  return;
3604
3685
  for (const mod of modifiers) {
3605
- if (mod.kind === ts7.SyntaxKind.PrivateKeyword)
3686
+ if (mod.kind === ts8.SyntaxKind.PrivateKeyword)
3606
3687
  return "private";
3607
- if (mod.kind === ts7.SyntaxKind.ProtectedKeyword)
3688
+ if (mod.kind === ts8.SyntaxKind.ProtectedKeyword)
3608
3689
  return "protected";
3609
- if (mod.kind === ts7.SyntaxKind.PublicKeyword)
3690
+ if (mod.kind === ts8.SyntaxKind.PublicKeyword)
3610
3691
  return "public";
3611
3692
  }
3612
3693
  return;
3613
3694
  }
3614
3695
  function isStatic(member) {
3615
- const modifiers = ts7.canHaveModifiers(member) ? ts7.getModifiers(member) : undefined;
3616
- return modifiers?.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword) ?? false;
3696
+ const modifiers = ts8.canHaveModifiers(member) ? ts8.getModifiers(member) : undefined;
3697
+ return modifiers?.some((m) => m.kind === ts8.SyntaxKind.StaticKeyword) ?? false;
3617
3698
  }
3618
3699
  function isReadonly(member) {
3619
- const modifiers = ts7.canHaveModifiers(member) ? ts7.getModifiers(member) : undefined;
3620
- return modifiers?.some((m) => m.kind === ts7.SyntaxKind.ReadonlyKeyword) ?? false;
3700
+ const modifiers = ts8.canHaveModifiers(member) ? ts8.getModifiers(member) : undefined;
3701
+ return modifiers?.some((m) => m.kind === ts8.SyntaxKind.ReadonlyKeyword) ?? false;
3621
3702
  }
3622
3703
  function serializeProperty(node, ctx) {
3623
3704
  const { typeChecker: checker } = ctx;
@@ -3675,11 +3756,11 @@ function serializeMethod(node, ctx) {
3675
3756
  if (node.asteriskToken)
3676
3757
  flags.generator = true;
3677
3758
  flags.methodSyntax = true;
3678
- const modifiers = ts7.getModifiers(node);
3679
- if (modifiers?.some((m) => m.kind === ts7.SyntaxKind.AsyncKeyword)) {
3759
+ const modifiers = ts8.getModifiers(node);
3760
+ if (modifiers?.some((m) => m.kind === ts8.SyntaxKind.AsyncKeyword)) {
3680
3761
  flags.async = true;
3681
3762
  }
3682
- if (modifiers?.some((m) => m.kind === ts7.SyntaxKind.AbstractKeyword)) {
3763
+ if (modifiers?.some((m) => m.kind === ts8.SyntaxKind.AbstractKeyword)) {
3683
3764
  flags.abstract = true;
3684
3765
  }
3685
3766
  const symbol = checker.getSymbolAtLocation(node.name ?? node);
@@ -3716,7 +3797,7 @@ function serializeConstructorSignature(node, sig, ctx) {
3716
3797
  }
3717
3798
  function serializeInheritedConstructors(node, ctx) {
3718
3799
  const { typeChecker: checker } = ctx;
3719
- const hasExtends = node.heritageClauses?.some((c) => c.token === ts7.SyntaxKind.ExtendsKeyword);
3800
+ const hasExtends = node.heritageClauses?.some((c) => c.token === ts8.SyntaxKind.ExtendsKeyword);
3720
3801
  if (!hasExtends)
3721
3802
  return [];
3722
3803
  const symbol = checker.getSymbolAtLocation(node.name ?? node);
@@ -3725,11 +3806,11 @@ function serializeInheritedConstructors(node, ctx) {
3725
3806
  const staticType = checker.getTypeOfSymbolAtLocation(symbol, node);
3726
3807
  const ctorSigs = staticType.getConstructSignatures().filter((sig) => {
3727
3808
  const decl = sig.getDeclaration();
3728
- return decl !== undefined && ts7.isConstructorDeclaration(decl);
3809
+ return decl !== undefined && ts8.isConstructorDeclaration(decl);
3729
3810
  });
3730
3811
  return ctorSigs.map((sig, index) => {
3731
3812
  const decl = sig.getDeclaration();
3732
- const owner = ts7.isClassLike(decl.parent) ? decl.parent.name?.text : undefined;
3813
+ const owner = ts8.isClassLike(decl.parent) ? decl.parent.name?.text : undefined;
3733
3814
  return {
3734
3815
  ...serializeConstructorSignature(decl, sig, ctx),
3735
3816
  ...owner ? { inheritedFrom: owner } : {},
@@ -3750,12 +3831,12 @@ function serializeAccessor(node, ctx) {
3750
3831
  const type = checker.getTypeAtLocation(node);
3751
3832
  const schema = buildSchema(type, checker, ctx);
3752
3833
  registerReferencedTypes(type, ctx);
3753
- const kind = ts7.isGetAccessorDeclaration(node) ? "getter" : "setter";
3834
+ const kind = ts8.isGetAccessorDeclaration(node) ? "getter" : "setter";
3754
3835
  const flags = {};
3755
3836
  if (isStatic(node))
3756
3837
  flags.static = true;
3757
3838
  let signatures;
3758
- if (ts7.isSetAccessorDeclaration(node) && node.parameters.length > 0) {
3839
+ if (ts8.isSetAccessorDeclaration(node) && node.parameters.length > 0) {
3759
3840
  const param = node.parameters[0];
3760
3841
  const paramName = param.name.getText();
3761
3842
  const paramType = checker.getTypeAtLocation(param);
@@ -3787,7 +3868,7 @@ function getExtendsClause(node, checker) {
3787
3868
  if (!node.heritageClauses)
3788
3869
  return;
3789
3870
  for (const clause of node.heritageClauses) {
3790
- if (clause.token === ts7.SyntaxKind.ExtendsKeyword) {
3871
+ if (clause.token === ts8.SyntaxKind.ExtendsKeyword) {
3791
3872
  const expr = clause.types[0];
3792
3873
  if (expr) {
3793
3874
  const type = checker.getTypeAtLocation(expr);
@@ -3802,7 +3883,7 @@ function getImplementsClause(node, checker) {
3802
3883
  if (!node.heritageClauses)
3803
3884
  return;
3804
3885
  for (const clause of node.heritageClauses) {
3805
- if (clause.token === ts7.SyntaxKind.ImplementsKeyword) {
3886
+ if (clause.token === ts8.SyntaxKind.ImplementsKeyword) {
3806
3887
  return clause.types.map((expr) => {
3807
3888
  const type = checker.getTypeAtLocation(expr);
3808
3889
  const symbol = type.getSymbol();
@@ -3856,16 +3937,16 @@ function serializeEnum(node, ctx) {
3856
3937
  }
3857
3938
 
3858
3939
  // src/serializers/functions.ts
3859
- import ts8 from "typescript";
3940
+ import ts9 from "typescript";
3860
3941
  function buildReturnSchema(sig, ctx) {
3861
3942
  const returnType = ctx.typeChecker.getReturnTypeOfSignature(sig);
3862
3943
  registerReferencedTypes(returnType, ctx);
3863
3944
  const schema = buildSchema(returnType, ctx.typeChecker, ctx);
3864
3945
  const declaration = sig.getDeclaration();
3865
- if (declaration && ts8.isFunctionLike(declaration) && declaration.type) {
3946
+ if (declaration && ts9.isFunctionLike(declaration) && declaration.type) {
3866
3947
  const returnTypeNode = declaration.type;
3867
- if (ts8.isTypePredicateNode(returnTypeNode)) {
3868
- const parameterName = ts8.isIdentifier(returnTypeNode.parameterName) ? returnTypeNode.parameterName.text : returnTypeNode.parameterName.getText();
3948
+ if (ts9.isTypePredicateNode(returnTypeNode)) {
3949
+ const parameterName = ts9.isIdentifier(returnTypeNode.parameterName) ? returnTypeNode.parameterName.text : returnTypeNode.parameterName.getText();
3869
3950
  let predicateTypeSchema = { type: "unknown" };
3870
3951
  if (returnTypeNode.type) {
3871
3952
  const predicateType = ctx.typeChecker.getTypeAtLocation(returnTypeNode.type);
@@ -3909,8 +3990,8 @@ function serializeFunctionExport(node, ctx, nameOverride) {
3909
3990
  };
3910
3991
  });
3911
3992
  const flags = {};
3912
- const modifiers = ts8.getModifiers(node);
3913
- if (modifiers?.some((m) => m.kind === ts8.SyntaxKind.AsyncKeyword)) {
3993
+ const modifiers = ts9.getModifiers(node);
3994
+ if (modifiers?.some((m) => m.kind === ts9.SyntaxKind.AsyncKeyword)) {
3914
3995
  flags.async = true;
3915
3996
  }
3916
3997
  if (node.asteriskToken) {
@@ -3932,7 +4013,7 @@ function serializeFunctionExport(node, ctx, nameOverride) {
3932
4013
  }
3933
4014
 
3934
4015
  // src/serializers/interfaces.ts
3935
- import ts9 from "typescript";
4016
+ import ts10 from "typescript";
3936
4017
  function serializeInterface(node, ctx) {
3937
4018
  const { typeChecker: checker } = ctx;
3938
4019
  const symbol = checker.getSymbolAtLocation(node.name ?? node);
@@ -3945,11 +4026,11 @@ function serializeInterface(node, ctx) {
3945
4026
  const methodsByName = new Map;
3946
4027
  let callSignatureMember = null;
3947
4028
  for (const member of node.members) {
3948
- if (ts9.isPropertySignature(member)) {
4029
+ if (ts10.isPropertySignature(member)) {
3949
4030
  const propMember = serializePropertySignature(member, ctx);
3950
4031
  if (propMember)
3951
4032
  members.push(propMember);
3952
- } else if (ts9.isMethodSignature(member)) {
4033
+ } else if (ts10.isMethodSignature(member)) {
3953
4034
  const methodMember = serializeMethodSignature(member, ctx);
3954
4035
  if (methodMember?.name && methodMember.signatures) {
3955
4036
  const existing = methodsByName.get(methodMember.name);
@@ -3970,7 +4051,7 @@ function serializeInterface(node, ctx) {
3970
4051
  methodsByName.set(methodMember.name, methodMember);
3971
4052
  }
3972
4053
  }
3973
- } else if (ts9.isCallSignatureDeclaration(member)) {
4054
+ } else if (ts10.isCallSignatureDeclaration(member)) {
3974
4055
  const callSig = serializeCallSignature(member, ctx);
3975
4056
  if (callSig?.signatures) {
3976
4057
  if (callSignatureMember?.signatures) {
@@ -3993,7 +4074,7 @@ function serializeInterface(node, ctx) {
3993
4074
  callSignatureMember = callSig;
3994
4075
  }
3995
4076
  }
3996
- } else if (ts9.isIndexSignatureDeclaration(member)) {
4077
+ } else if (ts10.isIndexSignatureDeclaration(member)) {
3997
4078
  const indexMember = serializeIndexSignature(member, ctx);
3998
4079
  if (indexMember)
3999
4080
  members.push(indexMember);
@@ -4031,7 +4112,7 @@ function serializePropertySignature(node, ctx) {
4031
4112
  const flags = {};
4032
4113
  if (node.questionToken)
4033
4114
  flags.optional = true;
4034
- if (node.modifiers?.some((m) => m.kind === ts9.SyntaxKind.ReadonlyKeyword)) {
4115
+ if (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ReadonlyKeyword)) {
4035
4116
  flags.readonly = true;
4036
4117
  }
4037
4118
  const symbol = checker.getSymbolAtLocation(node.name);
@@ -4119,7 +4200,7 @@ function getInterfaceExtends(node, checker) {
4119
4200
  if (!node.heritageClauses)
4120
4201
  return;
4121
4202
  for (const clause of node.heritageClauses) {
4122
- if (clause.token === ts9.SyntaxKind.ExtendsKeyword && clause.types.length > 0) {
4203
+ if (clause.token === ts10.SyntaxKind.ExtendsKeyword && clause.types.length > 0) {
4123
4204
  const names = clause.types.map((expr) => {
4124
4205
  const type = checker.getTypeAtLocation(expr);
4125
4206
  return type.getSymbol()?.getName() ?? expr.expression.getText();
@@ -4131,7 +4212,7 @@ function getInterfaceExtends(node, checker) {
4131
4212
  }
4132
4213
 
4133
4214
  // src/serializers/type-aliases.ts
4134
- import ts10 from "typescript";
4215
+ import ts11 from "typescript";
4135
4216
  function buildIntersectionSchemaFromNode(node, ctx) {
4136
4217
  const types = node.types;
4137
4218
  const schemas = [];
@@ -4159,14 +4240,14 @@ function serializeTypeAlias(node, ctx) {
4159
4240
  registerReferencedTypes(type, ctx);
4160
4241
  let schema;
4161
4242
  let members;
4162
- if (ts10.isIntersectionTypeNode(node.type)) {
4243
+ if (ts11.isIntersectionTypeNode(node.type)) {
4163
4244
  schema = buildIntersectionSchemaFromNode(node.type, ctx);
4164
4245
  if (type.getProperties().length > 0 && type.getCallSignatures().length === 0) {
4165
4246
  members = serializeResolvedMembers(type, node, ctx);
4166
4247
  }
4167
4248
  } else if (isInlineFunctionAlias(node.type) && type.getCallSignatures().length > 0) {
4168
4249
  schema = buildFunctionSchema(type.getCallSignatures(), ctx.typeChecker, ctx);
4169
- } else if ((ts10.isMappedTypeNode(node.type) || ts10.isConditionalTypeNode(node.type)) && type.getProperties().length > 0 && type.getCallSignatures().length === 0 && !(type.flags & ts10.TypeFlags.Conditional) && !(type.flags & (ts10.TypeFlags.StringLike | ts10.TypeFlags.NumberLike))) {
4250
+ } else if ((ts11.isMappedTypeNode(node.type) || ts11.isConditionalTypeNode(node.type)) && type.getProperties().length > 0 && type.getCallSignatures().length === 0 && !(type.flags & ts11.TypeFlags.Conditional) && !(type.flags & (ts11.TypeFlags.StringLike | ts11.TypeFlags.NumberLike))) {
4170
4251
  schema = buildObjectSchema(type.getProperties(), ctx.typeChecker, ctx, type);
4171
4252
  members = serializeResolvedMembers(type, node, ctx);
4172
4253
  } else {
@@ -4176,7 +4257,7 @@ function serializeTypeAlias(node, ctx) {
4176
4257
  }
4177
4258
  }
4178
4259
  if (shouldEmitAliasTypeText(node.type) && typeof schema === "object" && schema !== null && !("x-ts-type" in schema)) {
4179
- const text = renderTypeText(type, ctx.typeChecker, node, ts10.TypeFormatFlags.InTypeAlias);
4260
+ const text = renderTypeText(type, ctx.typeChecker, node, ts11.TypeFormatFlags.InTypeAlias);
4180
4261
  if (!PRIMITIVES.has(text) && text !== name) {
4181
4262
  schema["x-ts-type"] = text;
4182
4263
  }
@@ -4197,12 +4278,12 @@ function serializeTypeAlias(node, ctx) {
4197
4278
  }
4198
4279
  function isObjectShapedAlias(type, ctx) {
4199
4280
  const { typeChecker: checker } = ctx;
4200
- if (!(type.flags & ts10.TypeFlags.Object))
4281
+ if (!(type.flags & ts11.TypeFlags.Object))
4201
4282
  return false;
4202
4283
  if (checker.isArrayType(type) || checker.isTupleType(type))
4203
4284
  return false;
4204
4285
  const objectFlags = type.objectFlags;
4205
- if (!(objectFlags & ts10.ObjectFlags.Mapped)) {
4286
+ if (!(objectFlags & ts11.ObjectFlags.Mapped)) {
4206
4287
  const targetSymbol = type.target?.getSymbol?.() ?? type.getSymbol();
4207
4288
  if (isBuiltinSymbol(targetSymbol))
4208
4289
  return false;
@@ -4210,19 +4291,19 @@ function isObjectShapedAlias(type, ctx) {
4210
4291
  return type.getProperties().length > 0 && type.getCallSignatures().length === 0;
4211
4292
  }
4212
4293
  function isInlineFunctionAlias(typeNode) {
4213
- return ts10.isFunctionTypeNode(typeNode) || ts10.isTypeLiteralNode(typeNode) && typeNode.members.some(ts10.isCallSignatureDeclaration);
4294
+ return ts11.isFunctionTypeNode(typeNode) || ts11.isTypeLiteralNode(typeNode) && typeNode.members.some(ts11.isCallSignatureDeclaration);
4214
4295
  }
4215
4296
  function buildConditionalArmDocs(typeNode, checker) {
4216
4297
  const docs = new Map;
4217
- if (!ts10.isMappedTypeNode(typeNode) || !typeNode.type)
4298
+ if (!ts11.isMappedTypeNode(typeNode) || !typeNode.type)
4218
4299
  return docs;
4219
4300
  const literalKeys = (extendsType) => {
4220
4301
  const keys = [];
4221
4302
  const visit = (n) => {
4222
- if (ts10.isUnionTypeNode(n)) {
4303
+ if (ts11.isUnionTypeNode(n)) {
4223
4304
  for (const member of n.types)
4224
4305
  visit(member);
4225
- } else if (ts10.isLiteralTypeNode(n) && ts10.isStringLiteral(n.literal)) {
4306
+ } else if (ts11.isLiteralTypeNode(n) && ts11.isStringLiteral(n.literal)) {
4226
4307
  keys.push(n.literal.text);
4227
4308
  }
4228
4309
  };
@@ -4230,12 +4311,12 @@ function buildConditionalArmDocs(typeNode, checker) {
4230
4311
  return keys;
4231
4312
  };
4232
4313
  const armDoc = (armType) => {
4233
- if (!ts10.isTypeReferenceNode(armType))
4314
+ if (!ts11.isTypeReferenceNode(armType))
4234
4315
  return;
4235
4316
  const symbol = checker.getSymbolAtLocation(armType.typeName);
4236
4317
  if (!symbol)
4237
4318
  return;
4238
- const target = symbol.flags & ts10.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
4319
+ const target = symbol.flags & ts11.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
4239
4320
  const { deprecated, reason } = isSymbolDeprecated(target);
4240
4321
  const targetDecl = target.getDeclarations()?.[0];
4241
4322
  const description = targetDecl ? getJSDocComment(targetDecl, target, checker).description : undefined;
@@ -4244,7 +4325,7 @@ function buildConditionalArmDocs(typeNode, checker) {
4244
4325
  return { deprecated, deprecationReason: reason, description };
4245
4326
  };
4246
4327
  let current = typeNode.type;
4247
- while (current && ts10.isConditionalTypeNode(current)) {
4328
+ while (current && ts11.isConditionalTypeNode(current)) {
4248
4329
  const doc = armDoc(current.trueType);
4249
4330
  if (doc) {
4250
4331
  for (const key of literalKeys(current.extendsType)) {
@@ -4263,10 +4344,10 @@ function serializeResolvedMembers(type, node, ctx) {
4263
4344
  for (const prop of type.getProperties()) {
4264
4345
  const decl = prop.getDeclarations()?.[0] ?? node;
4265
4346
  const rawPropType = checker.getTypeOfSymbolAtLocation(prop, decl);
4266
- const propType = prop.flags & ts10.SymbolFlags.Optional ? stripUndefinedFromType(rawPropType, checker) : rawPropType;
4347
+ const propType = prop.flags & ts11.SymbolFlags.Optional ? stripUndefinedFromType(rawPropType, checker) : rawPropType;
4267
4348
  registerReferencedTypes(propType, ctx);
4268
4349
  const callSigs = propType.getCallSignatures();
4269
- const isMethodDecl = ts10.isMethodSignature(decl) || ts10.isMethodDeclaration(decl) || ts10.isFunctionDeclaration(decl);
4350
+ const isMethodDecl = ts11.isMethodSignature(decl) || ts11.isMethodDeclaration(decl) || ts11.isFunctionDeclaration(decl);
4270
4351
  const kind = callSigs.length > 0 && isMethodDecl ? "method" : "property";
4271
4352
  let { description, tags } = getJSDocComment(decl, prop, checker);
4272
4353
  let { deprecated, reason: deprecationReason } = isSymbolDeprecated(prop);
@@ -4284,11 +4365,11 @@ function serializeResolvedMembers(type, node, ctx) {
4284
4365
  ({ deprecated, reason: deprecationReason } = isSymbolDeprecated(armAlias));
4285
4366
  }
4286
4367
  const flags = {};
4287
- if (prop.flags & ts10.SymbolFlags.Optional)
4368
+ if (prop.flags & ts11.SymbolFlags.Optional)
4288
4369
  flags.optional = true;
4289
4370
  if (isReadonlyPropertySymbol(prop))
4290
4371
  flags.readonly = true;
4291
- if (prop.flags & ts10.SymbolFlags.Method)
4372
+ if (prop.flags & ts11.SymbolFlags.Method)
4292
4373
  flags.methodSyntax = true;
4293
4374
  const schema = kind === "property" ? decoratePropertySchema(buildSchema(propType, checker, ctx), prop, propType, checker) : decoratePropertySchema({ "x-ts-function": true }, prop, propType, checker);
4294
4375
  members.push({
@@ -5066,7 +5147,7 @@ async function getExport(options) {
5066
5147
  ctx.exportedIds = exportedIds;
5067
5148
  try {
5068
5149
  const originalDecls = targetSymbol.declarations ?? [];
5069
- const isNamespaceExportDecl = originalDecls.some((d) => ts11.isNamespaceExport(d) || ts11.isNamespaceImport(d));
5150
+ const isNamespaceExportDecl = originalDecls.some((d) => ts12.isNamespaceExport(d) || ts12.isNamespaceImport(d));
5070
5151
  if (isNamespaceExportDecl) {
5071
5152
  const spec2 = serializeNamespaceForGet(targetSymbol, exportName, ctx);
5072
5153
  const types2 = ctx.typeRegistry.getAll().map((t) => normalizeType(t));
@@ -5117,42 +5198,42 @@ function resolveExportTarget(symbol, checker) {
5117
5198
  let isTypeOnly = false;
5118
5199
  const declarations = symbol.declarations ?? [];
5119
5200
  for (const decl of declarations) {
5120
- if (ts11.isExportSpecifier(decl)) {
5201
+ if (ts12.isExportSpecifier(decl)) {
5121
5202
  if (decl.isTypeOnly)
5122
5203
  isTypeOnly = true;
5123
5204
  const exportDecl = decl.parent?.parent;
5124
- if (exportDecl && ts11.isExportDeclaration(exportDecl) && exportDecl.isTypeOnly) {
5205
+ if (exportDecl && ts12.isExportDeclaration(exportDecl) && exportDecl.isTypeOnly) {
5125
5206
  isTypeOnly = true;
5126
5207
  }
5127
5208
  }
5128
5209
  }
5129
- if (symbol.flags & ts11.SymbolFlags.Alias) {
5210
+ if (symbol.flags & ts12.SymbolFlags.Alias) {
5130
5211
  const aliased = checker.getAliasedSymbol(symbol);
5131
5212
  if (aliased && aliased !== symbol) {
5132
5213
  resolvedSymbol = aliased;
5133
5214
  }
5134
5215
  }
5135
5216
  const targetDeclarations = resolvedSymbol.declarations ?? [];
5136
- const declaration = resolvedSymbol.valueDeclaration || targetDeclarations.find((d) => d.kind !== ts11.SyntaxKind.ExportSpecifier) || targetDeclarations[0];
5217
+ const declaration = resolvedSymbol.valueDeclaration || targetDeclarations.find((d) => d.kind !== ts12.SyntaxKind.ExportSpecifier) || targetDeclarations[0];
5137
5218
  return { declaration, resolvedSymbol, isTypeOnly };
5138
5219
  }
5139
5220
  function serializeDeclaration(declaration, _exportSymbol, _targetSymbol, exportName, ctx, isTypeOnly) {
5140
5221
  let result = null;
5141
- if (ts11.isFunctionDeclaration(declaration)) {
5222
+ if (ts12.isFunctionDeclaration(declaration)) {
5142
5223
  result = serializeFunctionExport(declaration, ctx);
5143
- } else if (ts11.isClassDeclaration(declaration)) {
5224
+ } else if (ts12.isClassDeclaration(declaration)) {
5144
5225
  result = serializeClass(declaration, ctx);
5145
- } else if (ts11.isInterfaceDeclaration(declaration)) {
5226
+ } else if (ts12.isInterfaceDeclaration(declaration)) {
5146
5227
  result = serializeInterface(declaration, ctx);
5147
- } else if (ts11.isTypeAliasDeclaration(declaration)) {
5228
+ } else if (ts12.isTypeAliasDeclaration(declaration)) {
5148
5229
  result = serializeTypeAlias(declaration, ctx);
5149
- } else if (ts11.isEnumDeclaration(declaration)) {
5230
+ } else if (ts12.isEnumDeclaration(declaration)) {
5150
5231
  result = serializeEnum(declaration, ctx);
5151
- } else if (ts11.isVariableDeclaration(declaration)) {
5232
+ } else if (ts12.isVariableDeclaration(declaration)) {
5152
5233
  const varStatement = declaration.parent?.parent;
5153
- if (varStatement && ts11.isVariableStatement(varStatement)) {
5154
- if (declaration.initializer && (ts11.isArrowFunction(declaration.initializer) || ts11.isFunctionExpression(declaration.initializer))) {
5155
- const varName = ts11.isIdentifier(declaration.name) ? declaration.name.text : declaration.name.getText();
5234
+ if (varStatement && ts12.isVariableStatement(varStatement)) {
5235
+ if (declaration.initializer && (ts12.isArrowFunction(declaration.initializer) || ts12.isFunctionExpression(declaration.initializer))) {
5236
+ const varName = ts12.isIdentifier(declaration.name) ? declaration.name.text : declaration.name.getText();
5156
5237
  result = serializeFunctionExport(declaration.initializer, ctx, varName);
5157
5238
  } else {
5158
5239
  const checker = ctx.program.getTypeChecker();
@@ -5166,7 +5247,7 @@ function serializeDeclaration(declaration, _exportSymbol, _targetSymbol, exportN
5166
5247
  }
5167
5248
  }
5168
5249
  }
5169
- } else if (ts11.isNamespaceExport(declaration) || ts11.isModuleDeclaration(declaration) || ts11.isNamespaceImport(declaration) || ts11.isSourceFile(declaration)) {
5250
+ } else if (ts12.isNamespaceExport(declaration) || ts12.isModuleDeclaration(declaration) || ts12.isNamespaceImport(declaration) || ts12.isSourceFile(declaration)) {
5170
5251
  result = serializeNamespaceForGet(_exportSymbol, exportName, ctx);
5171
5252
  }
5172
5253
  if (result) {
@@ -5182,7 +5263,7 @@ function serializeDeclaration(declaration, _exportSymbol, _targetSymbol, exportN
5182
5263
  function serializeNamespaceForGet(symbol, exportName, ctx) {
5183
5264
  const checker = ctx.program.getTypeChecker();
5184
5265
  let targetSymbol = symbol;
5185
- if (symbol.flags & ts11.SymbolFlags.Alias) {
5266
+ if (symbol.flags & ts12.SymbolFlags.Alias) {
5186
5267
  const aliased = checker.getAliasedSymbol(symbol);
5187
5268
  if (aliased && aliased !== symbol) {
5188
5269
  targetSymbol = aliased;
@@ -5212,7 +5293,7 @@ function serializeNamespaceForGet(symbol, exportName, ctx) {
5212
5293
  }
5213
5294
  function detectExternalPackage(symbol, checker) {
5214
5295
  let targetSymbol = symbol;
5215
- if (symbol.flags & ts11.SymbolFlags.Alias) {
5296
+ if (symbol.flags & ts12.SymbolFlags.Alias) {
5216
5297
  const aliased = checker.getAliasedSymbol(symbol);
5217
5298
  if (aliased && aliased !== symbol) {
5218
5299
  targetSymbol = aliased;
@@ -5226,9 +5307,9 @@ function detectExternalPackage(symbol, checker) {
5226
5307
  if (match)
5227
5308
  return match[1];
5228
5309
  }
5229
- if (ts11.isExportSpecifier(decl)) {
5310
+ if (ts12.isExportSpecifier(decl)) {
5230
5311
  const exportDecl = decl.parent?.parent;
5231
- if (exportDecl && ts11.isExportDeclaration(exportDecl) && exportDecl.moduleSpecifier) {
5312
+ if (exportDecl && ts12.isExportDeclaration(exportDecl) && exportDecl.moduleSpecifier) {
5232
5313
  const moduleText = exportDecl.moduleSpecifier.text;
5233
5314
  if (!moduleText.startsWith(".") && !moduleText.startsWith("/")) {
5234
5315
  return moduleText;
@@ -5239,8 +5320,8 @@ function detectExternalPackage(symbol, checker) {
5239
5320
  return;
5240
5321
  }
5241
5322
  // src/primitives/list.ts
5242
- import * as path4 from "node:path";
5243
- import ts12 from "typescript";
5323
+ import * as path5 from "node:path";
5324
+ import ts13 from "typescript";
5244
5325
  async function listExports(options) {
5245
5326
  const { entryFile, baseDir, content } = options;
5246
5327
  const errors = [];
@@ -5283,16 +5364,16 @@ async function listExports(options) {
5283
5364
  }
5284
5365
  function extractExportItem(symbol, checker, entryFile, entrySourceFile) {
5285
5366
  const name = symbol.getName();
5286
- const isReexport = !!(symbol.flags & ts12.SymbolFlags.Alias);
5367
+ const isReexport = !!(symbol.flags & ts13.SymbolFlags.Alias);
5287
5368
  let targetSymbol = symbol;
5288
- if (symbol.flags & ts12.SymbolFlags.Alias) {
5369
+ if (symbol.flags & ts13.SymbolFlags.Alias) {
5289
5370
  const aliased = checker.getAliasedSymbol(symbol);
5290
5371
  if (aliased && aliased !== symbol) {
5291
5372
  targetSymbol = aliased;
5292
5373
  }
5293
5374
  }
5294
5375
  const declarations = targetSymbol.declarations ?? [];
5295
- const declaration = targetSymbol.valueDeclaration || declarations.find((d) => d.kind !== ts12.SyntaxKind.ExportSpecifier) || declarations[0];
5376
+ const declaration = targetSymbol.valueDeclaration || declarations.find((d) => d.kind !== ts13.SyntaxKind.ExportSpecifier) || declarations[0];
5296
5377
  if (!declaration) {
5297
5378
  return {
5298
5379
  name,
@@ -5302,11 +5383,11 @@ function extractExportItem(symbol, checker, entryFile, entrySourceFile) {
5302
5383
  reexport: true
5303
5384
  };
5304
5385
  }
5305
- if (ts12.isSourceFile(declaration)) {
5386
+ if (ts13.isSourceFile(declaration)) {
5306
5387
  return {
5307
5388
  name,
5308
5389
  kind: "namespace",
5309
- file: path4.relative(path4.dirname(entryFile), declaration.fileName),
5390
+ file: path5.relative(path5.dirname(entryFile), declaration.fileName),
5310
5391
  line: 1,
5311
5392
  reexport: true
5312
5393
  };
@@ -5320,7 +5401,7 @@ function extractExportItem(symbol, checker, entryFile, entrySourceFile) {
5320
5401
  return {
5321
5402
  name,
5322
5403
  kind,
5323
- file: path4.relative(path4.dirname(entryFile), sourceFile.fileName),
5404
+ file: path5.relative(path5.dirname(entryFile), sourceFile.fileName),
5324
5405
  line: line + 1,
5325
5406
  ...description ? { description } : {},
5326
5407
  ...deprecated ? { deprecated: true } : {},
@@ -5341,21 +5422,21 @@ function getDescriptionPreview(symbol, checker) {
5341
5422
  return `${firstLine.slice(0, 77)}...`;
5342
5423
  }
5343
5424
  // src/builder/spec-builder.ts
5344
- import * as fs7 from "node:fs";
5425
+ import * as fs6 from "node:fs";
5345
5426
  import * as path9 from "node:path";
5346
5427
  import { SCHEMA_URL, SCHEMA_VERSION } from "@openpkg-ts/spec";
5347
- import ts17 from "typescript";
5428
+ import ts18 from "typescript";
5348
5429
 
5349
5430
  // src/ast/resolve.ts
5350
- import ts13 from "typescript";
5431
+ import ts14 from "typescript";
5351
5432
  function isTypeOnlyExport(symbol) {
5352
5433
  const declarations = symbol.declarations ?? [];
5353
5434
  for (const decl of declarations) {
5354
- if (ts13.isExportSpecifier(decl)) {
5435
+ if (ts14.isExportSpecifier(decl)) {
5355
5436
  if (decl.isTypeOnly)
5356
5437
  return true;
5357
5438
  const exportDecl = decl.parent?.parent;
5358
- if (exportDecl && ts13.isExportDeclaration(exportDecl) && exportDecl.isTypeOnly) {
5439
+ if (exportDecl && ts14.isExportDeclaration(exportDecl) && exportDecl.isTypeOnly) {
5359
5440
  return true;
5360
5441
  }
5361
5442
  }
@@ -5365,14 +5446,14 @@ function isTypeOnlyExport(symbol) {
5365
5446
  function resolveExportTarget2(symbol, checker) {
5366
5447
  let targetSymbol = symbol;
5367
5448
  const isTypeOnly = isTypeOnlyExport(symbol);
5368
- if (symbol.flags & ts13.SymbolFlags.Alias) {
5449
+ if (symbol.flags & ts14.SymbolFlags.Alias) {
5369
5450
  const aliasTarget = checker.getAliasedSymbol(symbol);
5370
5451
  if (aliasTarget && aliasTarget !== symbol) {
5371
5452
  targetSymbol = aliasTarget;
5372
5453
  }
5373
5454
  }
5374
5455
  const declarations = targetSymbol.declarations ?? [];
5375
- const declaration = targetSymbol.valueDeclaration || declarations.find((decl) => decl.kind !== ts13.SyntaxKind.ExportSpecifier) || declarations[0];
5456
+ const declaration = targetSymbol.valueDeclaration || declarations.find((decl) => decl.kind !== ts14.SyntaxKind.ExportSpecifier) || declarations[0];
5376
5457
  return { declaration, targetSymbol, isTypeOnly };
5377
5458
  }
5378
5459
 
@@ -5380,7 +5461,7 @@ function resolveExportTarget2(symbol, checker) {
5380
5461
  import { spawn, spawnSync } from "node:child_process";
5381
5462
  import * as fs4 from "node:fs";
5382
5463
  import * as os from "node:os";
5383
- import * as path5 from "node:path";
5464
+ import * as path6 from "node:path";
5384
5465
  var MAX_BUFFER_SIZE = 10 * 1024 * 1024;
5385
5466
  function isStandardJSONSchema(obj) {
5386
5467
  if (typeof obj !== "object" || obj === null)
@@ -5639,16 +5720,16 @@ async function extractStandardSchemasFromTs(tsFilePath, options = {}) {
5639
5720
  return result;
5640
5721
  }
5641
5722
  const tempDir = os.tmpdir();
5642
- const workerPath = path5.join(tempDir, `openpkg-extract-worker-${Date.now()}.ts`);
5723
+ const workerPath = path6.join(tempDir, `openpkg-extract-worker-${Date.now()}.ts`);
5643
5724
  try {
5644
5725
  fs4.writeFileSync(workerPath, TS_WORKER_SCRIPT);
5645
5726
  const optionsJson = JSON.stringify({ target, libraryOptions });
5646
5727
  const args = [...runtime.args, workerPath, tsFilePath, optionsJson];
5647
- return await new Promise((resolve2) => {
5728
+ return await new Promise((resolve3) => {
5648
5729
  const child = spawn(runtime.cmd, args, {
5649
5730
  timeout,
5650
5731
  stdio: ["ignore", "pipe", "pipe"],
5651
- cwd: path5.dirname(tsFilePath)
5732
+ cwd: path6.dirname(tsFilePath)
5652
5733
  });
5653
5734
  let stdout = "";
5654
5735
  let stderr = "";
@@ -5680,14 +5761,14 @@ async function extractStandardSchemasFromTs(tsFilePath, options = {}) {
5680
5761
  }
5681
5762
  if (code !== 0) {
5682
5763
  result.errors.push(`Extraction failed (${runtime.name}): ${stderr || `exit code ${code}`}`);
5683
- resolve2(result);
5764
+ resolve3(result);
5684
5765
  return;
5685
5766
  }
5686
5767
  try {
5687
5768
  const parsed = JSON.parse(stdout);
5688
5769
  if (!parsed.success) {
5689
5770
  result.errors.push(`Extraction failed: ${parsed.error}`);
5690
- resolve2(result);
5771
+ resolve3(result);
5691
5772
  return;
5692
5773
  }
5693
5774
  for (const item of parsed.results) {
@@ -5722,7 +5803,7 @@ async function extractStandardSchemasFromTs(tsFilePath, options = {}) {
5722
5803
  message: "stderr exceeded 10MB buffer limit"
5723
5804
  });
5724
5805
  }
5725
- resolve2(result);
5806
+ resolve3(result);
5726
5807
  });
5727
5808
  child.on("error", (err) => {
5728
5809
  try {
@@ -5733,7 +5814,7 @@ async function extractStandardSchemasFromTs(tsFilePath, options = {}) {
5733
5814
  }
5734
5815
  }
5735
5816
  result.errors.push(`Subprocess error: ${err.message}`);
5736
- resolve2(result);
5817
+ resolve3(result);
5737
5818
  });
5738
5819
  });
5739
5820
  } catch (e) {
@@ -5749,7 +5830,7 @@ async function extractStandardSchemasFromTs(tsFilePath, options = {}) {
5749
5830
  }
5750
5831
  }
5751
5832
  function readTsconfigOutDir(baseDir) {
5752
- const tsconfigPath = path5.join(baseDir, "tsconfig.json");
5833
+ const tsconfigPath = path6.join(baseDir, "tsconfig.json");
5753
5834
  try {
5754
5835
  if (!fs4.existsSync(tsconfigPath)) {
5755
5836
  return null;
@@ -5764,7 +5845,7 @@ function readTsconfigOutDir(baseDir) {
5764
5845
  return null;
5765
5846
  }
5766
5847
  function resolveCompiledPath(tsPath, baseDir) {
5767
- const relativePath = path5.relative(baseDir, tsPath);
5848
+ const relativePath = path6.relative(baseDir, tsPath);
5768
5849
  const withoutExt = relativePath.replace(/\.tsx?$/, "");
5769
5850
  const srcPrefix = withoutExt.replace(/^src\//, "");
5770
5851
  const tsconfigOutDir = readTsconfigOutDir(baseDir);
@@ -5772,7 +5853,7 @@ function resolveCompiledPath(tsPath, baseDir) {
5772
5853
  const candidates = [];
5773
5854
  if (tsconfigOutDir) {
5774
5855
  for (const ext of extensions) {
5775
- candidates.push(path5.join(baseDir, tsconfigOutDir, `${srcPrefix}${ext}`));
5856
+ candidates.push(path6.join(baseDir, tsconfigOutDir, `${srcPrefix}${ext}`));
5776
5857
  }
5777
5858
  }
5778
5859
  const commonOutDirs = ["dist", "build", "lib", "out"];
@@ -5780,17 +5861,17 @@ function resolveCompiledPath(tsPath, baseDir) {
5780
5861
  if (outDir === tsconfigOutDir)
5781
5862
  continue;
5782
5863
  for (const ext of extensions) {
5783
- candidates.push(path5.join(baseDir, outDir, `${srcPrefix}${ext}`));
5864
+ candidates.push(path6.join(baseDir, outDir, `${srcPrefix}${ext}`));
5784
5865
  }
5785
5866
  }
5786
5867
  for (const ext of extensions) {
5787
- candidates.push(path5.join(baseDir, `${withoutExt}${ext}`));
5868
+ candidates.push(path6.join(baseDir, `${withoutExt}${ext}`));
5788
5869
  }
5789
5870
  const workspaceMatch = baseDir.match(/^(.+\/packages\/[^/]+)$/);
5790
5871
  if (workspaceMatch) {
5791
5872
  const pkgRoot = workspaceMatch[1];
5792
5873
  for (const ext of extensions) {
5793
- candidates.push(path5.join(pkgRoot, "dist", `${srcPrefix}${ext}`));
5874
+ candidates.push(path6.join(pkgRoot, "dist", `${srcPrefix}${ext}`));
5794
5875
  }
5795
5876
  }
5796
5877
  for (const candidate of candidates) {
@@ -5812,7 +5893,7 @@ async function extractStandardSchemas(compiledJsPath, options = {}) {
5812
5893
  return result;
5813
5894
  }
5814
5895
  const optionsJson = JSON.stringify({ target, libraryOptions });
5815
- return new Promise((resolve2) => {
5896
+ return new Promise((resolve3) => {
5816
5897
  const child = spawn("node", ["-e", WORKER_SCRIPT, compiledJsPath, optionsJson], {
5817
5898
  timeout,
5818
5899
  stdio: ["ignore", "pipe", "pipe"]
@@ -5840,14 +5921,14 @@ async function extractStandardSchemas(compiledJsPath, options = {}) {
5840
5921
  child.on("close", (code) => {
5841
5922
  if (code !== 0) {
5842
5923
  result.errors.push(`Extraction process failed: ${stderr || `exit code ${code}`}`);
5843
- resolve2(result);
5924
+ resolve3(result);
5844
5925
  return;
5845
5926
  }
5846
5927
  try {
5847
5928
  const parsed = JSON.parse(stdout);
5848
5929
  if (!parsed.success) {
5849
5930
  result.errors.push(`Extraction failed: ${parsed.error}`);
5850
- resolve2(result);
5931
+ resolve3(result);
5851
5932
  return;
5852
5933
  }
5853
5934
  for (const item of parsed.results) {
@@ -5882,11 +5963,11 @@ async function extractStandardSchemas(compiledJsPath, options = {}) {
5882
5963
  message: "stderr exceeded 10MB buffer limit"
5883
5964
  });
5884
5965
  }
5885
- resolve2(result);
5966
+ resolve3(result);
5886
5967
  });
5887
5968
  child.on("error", (err) => {
5888
5969
  result.errors.push(`Subprocess error: ${err.message}`);
5889
- resolve2(result);
5970
+ resolve3(result);
5890
5971
  });
5891
5972
  });
5892
5973
  }
@@ -5924,9 +6005,9 @@ async function extractStandardSchemasFromProject(entryFile, baseDir, options = {
5924
6005
 
5925
6006
  // src/builder/external-resolver.ts
5926
6007
  import * as fs5 from "node:fs";
5927
- import * as path6 from "node:path";
6008
+ import * as path7 from "node:path";
5928
6009
  import picomatch from "picomatch";
5929
- import ts14 from "typescript";
6010
+ import ts15 from "typescript";
5930
6011
  function matchesExternalPattern(packageName, include, exclude) {
5931
6012
  if (!include?.length)
5932
6013
  return false;
@@ -5942,7 +6023,7 @@ function matchesExternalPattern(packageName, include, exclude) {
5942
6023
  return true;
5943
6024
  }
5944
6025
  function resolveExternalModule(moduleSpecifier, containingFile, compilerOptions) {
5945
- const resolved = ts14.resolveModuleName(moduleSpecifier, containingFile, compilerOptions, ts14.sys);
6026
+ const resolved = ts15.resolveModuleName(moduleSpecifier, containingFile, compilerOptions, ts15.sys);
5946
6027
  if (!resolved.resolvedModule) {
5947
6028
  return null;
5948
6029
  }
@@ -5958,11 +6039,11 @@ function findPackageJson(resolvedPath, packageName) {
5958
6039
  const isScoped = packageName.startsWith("@");
5959
6040
  const packageParts = isScoped ? packageName.split("/").slice(0, 2) : [packageName.split("/")[0]];
5960
6041
  const packageDir = packageParts.join("/");
5961
- let dir = path6.dirname(resolvedPath);
6042
+ let dir = path7.dirname(resolvedPath);
5962
6043
  const maxDepth = 10;
5963
6044
  for (let i = 0;i < maxDepth; i++) {
5964
6045
  if (dir.endsWith(`node_modules/${packageDir}`)) {
5965
- const pkgPath = path6.join(dir, "package.json");
6046
+ const pkgPath = path7.join(dir, "package.json");
5966
6047
  if (fs5.existsSync(pkgPath)) {
5967
6048
  try {
5968
6049
  return JSON.parse(fs5.readFileSync(pkgPath, "utf-8"));
@@ -5971,7 +6052,7 @@ function findPackageJson(resolvedPath, packageName) {
5971
6052
  }
5972
6053
  }
5973
6054
  }
5974
- const parent = path6.dirname(dir);
6055
+ const parent = path7.dirname(dir);
5975
6056
  if (parent === dir)
5976
6057
  break;
5977
6058
  dir = parent;
@@ -6007,7 +6088,7 @@ function extractExternalExport(exportName, resolvedModule, program, ctx, visited
6007
6088
  return null;
6008
6089
  }
6009
6090
  let resolvedSymbol = targetExport;
6010
- if (targetExport.flags & ts14.SymbolFlags.Alias) {
6091
+ if (targetExport.flags & ts15.SymbolFlags.Alias) {
6011
6092
  const aliased = checker.getAliasedSymbol(targetExport);
6012
6093
  if (aliased && aliased !== targetExport) {
6013
6094
  resolvedSymbol = aliased;
@@ -6078,7 +6159,7 @@ function mergeRuntimeSchemas(staticExports, runtimeSchemas) {
6078
6159
  }
6079
6160
 
6080
6161
  // src/builder/type-cache.ts
6081
- import ts15 from "typescript";
6162
+ import ts16 from "typescript";
6082
6163
 
6083
6164
  // src/utils/cache-manager.ts
6084
6165
  class CacheManager {
@@ -6185,10 +6266,10 @@ function findTypeDefinition(typeName, program, sourceFile) {
6185
6266
  return typeDefinitionCache.getOrCompute(typeName, () => {
6186
6267
  const checker = program.getTypeChecker();
6187
6268
  const findInNode = (node) => {
6188
- if ((ts15.isInterfaceDeclaration(node) || ts15.isTypeAliasDeclaration(node) || ts15.isClassDeclaration(node) || ts15.isEnumDeclaration(node)) && node.name?.text === typeName) {
6269
+ if ((ts16.isInterfaceDeclaration(node) || ts16.isTypeAliasDeclaration(node) || ts16.isClassDeclaration(node) || ts16.isEnumDeclaration(node)) && node.name?.text === typeName) {
6189
6270
  return node.getSourceFile().fileName;
6190
6271
  }
6191
- return ts15.forEachChild(node, findInNode);
6272
+ return ts16.forEachChild(node, findInNode);
6192
6273
  };
6193
6274
  const entryResult = findInNode(sourceFile);
6194
6275
  if (entryResult)
@@ -6200,14 +6281,14 @@ function findTypeDefinition(typeName, program, sourceFile) {
6200
6281
  return result;
6201
6282
  }
6202
6283
  }
6203
- const symbol = checker.resolveName(typeName, sourceFile, ts15.SymbolFlags.Type, false);
6284
+ const symbol = checker.resolveName(typeName, sourceFile, ts16.SymbolFlags.Type, false);
6204
6285
  return symbol?.declarations?.[0]?.getSourceFile().fileName;
6205
6286
  });
6206
6287
  }
6207
6288
  function hasInternalTag(typeName, program, sourceFile) {
6208
6289
  return internalTagCache.getOrCompute(typeName, () => {
6209
6290
  const checker = program.getTypeChecker();
6210
- const symbol = checker.resolveName(typeName, sourceFile, ts15.SymbolFlags.Type, false);
6291
+ const symbol = checker.resolveName(typeName, sourceFile, ts16.SymbolFlags.Type, false);
6211
6292
  if (!symbol)
6212
6293
  return false;
6213
6294
  return symbol.getJsDocTags().some((tag) => tag.name === "internal");
@@ -6215,21 +6296,8 @@ function hasInternalTag(typeName, program, sourceFile) {
6215
6296
  }
6216
6297
 
6217
6298
  // src/builder/type-expansion.ts
6218
- import * as fs6 from "node:fs";
6219
- import * as path7 from "node:path";
6220
- import ts16 from "typescript";
6221
- function findPackageDir(fromFile) {
6222
- let dir = path7.dirname(path7.resolve(fromFile));
6223
- while (true) {
6224
- if (fs6.existsSync(path7.join(dir, "package.json")))
6225
- return dir;
6226
- const parent = path7.dirname(dir);
6227
- if (parent === dir)
6228
- return;
6229
- dir = parent;
6230
- }
6231
- }
6232
- var NODE_MODULES_PKG = /node_modules\/(@[^/]+\/[^/]+|[^/]+)/;
6299
+ import ts17 from "typescript";
6300
+ var NODE_MODULES_PKG2 = /node_modules\/(@[^/]+\/[^/]+|[^/]+)/;
6233
6301
  function isLibFile(fileName) {
6234
6302
  return fileName.includes("/typescript/lib/lib.") || fileName.includes("\\typescript\\lib\\lib.");
6235
6303
  }
@@ -6256,7 +6324,7 @@ function createExternalExpansionPredicate(opts) {
6256
6324
  const fileName = decl.getSourceFile().fileName;
6257
6325
  if (isLibFile(fileName))
6258
6326
  return false;
6259
- const match = fileName.match(NODE_MODULES_PKG);
6327
+ const match = fileName.match(NODE_MODULES_PKG2);
6260
6328
  if (match)
6261
6329
  return packageAllowed(match[1]);
6262
6330
  return true;
@@ -6268,20 +6336,6 @@ function expandReachableTypes(exportedSymbols, ctx, opts) {
6268
6336
  const checker = ctx.typeChecker;
6269
6337
  const visited = new Set;
6270
6338
  const MAX_DEPTH = 30;
6271
- const entryPackageDir = findPackageDir(opts.entryFile);
6272
- const packageLabel = (fileName) => {
6273
- const match = fileName.match(NODE_MODULES_PKG);
6274
- let pkg = match?.[1];
6275
- if (!pkg) {
6276
- for (const [name, dir] of opts.workspacePackages) {
6277
- if (fileName.startsWith(`${path7.resolve(dir)}${path7.sep}`)) {
6278
- pkg = name;
6279
- break;
6280
- }
6281
- }
6282
- }
6283
- return (pkg ?? "local").replace(/^@/, "").replace(/\//g, "-");
6284
- };
6285
6339
  const symbolAllowed = createExternalExpansionPredicate(opts);
6286
6340
  const visit = (type, depth) => {
6287
6341
  if (!type || depth > MAX_DEPTH || visited.has(type))
@@ -6311,7 +6365,7 @@ function expandReachableTypes(exportedSymbols, ctx, opts) {
6311
6365
  visit(t, depth + 1);
6312
6366
  }
6313
6367
  }
6314
- if (!allowed || !(type.flags & ts16.TypeFlags.Object || type.isClassOrInterface())) {
6368
+ if (!allowed || !(type.flags & ts17.TypeFlags.Object || type.isClassOrInterface())) {
6315
6369
  return;
6316
6370
  }
6317
6371
  if (type.isClassOrInterface()) {
@@ -6334,19 +6388,19 @@ function expandReachableTypes(exportedSymbols, ctx, opts) {
6334
6388
  visit(info.type, depth + 1);
6335
6389
  }
6336
6390
  };
6337
- const TYPE_SYMBOL_FLAGS = ts16.SymbolFlags.Interface | ts16.SymbolFlags.TypeAlias | ts16.SymbolFlags.Class | ts16.SymbolFlags.RegularEnum | ts16.SymbolFlags.ConstEnum;
6391
+ const TYPE_SYMBOL_FLAGS = ts17.SymbolFlags.Interface | ts17.SymbolFlags.TypeAlias | ts17.SymbolFlags.Class | ts17.SymbolFlags.RegularEnum | ts17.SymbolFlags.ConstEnum;
6338
6392
  const visitedSymbols = new Set;
6339
6393
  const symbolKind = (symbol) => {
6340
- if (symbol.flags & ts16.SymbolFlags.Interface)
6394
+ if (symbol.flags & ts17.SymbolFlags.Interface)
6341
6395
  return "interface";
6342
- if (symbol.flags & ts16.SymbolFlags.Class)
6396
+ if (symbol.flags & ts17.SymbolFlags.Class)
6343
6397
  return "class";
6344
- if (symbol.flags & (ts16.SymbolFlags.RegularEnum | ts16.SymbolFlags.ConstEnum))
6398
+ if (symbol.flags & (ts17.SymbolFlags.RegularEnum | ts17.SymbolFlags.ConstEnum))
6345
6399
  return "enum";
6346
6400
  return "type";
6347
6401
  };
6348
6402
  const resolveAlias = (symbol) => {
6349
- if (symbol.flags & ts16.SymbolFlags.Alias) {
6403
+ if (symbol.flags & ts17.SymbolFlags.Alias) {
6350
6404
  try {
6351
6405
  return checker.getAliasedSymbol(symbol);
6352
6406
  } catch {
@@ -6368,37 +6422,16 @@ function expandReachableTypes(exportedSymbols, ctx, opts) {
6368
6422
  walkDeclarations(symbol);
6369
6423
  return;
6370
6424
  }
6371
- if (ctx.typeRegistry.has(name)) {
6372
- const prior = symbolByName.get(name);
6373
- if (prior !== symbol) {
6374
- const declFile = symbol.declarations?.[0]?.getSourceFile().fileName ?? "";
6375
- const foreign = !!entryPackageDir && !declFile.startsWith(`${entryPackageDir}${path7.sep}`);
6376
- if (prior !== undefined || foreign) {
6377
- const scopedId = `${packageLabel(declFile)}.${name}`;
6378
- if (!ctx.typeRegistry.has(scopedId)) {
6379
- const declared2 = checker.getDeclaredTypeOfSymbol(symbol);
6380
- const schema = ensureNonEmptySchema(buildSchema(declared2, checker, ctx), declared2, checker);
6381
- const selfRef = JSON.stringify(schema) === JSON.stringify({ $ref: `#/types/${name}` });
6382
- if (!selfRef && JSON.stringify(ctx.typeRegistry.get(name)?.schema) !== JSON.stringify(schema)) {
6383
- ctx.typeRegistry.add({
6384
- id: scopedId,
6385
- name,
6386
- kind: symbolKind(symbol),
6387
- schema
6388
- });
6389
- visit(declared2, 0);
6390
- }
6391
- }
6392
- }
6393
- }
6425
+ const id = resolveTypeId(symbol, ctx);
6426
+ if (ctx.typeRegistry.has(id)) {
6394
6427
  walkDeclarations(symbol);
6395
6428
  return;
6396
6429
  }
6397
6430
  const declared = checker.getDeclaredTypeOfSymbol(symbol);
6398
6431
  ctx.typeRegistry.registerType(declared, ctx);
6399
- if (!ctx.typeRegistry.has(name)) {
6432
+ if (!ctx.typeRegistry.has(id)) {
6400
6433
  ctx.typeRegistry.add({
6401
- id: name,
6434
+ id,
6402
6435
  name,
6403
6436
  kind: symbolKind(symbol),
6404
6437
  schema: ensureNonEmptySchema(buildSchema(declared, checker, ctx), declared, checker)
@@ -6419,7 +6452,7 @@ function expandReachableTypes(exportedSymbols, ctx, opts) {
6419
6452
  const target = symbol && resolveAlias(symbol);
6420
6453
  if (!target || visitedSymbols.has(target))
6421
6454
  return;
6422
- if (!(target.flags & (ts16.SymbolFlags.ValueModule | ts16.SymbolFlags.NamespaceModule)))
6455
+ if (!(target.flags & (ts17.SymbolFlags.ValueModule | ts17.SymbolFlags.NamespaceModule)))
6423
6456
  return;
6424
6457
  if (!symbolAllowed(target))
6425
6458
  return;
@@ -6434,22 +6467,22 @@ function expandReachableTypes(exportedSymbols, ctx, opts) {
6434
6467
  }
6435
6468
  };
6436
6469
  const walkNode = (node) => {
6437
- if (ts16.isTypeReferenceNode(node)) {
6470
+ if (ts17.isTypeReferenceNode(node)) {
6438
6471
  handleRef(node.typeName);
6439
- if (ts16.isQualifiedName(node.typeName)) {
6472
+ if (ts17.isQualifiedName(node.typeName)) {
6440
6473
  handleNamespaceRef(node.typeName.left);
6441
6474
  }
6442
- } else if (ts16.isExpressionWithTypeArguments(node)) {
6475
+ } else if (ts17.isExpressionWithTypeArguments(node)) {
6443
6476
  handleRef(node.expression);
6444
- } else if (ts16.isTypeQueryNode(node)) {
6477
+ } else if (ts17.isTypeQueryNode(node)) {
6445
6478
  handleRef(node.exprName);
6446
- if (ts16.isQualifiedName(node.exprName)) {
6479
+ if (ts17.isQualifiedName(node.exprName)) {
6447
6480
  handleRef(node.exprName.left);
6448
6481
  handleNamespaceRef(node.exprName.left);
6449
6482
  }
6450
- } else if (ts16.isImportTypeNode(node) && node.qualifier) {
6483
+ } else if (ts17.isImportTypeNode(node) && node.qualifier) {
6451
6484
  handleRef(node.qualifier);
6452
- if (ts16.isQualifiedName(node.qualifier)) {
6485
+ if (ts17.isQualifiedName(node.qualifier)) {
6453
6486
  handleNamespaceRef(node.qualifier.left);
6454
6487
  }
6455
6488
  }
@@ -6465,7 +6498,7 @@ function expandReachableTypes(exportedSymbols, ctx, opts) {
6465
6498
  };
6466
6499
  for (const exportSymbol of exportedSymbols) {
6467
6500
  let target = exportSymbol;
6468
- if (exportSymbol.flags & ts16.SymbolFlags.Alias) {
6501
+ if (exportSymbol.flags & ts17.SymbolFlags.Alias) {
6469
6502
  try {
6470
6503
  target = checker.getAliasedSymbol(exportSymbol);
6471
6504
  } catch {
@@ -6798,7 +6831,8 @@ async function extract(options) {
6798
6831
  shouldExpandExternal: createExternalExpansionPredicate({
6799
6832
  followExternal: options.followExternal,
6800
6833
  workspacePackages: result.workspacePackages ?? new Map
6801
- })
6834
+ }),
6835
+ workspacePackages: result.workspacePackages ?? new Map
6802
6836
  });
6803
6837
  ctx.exportedIds = exportedIds;
6804
6838
  const filteredSymbols = exportedSymbols.filter((s) => shouldIncludeExport(s.getName(), only, ignore));
@@ -6827,9 +6861,9 @@ async function extract(options) {
6827
6861
  break;
6828
6862
  }
6829
6863
  }
6830
- if (ts17.isExportSpecifier(decl)) {
6864
+ if (ts18.isExportSpecifier(decl)) {
6831
6865
  const exportDecl = decl.parent?.parent;
6832
- if (exportDecl && ts17.isExportDeclaration(exportDecl) && exportDecl.moduleSpecifier) {
6866
+ if (exportDecl && ts18.isExportDeclaration(exportDecl) && exportDecl.moduleSpecifier) {
6833
6867
  const moduleText = exportDecl.moduleSpecifier.getText().slice(1, -1);
6834
6868
  if (!moduleText.startsWith(".") && !moduleText.startsWith("/")) {
6835
6869
  externalPackage = moduleText;
@@ -6898,7 +6932,7 @@ async function extract(options) {
6898
6932
  entryFile
6899
6933
  });
6900
6934
  {
6901
- const symFlags = ts17.SymbolFlags.Type | ts17.SymbolFlags.Interface | ts17.SymbolFlags.Class;
6935
+ const symFlags = ts18.SymbolFlags.Type | ts18.SymbolFlags.Interface | ts18.SymbolFlags.Class;
6902
6936
  const maxPasses = 5;
6903
6937
  for (let pass = 0;pass < maxPasses; pass++) {
6904
6938
  const allRefs = new Map;
@@ -7045,21 +7079,21 @@ async function extract(options) {
7045
7079
  }
7046
7080
  function serializeDeclaration2(declaration, exportSymbol, exportName, ctx, isTypeOnly = false) {
7047
7081
  let result = null;
7048
- if (ts17.isFunctionDeclaration(declaration)) {
7082
+ if (ts18.isFunctionDeclaration(declaration)) {
7049
7083
  result = serializeFunctionExport(declaration, ctx);
7050
- } else if (ts17.isClassDeclaration(declaration)) {
7084
+ } else if (ts18.isClassDeclaration(declaration)) {
7051
7085
  result = serializeClass(declaration, ctx);
7052
- } else if (ts17.isInterfaceDeclaration(declaration)) {
7086
+ } else if (ts18.isInterfaceDeclaration(declaration)) {
7053
7087
  result = serializeInterface(declaration, ctx);
7054
- } else if (ts17.isTypeAliasDeclaration(declaration)) {
7088
+ } else if (ts18.isTypeAliasDeclaration(declaration)) {
7055
7089
  result = serializeTypeAlias(declaration, ctx);
7056
- } else if (ts17.isEnumDeclaration(declaration)) {
7090
+ } else if (ts18.isEnumDeclaration(declaration)) {
7057
7091
  result = serializeEnum(declaration, ctx);
7058
- } else if (ts17.isVariableDeclaration(declaration)) {
7092
+ } else if (ts18.isVariableDeclaration(declaration)) {
7059
7093
  const varStatement = declaration.parent?.parent;
7060
- if (varStatement && ts17.isVariableStatement(varStatement)) {
7061
- if (declaration.initializer && (ts17.isArrowFunction(declaration.initializer) || ts17.isFunctionExpression(declaration.initializer))) {
7062
- const varName = ts17.isIdentifier(declaration.name) ? declaration.name.text : declaration.name.getText();
7094
+ if (varStatement && ts18.isVariableStatement(varStatement)) {
7095
+ if (declaration.initializer && (ts18.isArrowFunction(declaration.initializer) || ts18.isFunctionExpression(declaration.initializer))) {
7096
+ const varName = ts18.isIdentifier(declaration.name) ? declaration.name.text : declaration.name.getText();
7063
7097
  result = serializeFunctionExport(declaration.initializer, ctx, varName);
7064
7098
  } else {
7065
7099
  result = serializeVariable(declaration, varStatement, ctx);
@@ -7071,7 +7105,7 @@ function serializeDeclaration2(declaration, exportSymbol, exportName, ctx, isTyp
7071
7105
  }
7072
7106
  }
7073
7107
  }
7074
- } else if (ts17.isNamespaceExport(declaration) || ts17.isModuleDeclaration(declaration) || ts17.isNamespaceImport(declaration) || ts17.isSourceFile(declaration)) {
7108
+ } else if (ts18.isNamespaceExport(declaration) || ts18.isModuleDeclaration(declaration) || ts18.isNamespaceImport(declaration) || ts18.isSourceFile(declaration)) {
7075
7109
  try {
7076
7110
  result = serializeNamespaceExport(exportSymbol, exportName, ctx);
7077
7111
  } catch {
@@ -7107,7 +7141,7 @@ function serializeNamespaceExport(symbol, exportName, ctx) {
7107
7141
  const members = [];
7108
7142
  const checker = ctx.program.getTypeChecker();
7109
7143
  let targetSymbol = symbol;
7110
- if (symbol.flags & ts17.SymbolFlags.Alias) {
7144
+ if (symbol.flags & ts18.SymbolFlags.Alias) {
7111
7145
  const aliased = checker.getAliasedSymbol(symbol);
7112
7146
  if (aliased && aliased !== symbol) {
7113
7147
  targetSymbol = aliased;
@@ -7134,31 +7168,31 @@ function serializeNamespaceExport(symbol, exportName, ctx) {
7134
7168
  function serializeNamespaceMember(symbol, memberName, ctx) {
7135
7169
  const checker = ctx.program.getTypeChecker();
7136
7170
  let targetSymbol = symbol;
7137
- if (symbol.flags & ts17.SymbolFlags.Alias) {
7171
+ if (symbol.flags & ts18.SymbolFlags.Alias) {
7138
7172
  const aliased = checker.getAliasedSymbol(symbol);
7139
7173
  if (aliased && aliased !== symbol) {
7140
7174
  targetSymbol = aliased;
7141
7175
  }
7142
7176
  }
7143
7177
  const declarations = targetSymbol.declarations ?? [];
7144
- const declaration = targetSymbol.valueDeclaration || declarations.find((d) => d.kind !== ts17.SyntaxKind.ExportSpecifier) || declarations[0];
7178
+ const declaration = targetSymbol.valueDeclaration || declarations.find((d) => d.kind !== ts18.SyntaxKind.ExportSpecifier) || declarations[0];
7145
7179
  if (!declaration)
7146
7180
  return null;
7147
7181
  const type = checker.getTypeAtLocation(declaration);
7148
7182
  const callSignatures = type.getCallSignatures();
7149
7183
  const { deprecated } = isSymbolDeprecated(targetSymbol);
7150
7184
  let kind = "variable";
7151
- if (ts17.isFunctionDeclaration(declaration) || ts17.isFunctionExpression(declaration)) {
7185
+ if (ts18.isFunctionDeclaration(declaration) || ts18.isFunctionExpression(declaration)) {
7152
7186
  kind = "function";
7153
- } else if (ts17.isClassDeclaration(declaration)) {
7187
+ } else if (ts18.isClassDeclaration(declaration)) {
7154
7188
  kind = "class";
7155
- } else if (ts17.isInterfaceDeclaration(declaration)) {
7189
+ } else if (ts18.isInterfaceDeclaration(declaration)) {
7156
7190
  kind = "interface";
7157
- } else if (ts17.isTypeAliasDeclaration(declaration)) {
7191
+ } else if (ts18.isTypeAliasDeclaration(declaration)) {
7158
7192
  kind = "type";
7159
- } else if (ts17.isEnumDeclaration(declaration)) {
7193
+ } else if (ts18.isEnumDeclaration(declaration)) {
7160
7194
  kind = "enum";
7161
- } else if (ts17.isVariableDeclaration(declaration)) {
7195
+ } else if (ts18.isVariableDeclaration(declaration)) {
7162
7196
  if (callSignatures.length > 0) {
7163
7197
  kind = "function";
7164
7198
  }
@@ -7189,11 +7223,11 @@ function getJSDocFromExportSymbol(symbol) {
7189
7223
  const examples = [];
7190
7224
  const decl = symbol.declarations?.[0];
7191
7225
  if (decl) {
7192
- const exportDecl = ts17.isNamespaceExport(decl) ? decl.parent : decl;
7193
- if (exportDecl && ts17.isExportDeclaration(exportDecl)) {
7194
- const jsDocs = ts17.getJSDocCommentsAndTags(exportDecl);
7226
+ const exportDecl = ts18.isNamespaceExport(decl) ? decl.parent : decl;
7227
+ if (exportDecl && ts18.isExportDeclaration(exportDecl)) {
7228
+ const jsDocs = ts18.getJSDocCommentsAndTags(exportDecl);
7195
7229
  for (const doc of jsDocs) {
7196
- if (ts17.isJSDoc(doc) && doc.comment) {
7230
+ if (ts18.isJSDoc(doc) && doc.comment) {
7197
7231
  const commentText = typeof doc.comment === "string" ? doc.comment : doc.comment.map((c) => ("text" in c) ? c.text : "").join("");
7198
7232
  if (commentText) {
7199
7233
  return {
@@ -7291,8 +7325,8 @@ async function getPackageMeta(entryFile, baseDir) {
7291
7325
  while (dir !== path9.dirname(dir)) {
7292
7326
  const pkgPath = path9.join(dir, "package.json");
7293
7327
  try {
7294
- if (fs7.existsSync(pkgPath)) {
7295
- const pkg = JSON.parse(fs7.readFileSync(pkgPath, "utf-8"));
7328
+ if (fs6.existsSync(pkgPath)) {
7329
+ const pkg = JSON.parse(fs6.readFileSync(pkgPath, "utf-8"));
7296
7330
  return {
7297
7331
  name: pkg.name ?? path9.basename(dir),
7298
7332
  version: pkg.version,
@@ -7787,12 +7821,12 @@ function toToolSchema(exp, spec, options) {
7787
7821
  };
7788
7822
  }
7789
7823
  // src/types/utils.ts
7790
- import ts18 from "typescript";
7824
+ import ts19 from "typescript";
7791
7825
  function isExported(node) {
7792
7826
  const modifiers = node.modifiers;
7793
7827
  if (!modifiers)
7794
7828
  return false;
7795
- return modifiers.some((m) => m.kind === ts18.SyntaxKind.ExportKeyword);
7829
+ return modifiers.some((m) => m.kind === ts19.SyntaxKind.ExportKeyword);
7796
7830
  }
7797
7831
  function getNodeName(node) {
7798
7832
  if ("name" in node && node.name) {