@formspec/build 0.1.0-alpha.57 → 0.1.0-alpha.59

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.cjs CHANGED
@@ -1053,7 +1053,7 @@ function generateJsonSchemaFromIR(ir, options) {
1053
1053
  applyConstraints(ctx.defs[schemaName], typeDef.constraints, ctx);
1054
1054
  }
1055
1055
  if (typeDef.annotations && typeDef.annotations.length > 0) {
1056
- applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx);
1056
+ applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx, typeDef.type);
1057
1057
  }
1058
1058
  }
1059
1059
  const properties = {};
@@ -1126,7 +1126,7 @@ function generateFieldSchema(field, ctx) {
1126
1126
  }
1127
1127
  }
1128
1128
  applyResolvedMetadata(schema, field.metadata);
1129
- applyAnnotations(schema, rootAnnotations, ctx);
1129
+ applyAnnotations(schema, rootAnnotations, ctx, field.type);
1130
1130
  if (itemStringSchema !== void 0) {
1131
1131
  applyAnnotations(itemStringSchema, itemAnnotations, ctx);
1132
1132
  }
@@ -1169,32 +1169,36 @@ function applyPathTargetedConstraints(schema, pathConstraints, ctx, typeNode) {
1169
1169
  return schema;
1170
1170
  }
1171
1171
  if (schema.$ref) {
1172
- const { $ref, ...rest } = schema;
1173
- const refPart = { $ref };
1174
- const overridePart = {
1175
- properties: propertyOverrides,
1176
- ...rest
1172
+ return {
1173
+ ...schema,
1174
+ properties: propertyOverrides
1177
1175
  };
1178
- return { allOf: [refPart, overridePart] };
1179
1176
  }
1180
1177
  if (schema.type === "object" && schema.properties) {
1181
- const missingOverrides = {};
1182
1178
  for (const [target, overrideSchema] of Object.entries(propertyOverrides)) {
1183
- if (schema.properties[target]) {
1184
- mergeSchemaOverride(schema.properties[target], overrideSchema);
1185
- } else {
1186
- missingOverrides[target] = overrideSchema;
1179
+ if (Object.hasOwn(schema.properties, target)) {
1180
+ const existing = schema.properties[target];
1181
+ if (existing) {
1182
+ mergeSchemaOverride(existing, overrideSchema);
1183
+ continue;
1184
+ }
1187
1185
  }
1186
+ Object.defineProperty(schema.properties, target, {
1187
+ value: overrideSchema,
1188
+ writable: true,
1189
+ enumerable: true,
1190
+ configurable: true
1191
+ });
1188
1192
  }
1189
- if (Object.keys(missingOverrides).length === 0) {
1190
- return schema;
1191
- }
1192
- return {
1193
- allOf: [schema, { properties: missingOverrides }]
1194
- };
1193
+ return schema;
1195
1194
  }
1196
1195
  if (schema.allOf) {
1197
- schema.allOf = [...schema.allOf, { properties: propertyOverrides }];
1196
+ const overrideMember = { properties: propertyOverrides };
1197
+ const flattened = tryFlattenAllOfToSiblings(schema, overrideMember);
1198
+ if (flattened !== void 0) {
1199
+ return flattened;
1200
+ }
1201
+ schema.allOf = [...schema.allOf, overrideMember];
1198
1202
  return schema;
1199
1203
  }
1200
1204
  return schema;
@@ -1307,7 +1311,7 @@ function generatePropertySchema(prop, ctx) {
1307
1311
  const schema = generateTypeNode(prop.type, ctx);
1308
1312
  applyConstraints(schema, prop.constraints, ctx);
1309
1313
  applyResolvedMetadata(schema, prop.metadata);
1310
- applyAnnotations(schema, prop.annotations, ctx);
1314
+ applyAnnotations(schema, prop.annotations, ctx, prop.type);
1311
1315
  return schema;
1312
1316
  }
1313
1317
  function generateUnionType(type, ctx) {
@@ -1410,13 +1414,20 @@ function buildPropertyOverrides(pathConstraints, typeNode, ctx) {
1410
1414
  grouped.push(constraint);
1411
1415
  byTarget.set(target, grouped);
1412
1416
  }
1413
- const overrides = {};
1417
+ const overrides = /* @__PURE__ */ Object.create(null);
1414
1418
  for (const [target, constraints] of byTarget) {
1415
- overrides[resolveSerializedPropertyName(target, typeNode, ctx)] = buildPathOverrideSchema(
1419
+ const resolvedName = resolveSerializedPropertyName(target, typeNode, ctx);
1420
+ const schema = buildPathOverrideSchema(
1416
1421
  constraints.map(stripLeadingPathSegment),
1417
1422
  resolveTargetTypeNode(target, typeNode, ctx),
1418
1423
  ctx
1419
1424
  );
1425
+ Object.defineProperty(overrides, resolvedName, {
1426
+ value: schema,
1427
+ writable: true,
1428
+ enumerable: true,
1429
+ configurable: true
1430
+ });
1420
1431
  }
1421
1432
  return overrides;
1422
1433
  }
@@ -1443,6 +1454,34 @@ function buildPathOverrideSchema(constraints, typeNode, ctx) {
1443
1454
  schema.properties = buildPropertyOverrides(nestedConstraints, effectiveType, ctx);
1444
1455
  return schema;
1445
1456
  }
1457
+ function tryFlattenAllOfToSiblings(schema, overrideMember) {
1458
+ if (schema.allOf?.length !== 1) {
1459
+ return void 0;
1460
+ }
1461
+ const [soleMember] = schema.allOf;
1462
+ if (soleMember === void 0) {
1463
+ return void 0;
1464
+ }
1465
+ const { allOf: _allOf, ...outerRest } = schema;
1466
+ const outerKeys = new Set(Object.keys(outerRest));
1467
+ const memberKeys = new Set(Object.keys(soleMember));
1468
+ const overrideKeys = new Set(Object.keys(overrideMember));
1469
+ for (const key of memberKeys) {
1470
+ if (outerKeys.has(key) || overrideKeys.has(key)) {
1471
+ return void 0;
1472
+ }
1473
+ }
1474
+ for (const key of overrideKeys) {
1475
+ if (outerKeys.has(key)) {
1476
+ return void 0;
1477
+ }
1478
+ }
1479
+ return {
1480
+ ...outerRest,
1481
+ ...soleMember,
1482
+ ...overrideMember
1483
+ };
1484
+ }
1446
1485
  function mergeSchemaOverride(target, override) {
1447
1486
  const nullableValueBranch = getNullableUnionValueSchema(target);
1448
1487
  if (nullableValueBranch !== void 0) {
@@ -1450,11 +1489,16 @@ function mergeSchemaOverride(target, override) {
1450
1489
  return;
1451
1490
  }
1452
1491
  if (override.properties !== void 0) {
1453
- const mergedProperties = target.properties ?? {};
1492
+ const mergedProperties = target.properties ?? /* @__PURE__ */ Object.create(null);
1454
1493
  for (const [name, propertyOverride] of Object.entries(override.properties)) {
1455
- const existing = mergedProperties[name];
1494
+ const existing = Object.hasOwn(mergedProperties, name) ? mergedProperties[name] : void 0;
1456
1495
  if (existing === void 0) {
1457
- mergedProperties[name] = propertyOverride;
1496
+ Object.defineProperty(mergedProperties, name, {
1497
+ value: propertyOverride,
1498
+ writable: true,
1499
+ enumerable: true,
1500
+ configurable: true
1501
+ });
1458
1502
  } else {
1459
1503
  mergeSchemaOverride(existing, propertyOverride);
1460
1504
  }
@@ -1472,7 +1516,12 @@ function mergeSchemaOverride(target, override) {
1472
1516
  if (key === "properties" || key === "items") {
1473
1517
  continue;
1474
1518
  }
1475
- target[key] = value;
1519
+ Object.defineProperty(target, key, {
1520
+ value,
1521
+ writable: true,
1522
+ enumerable: true,
1523
+ configurable: true
1524
+ });
1476
1525
  }
1477
1526
  }
1478
1527
  function stripLeadingPathSegment(constraint) {
@@ -1572,7 +1621,7 @@ function applyConstraints(schema, constraints, ctx) {
1572
1621
  }
1573
1622
  }
1574
1623
  }
1575
- function applyAnnotations(schema, annotations, ctx) {
1624
+ function applyAnnotations(schema, annotations, ctx, typeNode) {
1576
1625
  for (const annotation of annotations) {
1577
1626
  switch (annotation.annotationKind) {
1578
1627
  case "displayName":
@@ -1585,7 +1634,7 @@ function applyAnnotations(schema, annotations, ctx) {
1585
1634
  schema[`${ctx.vendorPrefix}-remarks`] = annotation.value;
1586
1635
  break;
1587
1636
  case "defaultValue":
1588
- schema.default = annotation.value;
1637
+ schema.default = coerceDefaultValue(annotation.value, typeNode, schema, ctx);
1589
1638
  break;
1590
1639
  case "format":
1591
1640
  schema.format = annotation.value;
@@ -1610,6 +1659,34 @@ function applyAnnotations(schema, annotations, ctx) {
1610
1659
  }
1611
1660
  }
1612
1661
  }
1662
+ function coerceDefaultValue(value, typeNode, emittedSchema, ctx) {
1663
+ if (typeNode?.kind !== "custom") {
1664
+ return value;
1665
+ }
1666
+ const registration = ctx.extensionRegistry?.findType(typeNode.typeId);
1667
+ if (registration === void 0) {
1668
+ return value;
1669
+ }
1670
+ if (registration.serializeDefault !== void 0) {
1671
+ return registration.serializeDefault(value, typeNode.payload);
1672
+ }
1673
+ const declaredType = emittedSchema["type"];
1674
+ if (declaredType === "string" && typeof value !== "string") {
1675
+ if (typeof value === "number") {
1676
+ if (!Number.isFinite(value)) {
1677
+ return value;
1678
+ }
1679
+ return String(value);
1680
+ }
1681
+ if (typeof value === "boolean") {
1682
+ return String(value);
1683
+ }
1684
+ if (typeof value === "bigint") {
1685
+ return value.toString();
1686
+ }
1687
+ }
1688
+ return value;
1689
+ }
1613
1690
  function generateCustomType(type, ctx) {
1614
1691
  const registration = ctx.extensionRegistry?.findType(type.typeId);
1615
1692
  if (registration === void 0) {
@@ -2039,6 +2116,16 @@ function buildConstraintTagSources(extensions) {
2039
2116
  constraintTags: extension.constraintTags.map((tag) => ({
2040
2117
  tagName: (0, import_internal.normalizeFormSpecTagName)(tag.tagName)
2041
2118
  }))
2119
+ } : {},
2120
+ // Include customTypes so _validateExtensionSetup can check tsTypeNames for
2121
+ // unsupported built-in overrides and invalid identifier patterns.
2122
+ ...extension.types !== void 0 ? {
2123
+ customTypes: extension.types.map((type) => ({
2124
+ // tsTypeNames: deprecated in favour of symbol-based detection, but
2125
+ // still required for name-based validation in _validateExtensionSetup
2126
+ // until the bridge is fully retired (see §synthetic-checker-retirement §4C).
2127
+ tsTypeNames: type.tsTypeNames ?? [type.typeName]
2128
+ }))
2042
2129
  } : {}
2043
2130
  }));
2044
2131
  }
@@ -2048,7 +2135,13 @@ function createExtensionRegistry(extensions) {
2048
2135
  extensionCount: extensions.length,
2049
2136
  extensionIds: extensions.map((e) => e.extensionId)
2050
2137
  });
2051
- const reservedTagSources = buildConstraintTagSources(extensions);
2138
+ const extensionTagSources = buildConstraintTagSources(extensions);
2139
+ const setupDiagnostics = (0, import_internal._validateExtensionSetup)(extensionTagSources);
2140
+ (0, import_internal.logSetupDiagnostics)(registryLog, {
2141
+ diagnosticCount: setupDiagnostics.length,
2142
+ codes: setupDiagnostics.map((d) => d.kind)
2143
+ });
2144
+ const reservedTagSources = extensionTagSources;
2052
2145
  let symbolMap = /* @__PURE__ */ new Map();
2053
2146
  const typeMap = /* @__PURE__ */ new Map();
2054
2147
  const typeNameMap = /* @__PURE__ */ new Map();
@@ -2185,10 +2278,12 @@ function createExtensionRegistry(extensions) {
2185
2278
  constraintTagCount: constraintTagMap.size,
2186
2279
  broadeningCount: builtinBroadeningMap.size,
2187
2280
  annotationCount: annotationMap.size,
2188
- metadataSlotCount: metadataSlotMap.size
2281
+ metadataSlotCount: metadataSlotMap.size,
2282
+ setupDiagnosticCount: setupDiagnostics.length
2189
2283
  });
2190
2284
  return {
2191
2285
  extensions,
2286
+ setupDiagnostics,
2192
2287
  findType: (typeId) => typeMap.get(typeId),
2193
2288
  findTypeByName: (typeName) => typeNameMap.get(typeName),
2194
2289
  findTypeByBrand: (brand) => brandMap.get(brand),
@@ -2266,22 +2361,22 @@ var jsonSchema7Schema = import_zod3.z.lazy(
2266
2361
  );
2267
2362
 
2268
2363
  // src/generators/class-schema.ts
2269
- var ts9 = __toESM(require("typescript"), 1);
2364
+ var ts8 = __toESM(require("typescript"), 1);
2270
2365
 
2271
2366
  // src/analyzer/program.ts
2272
- var ts7 = __toESM(require("typescript"), 1);
2367
+ var ts6 = __toESM(require("typescript"), 1);
2273
2368
  var path = __toESM(require("path"), 1);
2274
2369
 
2275
2370
  // src/analyzer/class-analyzer.ts
2276
- var ts6 = __toESM(require("typescript"), 1);
2277
- var import_internal5 = require("@formspec/analysis/internal");
2371
+ var ts5 = __toESM(require("typescript"), 1);
2372
+ var import_internal6 = require("@formspec/analysis/internal");
2278
2373
 
2279
2374
  // src/analyzer/jsdoc-constraints.ts
2280
- var ts5 = __toESM(require("typescript"), 1);
2375
+ var ts4 = __toESM(require("typescript"), 1);
2281
2376
 
2282
2377
  // src/analyzer/tsdoc-parser.ts
2283
- var ts4 = __toESM(require("typescript"), 1);
2284
- var import_internal3 = require("@formspec/analysis/internal");
2378
+ var ts3 = __toESM(require("typescript"), 1);
2379
+ var import_internal4 = require("@formspec/analysis/internal");
2285
2380
  var import_internals4 = require("@formspec/core/internals");
2286
2381
  var import_internals5 = require("@formspec/core/internals");
2287
2382
  var import_core3 = require("@formspec/core");
@@ -2292,21 +2387,6 @@ var import_internal2 = require("@formspec/analysis/internal");
2292
2387
 
2293
2388
  // src/extensions/ts-type-utils.ts
2294
2389
  var ts = __toESM(require("typescript"), 1);
2295
- function collectBrandIdentifiers(type) {
2296
- if (!type.isIntersection()) {
2297
- return [];
2298
- }
2299
- const brands = [];
2300
- for (const prop of type.getProperties()) {
2301
- const decl = prop.valueDeclaration ?? prop.declarations?.[0];
2302
- if (decl === void 0) continue;
2303
- if (!ts.isPropertySignature(decl) && !ts.isPropertyDeclaration(decl)) continue;
2304
- if (!ts.isComputedPropertyName(decl.name)) continue;
2305
- if (!ts.isIdentifier(decl.name.expression)) continue;
2306
- brands.push(decl.name.expression.text);
2307
- }
2308
- return brands;
2309
- }
2310
2390
  function resolveCanonicalSymbol(type, checker) {
2311
2391
  const raw = type.aliasSymbol ?? type.getSymbol();
2312
2392
  if (raw === void 0) return void 0;
@@ -2391,7 +2471,7 @@ function resolveCustomTypeFromTsType(type, checker, registry, sourceNode) {
2391
2471
  return bySymbol;
2392
2472
  }
2393
2473
  }
2394
- for (const brand of collectBrandIdentifiers(stripped)) {
2474
+ for (const brand of (0, import_internal2._collectBrandIdentifiers)(stripped)) {
2395
2475
  const byBrand = registry.findTypeByBrand(brand);
2396
2476
  if (byBrand !== void 0) {
2397
2477
  return byBrand;
@@ -2404,22 +2484,17 @@ function customTypeIdFromLookup(result) {
2404
2484
  }
2405
2485
 
2406
2486
  // src/analyzer/builtin-brands.ts
2407
- var ts3 = __toESM(require("typescript"), 1);
2408
- function isIntegerBrandedType(type) {
2409
- if (!type.isIntersection()) return false;
2410
- if (!type.types.some((member) => !!(member.flags & ts3.TypeFlags.Number))) return false;
2411
- return collectBrandIdentifiers(type).includes("__integerBrand");
2412
- }
2487
+ var import_internal3 = require("@formspec/analysis/internal");
2413
2488
 
2414
2489
  // src/analyzer/tsdoc-parser.ts
2415
- var import_internal4 = require("@formspec/analysis/internal");
2490
+ var import_internal5 = require("@formspec/analysis/internal");
2416
2491
  function sharedTagValueOptions(options) {
2417
2492
  return {
2418
2493
  ...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
2419
2494
  ...options?.fieldType !== void 0 ? { fieldType: options.fieldType } : {}
2420
2495
  };
2421
2496
  }
2422
- var SYNTHETIC_TYPE_FORMAT_FLAGS = ts4.TypeFormatFlags.NoTruncation | ts4.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
2497
+ var SYNTHETIC_TYPE_FORMAT_FLAGS = ts3.TypeFormatFlags.NoTruncation | ts3.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
2423
2498
  function getExtensionTypeNames(registry) {
2424
2499
  if (registry === void 0) {
2425
2500
  return /* @__PURE__ */ new Set();
@@ -2433,23 +2508,23 @@ function getExtensionTypeNames(registry) {
2433
2508
  function collectImportedNames(sourceFile) {
2434
2509
  const importedNames = /* @__PURE__ */ new Set();
2435
2510
  for (const statement of sourceFile.statements) {
2436
- if (ts4.isImportDeclaration(statement) && statement.importClause !== void 0) {
2511
+ if (ts3.isImportDeclaration(statement) && statement.importClause !== void 0) {
2437
2512
  const clause = statement.importClause;
2438
2513
  if (clause.name !== void 0) {
2439
2514
  importedNames.add(clause.name.text);
2440
2515
  }
2441
2516
  if (clause.namedBindings !== void 0) {
2442
- if (ts4.isNamedImports(clause.namedBindings)) {
2517
+ if (ts3.isNamedImports(clause.namedBindings)) {
2443
2518
  for (const specifier of clause.namedBindings.elements) {
2444
2519
  importedNames.add(specifier.name.text);
2445
2520
  }
2446
- } else if (ts4.isNamespaceImport(clause.namedBindings)) {
2521
+ } else if (ts3.isNamespaceImport(clause.namedBindings)) {
2447
2522
  importedNames.add(clause.namedBindings.name.text);
2448
2523
  }
2449
2524
  }
2450
2525
  continue;
2451
2526
  }
2452
- if (ts4.isImportEqualsDeclaration(statement)) {
2527
+ if (ts3.isImportEqualsDeclaration(statement)) {
2453
2528
  importedNames.add(statement.name.text);
2454
2529
  }
2455
2530
  }
@@ -2457,13 +2532,13 @@ function collectImportedNames(sourceFile) {
2457
2532
  }
2458
2533
  function isNonReferenceIdentifier(node) {
2459
2534
  const parent = node.parent;
2460
- if ((ts4.isBindingElement(parent) || ts4.isClassDeclaration(parent) || ts4.isEnumDeclaration(parent) || ts4.isEnumMember(parent) || ts4.isFunctionDeclaration(parent) || ts4.isFunctionExpression(parent) || ts4.isImportClause(parent) || ts4.isImportEqualsDeclaration(parent) || ts4.isImportSpecifier(parent) || ts4.isInterfaceDeclaration(parent) || ts4.isMethodDeclaration(parent) || ts4.isMethodSignature(parent) || ts4.isModuleDeclaration(parent) || ts4.isNamespaceExport(parent) || ts4.isNamespaceImport(parent) || ts4.isParameter(parent) || ts4.isPropertyDeclaration(parent) || ts4.isPropertySignature(parent) || ts4.isSetAccessorDeclaration(parent) || ts4.isGetAccessorDeclaration(parent) || ts4.isTypeAliasDeclaration(parent) || ts4.isTypeParameterDeclaration(parent) || ts4.isVariableDeclaration(parent)) && parent.name === node) {
2535
+ if ((ts3.isBindingElement(parent) || ts3.isClassDeclaration(parent) || ts3.isEnumDeclaration(parent) || ts3.isEnumMember(parent) || ts3.isFunctionDeclaration(parent) || ts3.isFunctionExpression(parent) || ts3.isImportClause(parent) || ts3.isImportEqualsDeclaration(parent) || ts3.isImportSpecifier(parent) || ts3.isInterfaceDeclaration(parent) || ts3.isMethodDeclaration(parent) || ts3.isMethodSignature(parent) || ts3.isModuleDeclaration(parent) || ts3.isNamespaceExport(parent) || ts3.isNamespaceImport(parent) || ts3.isParameter(parent) || ts3.isPropertyDeclaration(parent) || ts3.isPropertySignature(parent) || ts3.isSetAccessorDeclaration(parent) || ts3.isGetAccessorDeclaration(parent) || ts3.isTypeAliasDeclaration(parent) || ts3.isTypeParameterDeclaration(parent) || ts3.isVariableDeclaration(parent)) && parent.name === node) {
2461
2536
  return true;
2462
2537
  }
2463
- if ((ts4.isPropertyAssignment(parent) || ts4.isPropertyAccessExpression(parent)) && parent.name === node) {
2538
+ if ((ts3.isPropertyAssignment(parent) || ts3.isPropertyAccessExpression(parent)) && parent.name === node) {
2464
2539
  return true;
2465
2540
  }
2466
- if (ts4.isQualifiedName(parent) && parent.right === node) {
2541
+ if (ts3.isQualifiedName(parent) && parent.right === node) {
2467
2542
  return true;
2468
2543
  }
2469
2544
  return false;
@@ -2475,20 +2550,20 @@ function astReferencesImportedName(root, importedNames) {
2475
2550
  let found = false;
2476
2551
  const visit = (node) => {
2477
2552
  if (found) return;
2478
- if (ts4.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
2553
+ if (ts3.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
2479
2554
  found = true;
2480
2555
  return;
2481
2556
  }
2482
- ts4.forEachChild(node, visit);
2557
+ ts3.forEachChild(node, visit);
2483
2558
  };
2484
2559
  visit(root);
2485
2560
  return found;
2486
2561
  }
2487
2562
  function getObjectMembers(statement) {
2488
- if (ts4.isInterfaceDeclaration(statement)) {
2563
+ if (ts3.isInterfaceDeclaration(statement)) {
2489
2564
  return statement.members;
2490
2565
  }
2491
- if (ts4.isTypeLiteralNode(statement.type)) {
2566
+ if (ts3.isTypeLiteralNode(statement.type)) {
2492
2567
  return statement.type.members;
2493
2568
  }
2494
2569
  return void 0;
@@ -2500,7 +2575,7 @@ function rewriteImportedMemberTypes(statement, sourceFile, importedNames) {
2500
2575
  }
2501
2576
  const replacements = [];
2502
2577
  for (const member of members) {
2503
- if (!ts4.isPropertySignature(member)) {
2578
+ if (!ts3.isPropertySignature(member)) {
2504
2579
  if (astReferencesImportedName(member, importedNames)) {
2505
2580
  return null;
2506
2581
  }
@@ -2532,14 +2607,14 @@ function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
2532
2607
  );
2533
2608
  const result = [];
2534
2609
  for (const statement of sourceFile.statements) {
2535
- if (ts4.isImportDeclaration(statement)) continue;
2536
- if (ts4.isImportEqualsDeclaration(statement)) continue;
2537
- if (ts4.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
2610
+ if (ts3.isImportDeclaration(statement)) continue;
2611
+ if (ts3.isImportEqualsDeclaration(statement)) continue;
2612
+ if (ts3.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
2538
2613
  if (!astReferencesImportedName(statement, importedNamesToSkip)) {
2539
2614
  result.push(statement.getText(sourceFile));
2540
2615
  continue;
2541
2616
  }
2542
- if (ts4.isInterfaceDeclaration(statement) || ts4.isTypeAliasDeclaration(statement)) {
2617
+ if (ts3.isInterfaceDeclaration(statement) || ts3.isTypeAliasDeclaration(statement)) {
2543
2618
  const rewritten = rewriteImportedMemberTypes(statement, sourceFile, importedNamesToSkip);
2544
2619
  if (rewritten !== null) {
2545
2620
  result.push(rewritten);
@@ -2564,6 +2639,7 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
2564
2639
  sourceFile,
2565
2640
  tagName,
2566
2641
  parsedTag,
2642
+ text,
2567
2643
  provenance,
2568
2644
  supportingDeclarations,
2569
2645
  options
@@ -2572,7 +2648,7 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
2572
2648
  pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2573
2649
  return;
2574
2650
  }
2575
- const constraintNode = (0, import_internal3.parseConstraintTagValue)(
2651
+ const constraintNode = (0, import_internal4.parseConstraintTagValue)(
2576
2652
  tagName,
2577
2653
  text,
2578
2654
  provenance,
@@ -2591,6 +2667,9 @@ function renderSyntheticArgumentExpression(valueKind, argumentText) {
2591
2667
  case "number":
2592
2668
  case "integer":
2593
2669
  case "signedInteger":
2670
+ if (trimmed === "Infinity" || trimmed === "-Infinity" || trimmed === "NaN") {
2671
+ return trimmed;
2672
+ }
2594
2673
  return Number.isFinite(Number(trimmed)) ? trimmed : JSON.stringify(trimmed);
2595
2674
  case "string":
2596
2675
  return JSON.stringify(argumentText);
@@ -2622,12 +2701,12 @@ function supportsConstraintCapability(type, checker, capability) {
2622
2701
  if (capability === void 0) {
2623
2702
  return true;
2624
2703
  }
2625
- if ((0, import_internal3.hasTypeSemanticCapability)(type, checker, capability)) {
2704
+ if ((0, import_internal4.hasTypeSemanticCapability)(type, checker, capability)) {
2626
2705
  return true;
2627
2706
  }
2628
2707
  if (capability === "string-like") {
2629
2708
  const itemType = getArrayElementType(type, checker);
2630
- return itemType !== null && (0, import_internal3.hasTypeSemanticCapability)(itemType, checker, capability);
2709
+ return itemType !== null && (0, import_internal4.hasTypeSemanticCapability)(itemType, checker, capability);
2631
2710
  }
2632
2711
  return false;
2633
2712
  }
@@ -2638,7 +2717,7 @@ function stripHintNullishUnion(type) {
2638
2717
  return type;
2639
2718
  }
2640
2719
  const nonNullish = type.types.filter(
2641
- (member) => (member.flags & (ts4.TypeFlags.Null | ts4.TypeFlags.Undefined)) === 0
2720
+ (member) => (member.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined)) === 0
2642
2721
  );
2643
2722
  if (nonNullish.length === 1 && nonNullish[0] !== void 0) {
2644
2723
  return nonNullish[0];
@@ -2654,10 +2733,10 @@ function isUserEmittableHintProperty(property, declaration) {
2654
2733
  }
2655
2734
  if ("name" in declaration && declaration.name !== void 0) {
2656
2735
  const name = declaration.name;
2657
- if (ts4.isComputedPropertyName(name) || ts4.isPrivateIdentifier(name)) {
2736
+ if (ts3.isComputedPropertyName(name) || ts3.isPrivateIdentifier(name)) {
2658
2737
  return false;
2659
2738
  }
2660
- if (!ts4.isIdentifier(name) && !ts4.isStringLiteral(name) && !ts4.isNumericLiteral(name)) {
2739
+ if (!ts3.isIdentifier(name) && !ts3.isStringLiteral(name) && !ts3.isNumericLiteral(name)) {
2661
2740
  return false;
2662
2741
  }
2663
2742
  }
@@ -2673,7 +2752,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
2673
2752
  if (isCallableType(stripped)) {
2674
2753
  return;
2675
2754
  }
2676
- if (!(0, import_internal3.hasTypeSemanticCapability)(stripped, checker, "object-like")) {
2755
+ if (!(0, import_internal4.hasTypeSemanticCapability)(stripped, checker, "object-like")) {
2677
2756
  return;
2678
2757
  }
2679
2758
  for (const property of stripped.getProperties()) {
@@ -2691,7 +2770,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
2691
2770
  continue;
2692
2771
  }
2693
2772
  const strippedPropertyType = stripHintNullishUnion(propertyType);
2694
- if (!isCallableType(strippedPropertyType) && (0, import_internal3.hasTypeSemanticCapability)(strippedPropertyType, checker, "object-like")) {
2773
+ if (!isCallableType(strippedPropertyType) && (0, import_internal4.hasTypeSemanticCapability)(strippedPropertyType, checker, "object-like")) {
2695
2774
  visit(strippedPropertyType, path4, depth + 1);
2696
2775
  }
2697
2776
  }
@@ -2700,7 +2779,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
2700
2779
  return out;
2701
2780
  }
2702
2781
  function buildPathTargetHint(subjectType, checker, capability, tagName, argumentText) {
2703
- if (!(0, import_internal3.hasTypeSemanticCapability)(subjectType, checker, "object-like")) {
2782
+ if (!(0, import_internal4.hasTypeSemanticCapability)(subjectType, checker, "object-like")) {
2704
2783
  return null;
2705
2784
  }
2706
2785
  const candidates = collectObjectSubfieldCandidates(subjectType, checker, capability);
@@ -2802,7 +2881,7 @@ function hasBuiltinConstraintBroadening(tagName, options) {
2802
2881
  const broadenedTypeId = getBroadenedCustomTypeId(options?.fieldType);
2803
2882
  return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
2804
2883
  }
2805
- function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, provenance, supportingDeclarations, options) {
2884
+ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, rawText, provenance, supportingDeclarations, options) {
2806
2885
  if (!(0, import_internals4.isBuiltinConstraintName)(tagName)) {
2807
2886
  return [];
2808
2887
  }
@@ -2811,22 +2890,24 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2811
2890
  if (checker === void 0 || subjectType === void 0) {
2812
2891
  return [];
2813
2892
  }
2814
- const placement = (0, import_internal3.resolveDeclarationPlacement)(node);
2893
+ const placement = (0, import_internal4.resolveDeclarationPlacement)(node);
2815
2894
  if (placement === null) {
2816
2895
  return [];
2817
2896
  }
2818
- const definition = (0, import_internal3.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
2897
+ const definition = (0, import_internal4.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
2819
2898
  if (definition === null) {
2820
2899
  return [];
2821
2900
  }
2822
2901
  const nonNullPlacement = placement;
2823
- const log = (0, import_internal4.getBuildLogger)();
2824
- const broadeningLog = (0, import_internal4.getBroadeningLogger)();
2825
- const syntheticLog = (0, import_internal4.getSyntheticLogger)();
2902
+ const log = (0, import_internal5.getBuildLogger)();
2903
+ const broadeningLog = (0, import_internal5.getBroadeningLogger)();
2904
+ const syntheticLog = (0, import_internal5.getSyntheticLogger)();
2905
+ const typedParserLog = (0, import_internal5.getTypedParserLogger)();
2826
2906
  const logsEnabled = log !== import_core3.noopLogger || broadeningLog !== import_core3.noopLogger;
2827
2907
  const syntheticTraceEnabled = syntheticLog !== import_core3.noopLogger;
2828
- const logStart = logsEnabled ? (0, import_internal4.nowMicros)() : 0;
2829
- const subjectTypeKind = logsEnabled ? (0, import_internal4.describeTypeKind)(subjectType, checker) : "";
2908
+ const typedParserTraceEnabled = typedParserLog !== import_core3.noopLogger;
2909
+ const logStart = logsEnabled ? (0, import_internal5.nowMicros)() : 0;
2910
+ const subjectTypeKind = logsEnabled ? (0, import_internal5.describeTypeKind)(subjectType, checker) : "";
2830
2911
  function emit(outcome, result2) {
2831
2912
  if (!logsEnabled) {
2832
2913
  return result2;
@@ -2837,11 +2918,11 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2837
2918
  placement: nonNullPlacement,
2838
2919
  subjectTypeKind,
2839
2920
  roleOutcome: outcome,
2840
- elapsedMicros: (0, import_internal4.elapsedMicros)(logStart)
2921
+ elapsedMicros: (0, import_internal5.elapsedMicros)(logStart)
2841
2922
  };
2842
- (0, import_internal4.logTagApplication)(log, entry);
2923
+ (0, import_internal5.logTagApplication)(log, entry);
2843
2924
  if (outcome === "bypass" || outcome === "D1" || outcome === "D2") {
2844
- (0, import_internal4.logTagApplication)(broadeningLog, entry);
2925
+ (0, import_internal5.logTagApplication)(broadeningLog, entry);
2845
2926
  }
2846
2927
  return result2;
2847
2928
  }
@@ -2876,7 +2957,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2876
2957
  )
2877
2958
  ]);
2878
2959
  }
2879
- const resolution = (0, import_internal3.resolvePathTargetType)(subjectType, checker, target.path.segments);
2960
+ const resolution = (0, import_internal4.resolvePathTargetType)(subjectType, checker, target.path.segments);
2880
2961
  if (resolution.kind === "missing-property") {
2881
2962
  return emit("B-reject", [
2882
2963
  makeDiagnostic(
@@ -2901,7 +2982,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2901
2982
  }
2902
2983
  const hasBroadening = (() => {
2903
2984
  if (target === null) {
2904
- if (isIntegerBrandedType((0, import_internal3.stripNullishUnion)(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
2985
+ if ((0, import_internal3._isIntegerBrandedType)((0, import_internal4.stripNullishUnion)(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
2905
2986
  return true;
2906
2987
  }
2907
2988
  return hasBuiltinConstraintBroadening(tagName, options);
@@ -2932,16 +3013,41 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2932
3013
  ]);
2933
3014
  }
2934
3015
  }
2935
- const argumentExpression = renderSyntheticArgumentExpression(
2936
- definition.valueKind,
2937
- parsedTag?.argumentText ?? ""
2938
- );
2939
- if (definition.requiresArgument && argumentExpression === null) {
2940
- return emit("A-pass", []);
2941
- }
2942
3016
  if (hasBroadening) {
2943
3017
  return emit("bypass", []);
2944
3018
  }
3019
+ const effectiveArgumentText = (0, import_internal5.extractEffectiveArgumentText)(tagName, rawText, parsedTag);
3020
+ const typedParseResult = (0, import_internal5.parseTagArgument)(tagName, effectiveArgumentText, "build");
3021
+ if (!typedParseResult.ok) {
3022
+ if (typedParserTraceEnabled) {
3023
+ typedParserLog.trace("typed-parser C-reject", {
3024
+ consumer: "build",
3025
+ tag: tagName,
3026
+ placement: nonNullPlacement,
3027
+ subjectTypeKind: subjectTypeKind !== "" ? subjectTypeKind : "-",
3028
+ roleOutcome: "C-reject",
3029
+ diagnosticCode: typedParseResult.diagnostic.code
3030
+ });
3031
+ }
3032
+ const mappedCode = (0, import_internal5.mapTypedParserDiagnosticCode)(typedParseResult.diagnostic.code, tagName);
3033
+ return emit("C-reject", [
3034
+ makeDiagnostic(mappedCode, typedParseResult.diagnostic.message, provenance)
3035
+ ]);
3036
+ }
3037
+ if (typedParserTraceEnabled) {
3038
+ typedParserLog.trace("typed-parser C-pass", {
3039
+ consumer: "build",
3040
+ tag: tagName,
3041
+ placement: nonNullPlacement,
3042
+ subjectTypeKind: subjectTypeKind !== "" ? subjectTypeKind : "-",
3043
+ roleOutcome: "C-pass",
3044
+ valueKind: typedParseResult.value.kind
3045
+ });
3046
+ }
3047
+ const argumentExpression = renderSyntheticArgumentExpression(
3048
+ definition.valueKind,
3049
+ effectiveArgumentText
3050
+ );
2945
3051
  const subjectTypeText = checker.typeToString(subjectType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
2946
3052
  const hostType = options?.hostType ?? subjectType;
2947
3053
  const hostTypeText = checker.typeToString(hostType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
@@ -2954,7 +3060,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2954
3060
  subjectTypeText
2955
3061
  });
2956
3062
  }
2957
- const result = (0, import_internal3.checkSyntheticTagApplication)({
3063
+ const result = (0, import_internal4.checkSyntheticTagApplication)({
2958
3064
  tagName,
2959
3065
  placement,
2960
3066
  hostType: hostTypeText,
@@ -2980,13 +3086,13 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2980
3086
  } : {}
2981
3087
  });
2982
3088
  if (result.diagnostics.length === 0) {
2983
- return emit("C-pass", []);
3089
+ return emit("D-pass", []);
2984
3090
  }
2985
3091
  const setupDiagnostic = result.diagnostics.find((diagnostic) => diagnostic.kind !== "typescript");
2986
3092
  if (setupDiagnostic !== void 0) {
2987
3093
  return emit("C-reject", [
2988
3094
  makeDiagnostic(
2989
- setupDiagnostic.kind === "unsupported-custom-type-override" ? "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" : "SYNTHETIC_SETUP_FAILURE",
3095
+ (0, import_internal5._mapSetupDiagnosticCode)(setupDiagnostic.kind),
2990
3096
  setupDiagnostic.message,
2991
3097
  provenance
2992
3098
  )
@@ -3005,10 +3111,10 @@ var parseResultCache = /* @__PURE__ */ new Map();
3005
3111
  function getExtensionTagNames(options) {
3006
3112
  return [
3007
3113
  ...options?.extensionRegistry?.extensions.flatMap(
3008
- (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal3.normalizeFormSpecTagName)(tag.tagName))
3114
+ (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal4.normalizeFormSpecTagName)(tag.tagName))
3009
3115
  ) ?? [],
3010
3116
  ...options?.extensionRegistry?.extensions.flatMap(
3011
- (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal3.normalizeFormSpecTagName)(slot.tagName))
3117
+ (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal4.normalizeFormSpecTagName)(slot.tagName))
3012
3118
  ) ?? []
3013
3119
  ].sort();
3014
3120
  }
@@ -3020,9 +3126,9 @@ function getExtensionRegistryCacheKey(registry) {
3020
3126
  (extension) => JSON.stringify({
3021
3127
  extensionId: extension.extensionId,
3022
3128
  typeNames: extension.types?.map((type) => type.typeName) ?? [],
3023
- constraintTags: extension.constraintTags?.map((tag) => (0, import_internal3.normalizeFormSpecTagName)(tag.tagName)) ?? [],
3129
+ constraintTags: extension.constraintTags?.map((tag) => (0, import_internal4.normalizeFormSpecTagName)(tag.tagName)) ?? [],
3024
3130
  metadataSlots: extension.metadataSlots?.map((slot) => ({
3025
- tagName: (0, import_internal3.normalizeFormSpecTagName)(slot.tagName),
3131
+ tagName: (0, import_internal4.normalizeFormSpecTagName)(slot.tagName),
3026
3132
  declarationKinds: [...slot.declarationKinds].sort(),
3027
3133
  allowBare: slot.allowBare !== false,
3028
3134
  qualifiers: (slot.qualifiers ?? []).map((qualifier) => ({
@@ -3054,6 +3160,16 @@ function parseTSDocTags(node, file = "", options) {
3054
3160
  if (cached !== void 0) {
3055
3161
  return cached;
3056
3162
  }
3163
+ const setupDiags = options?.extensionRegistry?.setupDiagnostics;
3164
+ if (setupDiags !== void 0 && setupDiags.length > 0) {
3165
+ const result2 = {
3166
+ constraints: [],
3167
+ annotations: [],
3168
+ diagnostics: (0, import_internal5._emitSetupDiagnostics)(setupDiags, file)
3169
+ };
3170
+ parseResultCache.set(cacheKey, result2);
3171
+ return result2;
3172
+ }
3057
3173
  const constraints = [];
3058
3174
  const annotations = [];
3059
3175
  const diagnostics = [];
@@ -3065,12 +3181,12 @@ function parseTSDocTags(node, file = "", options) {
3065
3181
  const sourceText = sourceFile.getFullText();
3066
3182
  const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
3067
3183
  const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
3068
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
3184
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
3069
3185
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
3070
3186
  const extensionTagNames = getExtensionTagNames(options);
3071
3187
  if (commentRanges) {
3072
3188
  for (const range of commentRanges) {
3073
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) {
3189
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) {
3074
3190
  continue;
3075
3191
  }
3076
3192
  const commentText = sourceText.substring(range.pos, range.end);
@@ -3078,7 +3194,7 @@ function parseTSDocTags(node, file = "", options) {
3078
3194
  continue;
3079
3195
  }
3080
3196
  const extensions = options?.extensionRegistry?.extensions;
3081
- const unified = (0, import_internal3.parseUnifiedComment)(commentText, {
3197
+ const unified = (0, import_internal4.parseUnifiedComment)(commentText, {
3082
3198
  offset: range.pos,
3083
3199
  extensionTagNames,
3084
3200
  ...extensions !== void 0 ? { extensions } : {}
@@ -3113,13 +3229,13 @@ function parseTSDocTags(node, file = "", options) {
3113
3229
  }
3114
3230
  continue;
3115
3231
  }
3116
- if (import_internal3.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
3232
+ if (import_internal4.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
3117
3233
  const fallback = rawTextFallbacks.get(tagName)?.shift();
3118
- const text2 = (0, import_internal3.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
3234
+ const text2 = (0, import_internal4.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
3119
3235
  if (text2 === "") continue;
3120
3236
  const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
3121
3237
  if (tagName === "defaultValue") {
3122
- annotations.push((0, import_internal3.parseDefaultValueTagValue)(text2, provenance2));
3238
+ annotations.push((0, import_internal4.parseDefaultValueTagValue)(text2, provenance2));
3123
3239
  continue;
3124
3240
  }
3125
3241
  processConstraintTag(
@@ -3201,7 +3317,7 @@ function parseTSDocTags(node, file = "", options) {
3201
3317
  if (text === "") continue;
3202
3318
  const provenance = fallback.provenance;
3203
3319
  if (tagName === "defaultValue") {
3204
- annotations.push((0, import_internal3.parseDefaultValueTagValue)(text, provenance));
3320
+ annotations.push((0, import_internal4.parseDefaultValueTagValue)(text, provenance));
3205
3321
  continue;
3206
3322
  }
3207
3323
  processConstraintTag(
@@ -3227,13 +3343,13 @@ function extractDisplayNameMetadata(node) {
3227
3343
  const memberDisplayNames = /* @__PURE__ */ new Map();
3228
3344
  const sourceFile = node.getSourceFile();
3229
3345
  const sourceText = sourceFile.getFullText();
3230
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
3346
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
3231
3347
  if (commentRanges) {
3232
3348
  for (const range of commentRanges) {
3233
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) continue;
3349
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) continue;
3234
3350
  const commentText = sourceText.substring(range.pos, range.end);
3235
3351
  if (!commentText.startsWith("/**")) continue;
3236
- const unified = (0, import_internal3.parseUnifiedComment)(commentText);
3352
+ const unified = (0, import_internal4.parseUnifiedComment)(commentText);
3237
3353
  for (const tag of unified.tags) {
3238
3354
  if (tag.normalizedTagName !== "displayName") {
3239
3355
  continue;
@@ -3255,9 +3371,9 @@ function extractDisplayNameMetadata(node) {
3255
3371
  }
3256
3372
  function collectRawTextFallbacks(node, file) {
3257
3373
  const fallbacks = /* @__PURE__ */ new Map();
3258
- for (const tag of ts4.getJSDocTags(node)) {
3374
+ for (const tag of ts3.getJSDocTags(node)) {
3259
3375
  const tagName = (0, import_internals4.normalizeConstraintTagName)(tag.tagName.text);
3260
- if (!import_internal3.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
3376
+ if (!import_internal4.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
3261
3377
  const commentText = getTagCommentText(tag)?.trim() ?? "";
3262
3378
  if (commentText === "") continue;
3263
3379
  const entries = fallbacks.get(tagName) ?? [];
@@ -3270,7 +3386,7 @@ function collectRawTextFallbacks(node, file) {
3270
3386
  return fallbacks;
3271
3387
  }
3272
3388
  function isMemberTargetDisplayName(text) {
3273
- return (0, import_internal3.parseTagSyntax)("displayName", text).target !== null;
3389
+ return (0, import_internal4.parseTagSyntax)("displayName", text).target !== null;
3274
3390
  }
3275
3391
  function provenanceForComment(range, sourceFile, file, tagName) {
3276
3392
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(range.pos);
@@ -3310,7 +3426,7 @@ function getTagCommentText(tag) {
3310
3426
  if (typeof tag.comment === "string") {
3311
3427
  return tag.comment;
3312
3428
  }
3313
- return ts4.getTextOfJSDocComment(tag.comment);
3429
+ return ts3.getTextOfJSDocComment(tag.comment);
3314
3430
  }
3315
3431
 
3316
3432
  // src/analyzer/jsdoc-constraints.ts
@@ -3328,18 +3444,18 @@ function extractJSDocAnnotationNodes(node, file = "", options) {
3328
3444
  function extractDefaultValueAnnotation(initializer, file = "") {
3329
3445
  if (!initializer) return null;
3330
3446
  let value;
3331
- if (ts5.isStringLiteral(initializer)) {
3447
+ if (ts4.isStringLiteral(initializer)) {
3332
3448
  value = initializer.text;
3333
- } else if (ts5.isNumericLiteral(initializer)) {
3449
+ } else if (ts4.isNumericLiteral(initializer)) {
3334
3450
  value = Number(initializer.text);
3335
- } else if (initializer.kind === ts5.SyntaxKind.TrueKeyword) {
3451
+ } else if (initializer.kind === ts4.SyntaxKind.TrueKeyword) {
3336
3452
  value = true;
3337
- } else if (initializer.kind === ts5.SyntaxKind.FalseKeyword) {
3453
+ } else if (initializer.kind === ts4.SyntaxKind.FalseKeyword) {
3338
3454
  value = false;
3339
- } else if (initializer.kind === ts5.SyntaxKind.NullKeyword) {
3455
+ } else if (initializer.kind === ts4.SyntaxKind.NullKeyword) {
3340
3456
  value = null;
3341
- } else if (ts5.isPrefixUnaryExpression(initializer)) {
3342
- if (initializer.operator === ts5.SyntaxKind.MinusToken && ts5.isNumericLiteral(initializer.operand)) {
3457
+ } else if (ts4.isPrefixUnaryExpression(initializer)) {
3458
+ if (initializer.operator === ts4.SyntaxKind.MinusToken && ts4.isNumericLiteral(initializer.operand)) {
3343
3459
  value = -Number(initializer.operand.text);
3344
3460
  }
3345
3461
  }
@@ -3361,28 +3477,28 @@ function extractDefaultValueAnnotation(initializer, file = "") {
3361
3477
 
3362
3478
  // src/analyzer/class-analyzer.ts
3363
3479
  function isObjectType(type) {
3364
- return !!(type.flags & ts6.TypeFlags.Object);
3480
+ return !!(type.flags & ts5.TypeFlags.Object);
3365
3481
  }
3366
3482
  function isIntersectionType(type) {
3367
- return !!(type.flags & ts6.TypeFlags.Intersection);
3483
+ return !!(type.flags & ts5.TypeFlags.Intersection);
3368
3484
  }
3369
3485
  function isResolvableObjectLikeAliasTypeNode(typeNode) {
3370
- if (ts6.isParenthesizedTypeNode(typeNode)) {
3486
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3371
3487
  return isResolvableObjectLikeAliasTypeNode(typeNode.type);
3372
3488
  }
3373
- if (ts6.isTypeLiteralNode(typeNode) || ts6.isTypeReferenceNode(typeNode)) {
3489
+ if (ts5.isTypeLiteralNode(typeNode) || ts5.isTypeReferenceNode(typeNode)) {
3374
3490
  return true;
3375
3491
  }
3376
- return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
3492
+ return ts5.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
3377
3493
  }
3378
3494
  function isSemanticallyPlainObjectLikeType(type, checker) {
3379
3495
  if (isIntersectionType(type)) {
3380
3496
  return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
3381
3497
  }
3382
- return isObjectType(type) && checker.getSignaturesOfType(type, ts6.SignatureKind.Call).length === 0 && checker.getSignaturesOfType(type, ts6.SignatureKind.Construct).length === 0 && !checker.isArrayType(type) && !checker.isTupleType(type);
3498
+ return isObjectType(type) && checker.getSignaturesOfType(type, ts5.SignatureKind.Call).length === 0 && checker.getSignaturesOfType(type, ts5.SignatureKind.Construct).length === 0 && !checker.isArrayType(type) && !checker.isTupleType(type);
3383
3499
  }
3384
3500
  function isTypeReference(type) {
3385
- return !!(type.flags & ts6.TypeFlags.Object) && !!(type.objectFlags & ts6.ObjectFlags.Reference);
3501
+ return !!(type.flags & ts5.TypeFlags.Object) && !!(type.objectFlags & ts5.ObjectFlags.Reference);
3386
3502
  }
3387
3503
  var RESOLVING_TYPE_PLACEHOLDER = {
3388
3504
  kind: "object",
@@ -3408,8 +3524,23 @@ function createAnalyzerMetadataPolicy(input, discriminator) {
3408
3524
  discriminator
3409
3525
  };
3410
3526
  }
3527
+ var DEDUPLICATABLE_DIAGNOSTIC_CODES = /* @__PURE__ */ new Set([
3528
+ "SYNTHETIC_SETUP_FAILURE",
3529
+ "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE"
3530
+ ]);
3531
+ function deduplicateDiagnostics(diagnostics) {
3532
+ if (diagnostics.length <= 1) return diagnostics;
3533
+ const seen = /* @__PURE__ */ new Set();
3534
+ return diagnostics.filter((d) => {
3535
+ if (!DEDUPLICATABLE_DIAGNOSTIC_CODES.has(d.code)) return true;
3536
+ const key = `${d.code}\0${d.message}`;
3537
+ if (seen.has(key)) return false;
3538
+ seen.add(key);
3539
+ return true;
3540
+ });
3541
+ }
3411
3542
  function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node, checker, extensionRegistry, buildContext) {
3412
- const analysis = (0, import_internal5.analyzeMetadataForNodeWithChecker)({
3543
+ const analysis = (0, import_internal6.analyzeMetadataForNodeWithChecker)({
3413
3544
  checker,
3414
3545
  node,
3415
3546
  logicalName,
@@ -3444,10 +3575,121 @@ function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node,
3444
3575
  }
3445
3576
  return resolvedMetadata;
3446
3577
  }
3578
+ var INHERITABLE_TYPE_ANNOTATION_KINDS = /* @__PURE__ */ new Set(["format"]);
3579
+ function getInheritableAnnotationStringValue(annotation) {
3580
+ if (annotation.annotationKind === "format") return annotation.value;
3581
+ return void 0;
3582
+ }
3583
+ function isOverridingInheritableAnnotation(annotation) {
3584
+ const value = getInheritableAnnotationStringValue(annotation);
3585
+ if (value === void 0) return true;
3586
+ return value.trim().length > 0;
3587
+ }
3588
+ function collectInheritedTypeAnnotations(derivedDecl, existingAnnotations, checker, extensionRegistry) {
3589
+ const existingKinds = new Set(
3590
+ existingAnnotations.filter(isOverridingInheritableAnnotation).map((a) => a.annotationKind)
3591
+ );
3592
+ const needed = /* @__PURE__ */ new Set();
3593
+ for (const kind of INHERITABLE_TYPE_ANNOTATION_KINDS) {
3594
+ if (!existingKinds.has(kind)) needed.add(kind);
3595
+ }
3596
+ if (needed.size === 0) return [];
3597
+ const inherited = [];
3598
+ const seen = /* @__PURE__ */ new Set([derivedDecl]);
3599
+ const queue = [];
3600
+ const resolveSymbolTarget = (sym) => {
3601
+ if ((sym.flags & ts5.SymbolFlags.Alias) === 0) return sym;
3602
+ try {
3603
+ return checker.getAliasedSymbol(sym);
3604
+ } catch {
3605
+ return sym;
3606
+ }
3607
+ };
3608
+ const isObjectShapedTypeAlias = (alias) => {
3609
+ const type = checker.getTypeFromTypeNode(alias.type);
3610
+ if ((type.flags & ts5.TypeFlags.Object) !== 0) return true;
3611
+ if (type.isIntersection()) return true;
3612
+ return false;
3613
+ };
3614
+ const enqueueCandidate = (baseDecl, fromTypeAliasRhs) => {
3615
+ if (seen.has(baseDecl)) return;
3616
+ if (ts5.isClassDeclaration(baseDecl) || ts5.isInterfaceDeclaration(baseDecl)) {
3617
+ seen.add(baseDecl);
3618
+ queue.push(baseDecl);
3619
+ return;
3620
+ }
3621
+ if (ts5.isTypeAliasDeclaration(baseDecl)) {
3622
+ if (!fromTypeAliasRhs && !isObjectShapedTypeAlias(baseDecl)) return;
3623
+ seen.add(baseDecl);
3624
+ queue.push(baseDecl);
3625
+ }
3626
+ };
3627
+ const enqueueBasesOf = (decl) => {
3628
+ if (ts5.isTypeAliasDeclaration(decl)) {
3629
+ const rhs = decl.type;
3630
+ if (!ts5.isTypeReferenceNode(rhs)) return;
3631
+ const sym = checker.getSymbolAtLocation(rhs.typeName);
3632
+ if (!sym) return;
3633
+ const target = resolveSymbolTarget(sym);
3634
+ for (const baseDecl of target.declarations ?? []) {
3635
+ enqueueCandidate(
3636
+ baseDecl,
3637
+ /*fromTypeAliasRhs*/
3638
+ true
3639
+ );
3640
+ }
3641
+ return;
3642
+ }
3643
+ const heritageClauses = decl.heritageClauses;
3644
+ if (!heritageClauses) return;
3645
+ for (const clause of heritageClauses) {
3646
+ if (clause.token !== ts5.SyntaxKind.ExtendsKeyword) continue;
3647
+ for (const typeExpr of clause.types) {
3648
+ const sym = checker.getSymbolAtLocation(typeExpr.expression);
3649
+ if (!sym) continue;
3650
+ const target = resolveSymbolTarget(sym);
3651
+ for (const baseDecl of target.declarations ?? []) {
3652
+ enqueueCandidate(
3653
+ baseDecl,
3654
+ /*fromTypeAliasRhs*/
3655
+ false
3656
+ );
3657
+ }
3658
+ }
3659
+ }
3660
+ };
3661
+ enqueueBasesOf(derivedDecl);
3662
+ for (let queueIndex = 0; queueIndex < queue.length && needed.size > 0; queueIndex++) {
3663
+ const baseDecl = queue[queueIndex];
3664
+ if (baseDecl === void 0) continue;
3665
+ const baseFile = baseDecl.getSourceFile().fileName;
3666
+ const baseAnnotations = extractJSDocAnnotationNodes(
3667
+ baseDecl,
3668
+ baseFile,
3669
+ makeParseOptions(extensionRegistry)
3670
+ );
3671
+ for (const annotation of baseAnnotations) {
3672
+ if (!needed.has(annotation.annotationKind)) continue;
3673
+ if (!isOverridingInheritableAnnotation(annotation)) continue;
3674
+ inherited.push(annotation);
3675
+ needed.delete(annotation.annotationKind);
3676
+ }
3677
+ if (needed.size > 0) {
3678
+ enqueueBasesOf(baseDecl);
3679
+ }
3680
+ }
3681
+ return inherited;
3682
+ }
3683
+ function extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) {
3684
+ const local = extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry));
3685
+ const inherited = collectInheritedTypeAnnotations(namedDecl, local, checker, extensionRegistry);
3686
+ if (inherited.length === 0) return [...local];
3687
+ return [...local, ...inherited];
3688
+ }
3447
3689
  function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRegistry, metadataPolicy) {
3448
3690
  const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
3449
3691
  const declarationType = checker.getTypeAtLocation(declaration);
3450
- const logicalName = ts6.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
3692
+ const logicalName = ts5.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
3451
3693
  const docResult = extractJSDocParseResult(
3452
3694
  declaration,
3453
3695
  file,
@@ -3489,13 +3731,19 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3489
3731
  file,
3490
3732
  makeParseOptions(extensionRegistry, void 0, checker, classType, classType)
3491
3733
  );
3492
- const annotations = [...classDoc.annotations];
3734
+ const inheritedClassAnnotations = collectInheritedTypeAnnotations(
3735
+ classDecl,
3736
+ classDoc.annotations,
3737
+ checker,
3738
+ extensionRegistry
3739
+ );
3740
+ const annotations = [...classDoc.annotations, ...inheritedClassAnnotations];
3493
3741
  diagnostics.push(...classDoc.diagnostics);
3494
3742
  const visiting = /* @__PURE__ */ new Set();
3495
3743
  const instanceMethods = [];
3496
3744
  const staticMethods = [];
3497
3745
  for (const member of classDecl.members) {
3498
- if (ts6.isPropertyDeclaration(member)) {
3746
+ if (ts5.isPropertyDeclaration(member)) {
3499
3747
  const fieldNode = analyzeFieldToIR(
3500
3748
  member,
3501
3749
  checker,
@@ -3511,10 +3759,10 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3511
3759
  fields.push(fieldNode);
3512
3760
  fieldLayouts.push({});
3513
3761
  }
3514
- } else if (ts6.isMethodDeclaration(member)) {
3762
+ } else if (ts5.isMethodDeclaration(member)) {
3515
3763
  const methodInfo = analyzeMethod(member, checker);
3516
3764
  if (methodInfo) {
3517
- const isStatic = member.modifiers?.some((m) => m.kind === ts6.SyntaxKind.StaticKeyword);
3765
+ const isStatic = member.modifiers?.some((m) => m.kind === ts5.SyntaxKind.StaticKeyword);
3518
3766
  if (isStatic) {
3519
3767
  staticMethods.push(methodInfo);
3520
3768
  } else {
@@ -3546,6 +3794,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3546
3794
  hostType: classType
3547
3795
  }
3548
3796
  );
3797
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3549
3798
  return {
3550
3799
  name,
3551
3800
  ...metadata !== void 0 && { metadata },
@@ -3553,7 +3802,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3553
3802
  fieldLayouts,
3554
3803
  typeRegistry,
3555
3804
  ...annotations.length > 0 && { annotations },
3556
- ...diagnostics.length > 0 && { diagnostics },
3805
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3557
3806
  instanceMethods,
3558
3807
  staticMethods
3559
3808
  };
@@ -3573,11 +3822,20 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3573
3822
  file,
3574
3823
  makeParseOptions(extensionRegistry, void 0, checker, interfaceType, interfaceType)
3575
3824
  );
3576
- const annotations = [...interfaceDoc.annotations];
3825
+ const inheritedInterfaceAnnotations = collectInheritedTypeAnnotations(
3826
+ interfaceDecl,
3827
+ interfaceDoc.annotations,
3828
+ checker,
3829
+ extensionRegistry
3830
+ );
3831
+ const annotations = [
3832
+ ...interfaceDoc.annotations,
3833
+ ...inheritedInterfaceAnnotations
3834
+ ];
3577
3835
  diagnostics.push(...interfaceDoc.diagnostics);
3578
3836
  const visiting = /* @__PURE__ */ new Set();
3579
3837
  for (const member of interfaceDecl.members) {
3580
- if (ts6.isPropertySignature(member)) {
3838
+ if (ts5.isPropertySignature(member)) {
3581
3839
  const fieldNode = analyzeInterfacePropertyToIR(
3582
3840
  member,
3583
3841
  checker,
@@ -3618,6 +3876,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3618
3876
  hostType: interfaceType
3619
3877
  }
3620
3878
  );
3879
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3621
3880
  return {
3622
3881
  name,
3623
3882
  ...metadata !== void 0 && { metadata },
@@ -3625,7 +3884,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3625
3884
  fieldLayouts,
3626
3885
  typeRegistry,
3627
3886
  ...annotations.length > 0 && { annotations },
3628
- ...diagnostics.length > 0 && { diagnostics },
3887
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3629
3888
  instanceMethods: [],
3630
3889
  staticMethods: []
3631
3890
  };
@@ -3635,7 +3894,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3635
3894
  if (members === null) {
3636
3895
  const sourceFile = typeAlias.getSourceFile();
3637
3896
  const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
3638
- const kindDesc = ts6.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3897
+ const kindDesc = ts5.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3639
3898
  return {
3640
3899
  ok: false,
3641
3900
  kind: "not-object-like",
@@ -3670,7 +3929,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3670
3929
  diagnostics.push(...typeAliasDoc.diagnostics);
3671
3930
  const visiting = /* @__PURE__ */ new Set();
3672
3931
  for (const member of members) {
3673
- if (ts6.isPropertySignature(member)) {
3932
+ if (ts5.isPropertySignature(member)) {
3674
3933
  const fieldNode = analyzeInterfacePropertyToIR(
3675
3934
  member,
3676
3935
  checker,
@@ -3710,6 +3969,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3710
3969
  hostType: aliasType
3711
3970
  }
3712
3971
  );
3972
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3713
3973
  return {
3714
3974
  ok: true,
3715
3975
  analysis: {
@@ -3719,7 +3979,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3719
3979
  fieldLayouts: specializedFields.map(() => ({})),
3720
3980
  typeRegistry,
3721
3981
  ...annotations.length > 0 && { annotations },
3722
- ...diagnostics.length > 0 && { diagnostics },
3982
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3723
3983
  instanceMethods: [],
3724
3984
  staticMethods: []
3725
3985
  }
@@ -3737,20 +3997,20 @@ function makeAnalysisDiagnostic(code, message, primaryLocation, relatedLocations
3737
3997
  function getLeadingParsedTags(node) {
3738
3998
  const sourceFile = node.getSourceFile();
3739
3999
  const sourceText = sourceFile.getFullText();
3740
- const commentRanges = ts6.getLeadingCommentRanges(sourceText, node.getFullStart());
4000
+ const commentRanges = ts5.getLeadingCommentRanges(sourceText, node.getFullStart());
3741
4001
  if (commentRanges === void 0) {
3742
4002
  return [];
3743
4003
  }
3744
4004
  const parsedTags = [];
3745
4005
  for (const range of commentRanges) {
3746
- if (range.kind !== ts6.SyntaxKind.MultiLineCommentTrivia) {
4006
+ if (range.kind !== ts5.SyntaxKind.MultiLineCommentTrivia) {
3747
4007
  continue;
3748
4008
  }
3749
4009
  const commentText = sourceText.slice(range.pos, range.end);
3750
4010
  if (!commentText.startsWith("/**")) {
3751
4011
  continue;
3752
4012
  }
3753
- parsedTags.push(...(0, import_internal5.parseCommentBlock)(commentText, { offset: range.pos }).tags);
4013
+ parsedTags.push(...(0, import_internal6.parseCommentBlock)(commentText, { offset: range.pos }).tags);
3754
4014
  }
3755
4015
  return parsedTags;
3756
4016
  }
@@ -3761,19 +4021,19 @@ function resolveDiscriminatorProperty(node, checker, fieldName) {
3761
4021
  return null;
3762
4022
  }
3763
4023
  const declaration = propertySymbol.valueDeclaration ?? propertySymbol.declarations?.find(
3764
- (candidate) => ts6.isPropertyDeclaration(candidate) || ts6.isPropertySignature(candidate)
4024
+ (candidate) => ts5.isPropertyDeclaration(candidate) || ts5.isPropertySignature(candidate)
3765
4025
  ) ?? propertySymbol.declarations?.[0];
3766
4026
  return {
3767
4027
  declaration,
3768
4028
  type: checker.getTypeOfSymbolAtLocation(propertySymbol, declaration ?? node),
3769
- optional: !!(propertySymbol.flags & ts6.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
4029
+ optional: !!(propertySymbol.flags & ts5.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
3770
4030
  };
3771
4031
  }
3772
4032
  function isLocalTypeParameterName(node, typeParameterName) {
3773
4033
  return node.typeParameters?.some((typeParameter) => typeParameter.name.text === typeParameterName) ?? false;
3774
4034
  }
3775
4035
  function isNullishSemanticType(type) {
3776
- if (type.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined | ts6.TypeFlags.Void | ts6.TypeFlags.Unknown | ts6.TypeFlags.Any)) {
4036
+ if (type.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined | ts5.TypeFlags.Void | ts5.TypeFlags.Unknown | ts5.TypeFlags.Any)) {
3777
4037
  return true;
3778
4038
  }
3779
4039
  return type.isUnion() && type.types.some((member) => isNullishSemanticType(member));
@@ -3783,7 +4043,7 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
3783
4043
  return false;
3784
4044
  }
3785
4045
  seen.add(type);
3786
- if (type.flags & ts6.TypeFlags.StringLike) {
4046
+ if (type.flags & ts5.TypeFlags.StringLike) {
3787
4047
  return true;
3788
4048
  }
3789
4049
  if (type.isUnion()) {
@@ -3796,13 +4056,13 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
3796
4056
  return false;
3797
4057
  }
3798
4058
  function getObjectLikeTypeAliasMembers(typeNode) {
3799
- if (ts6.isParenthesizedTypeNode(typeNode)) {
4059
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3800
4060
  return getObjectLikeTypeAliasMembers(typeNode.type);
3801
4061
  }
3802
- if (ts6.isTypeLiteralNode(typeNode)) {
4062
+ if (ts5.isTypeLiteralNode(typeNode)) {
3803
4063
  return [...typeNode.members];
3804
4064
  }
3805
- if (ts6.isIntersectionTypeNode(typeNode)) {
4065
+ if (ts5.isIntersectionTypeNode(typeNode)) {
3806
4066
  const members = [];
3807
4067
  for (const intersectionMember of typeNode.types) {
3808
4068
  const resolvedMembers = getObjectLikeTypeAliasMembers(intersectionMember);
@@ -3965,7 +4225,7 @@ function resolveLiteralDiscriminatorPropertyValue(boundType, propertyName, check
3965
4225
  }
3966
4226
  if (propertyType.isUnion()) {
3967
4227
  const nonNullMembers = propertyType.types.filter(
3968
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
4228
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
3969
4229
  );
3970
4230
  if (nonNullMembers.length > 0 && nonNullMembers.every((member) => member.isStringLiteral())) {
3971
4231
  diagnostics.push(
@@ -4014,13 +4274,13 @@ function resolveNamedDiscriminatorDeclaration(type, checker, seen = /* @__PURE__
4014
4274
  seen.add(type);
4015
4275
  const symbol = type.aliasSymbol ?? type.getSymbol();
4016
4276
  if (symbol !== void 0) {
4017
- const aliased = symbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
4277
+ const aliased = symbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
4018
4278
  const targetSymbol = aliased ?? symbol;
4019
4279
  const declaration = targetSymbol.declarations?.find(
4020
- (candidate) => ts6.isClassDeclaration(candidate) || ts6.isInterfaceDeclaration(candidate) || ts6.isTypeAliasDeclaration(candidate) || ts6.isEnumDeclaration(candidate)
4280
+ (candidate) => ts5.isClassDeclaration(candidate) || ts5.isInterfaceDeclaration(candidate) || ts5.isTypeAliasDeclaration(candidate) || ts5.isEnumDeclaration(candidate)
4021
4281
  );
4022
4282
  if (declaration !== void 0) {
4023
- if (ts6.isTypeAliasDeclaration(declaration) && ts6.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
4283
+ if (ts5.isTypeAliasDeclaration(declaration) && ts5.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
4024
4284
  return resolveNamedDiscriminatorDeclaration(
4025
4285
  checker.getTypeFromTypeNode(declaration.type),
4026
4286
  checker,
@@ -4048,7 +4308,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
4048
4308
  }
4049
4309
  if (boundType.isUnion()) {
4050
4310
  const nonNullMembers = boundType.types.filter(
4051
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
4311
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4052
4312
  );
4053
4313
  if (nonNullMembers.every((member) => member.isStringLiteral())) {
4054
4314
  diagnostics.push(
@@ -4093,7 +4353,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
4093
4353
  return null;
4094
4354
  }
4095
4355
  function getDeclarationName(node) {
4096
- if (ts6.isClassDeclaration(node) || ts6.isInterfaceDeclaration(node) || ts6.isTypeAliasDeclaration(node) || ts6.isEnumDeclaration(node)) {
4356
+ if (ts5.isClassDeclaration(node) || ts5.isInterfaceDeclaration(node) || ts5.isTypeAliasDeclaration(node) || ts5.isEnumDeclaration(node)) {
4097
4357
  return node.name?.text ?? "anonymous";
4098
4358
  }
4099
4359
  return "anonymous";
@@ -4148,11 +4408,11 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
4148
4408
  if (sourceTypeNode === void 0) {
4149
4409
  return [];
4150
4410
  }
4151
- const unwrapParentheses = (typeNode) => ts6.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
4411
+ const unwrapParentheses = (typeNode) => ts5.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
4152
4412
  const directTypeNode = unwrapParentheses(sourceTypeNode);
4153
- const referenceTypeNode = ts6.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
4413
+ const referenceTypeNode = ts5.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
4154
4414
  const resolvedTypeNode = resolveAliasedTypeNode(directTypeNode, checker);
4155
- return ts6.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
4415
+ return ts5.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
4156
4416
  })();
4157
4417
  if (referenceTypeNode?.typeArguments === void 0) {
4158
4418
  return [];
@@ -4160,7 +4420,7 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
4160
4420
  return referenceTypeNode.typeArguments.map((argumentNode) => {
4161
4421
  const argumentType = checker.getTypeFromTypeNode(argumentNode);
4162
4422
  const baseSymbol = argumentType.aliasSymbol ?? argumentType.getSymbol();
4163
- const argumentSymbol = baseSymbol !== void 0 && baseSymbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(baseSymbol) : baseSymbol;
4423
+ const argumentSymbol = baseSymbol !== void 0 && baseSymbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(baseSymbol) : baseSymbol;
4164
4424
  const argumentDecl = argumentSymbol?.declarations?.[0];
4165
4425
  if (argumentDecl !== void 0 && argumentDecl.getSourceFile().fileName !== file) {
4166
4426
  const argumentName = argumentSymbol?.getName() ?? baseSymbol?.getName();
@@ -4223,7 +4483,7 @@ function applyDiscriminatorToObjectProperties(properties, node, subjectType, che
4223
4483
  );
4224
4484
  }
4225
4485
  function analyzeFieldToIR(prop, checker, file, typeRegistry, visiting, diagnostics, hostType, metadataPolicy, extensionRegistry) {
4226
- if (!ts6.isIdentifier(prop.name)) {
4486
+ if (!ts5.isIdentifier(prop.name)) {
4227
4487
  return null;
4228
4488
  }
4229
4489
  const name = prop.name.text;
@@ -4350,7 +4610,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
4350
4610
  const seen = /* @__PURE__ */ new Set();
4351
4611
  const duplicates = /* @__PURE__ */ new Set();
4352
4612
  for (const member of members) {
4353
- if (!ts6.isPropertySignature(member)) {
4613
+ if (!ts5.isPropertySignature(member)) {
4354
4614
  continue;
4355
4615
  }
4356
4616
  const name = getAnalyzableObjectLikePropertyName(member.name);
@@ -4366,7 +4626,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
4366
4626
  return [...duplicates].sort();
4367
4627
  }
4368
4628
  function getAnalyzableObjectLikePropertyName(name) {
4369
- if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
4629
+ if (ts5.isIdentifier(name) || ts5.isStringLiteral(name) || ts5.isNumericLiteral(name)) {
4370
4630
  return name.text;
4371
4631
  }
4372
4632
  return null;
@@ -4461,28 +4721,28 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4461
4721
  if (primitiveAlias) {
4462
4722
  return primitiveAlias;
4463
4723
  }
4464
- if (isIntegerBrandedType(type)) {
4724
+ if ((0, import_internal3._isIntegerBrandedType)(type)) {
4465
4725
  return { kind: "primitive", primitiveKind: "integer" };
4466
4726
  }
4467
- if (type.flags & ts6.TypeFlags.String) {
4727
+ if (type.flags & ts5.TypeFlags.String) {
4468
4728
  return { kind: "primitive", primitiveKind: "string" };
4469
4729
  }
4470
- if (type.flags & ts6.TypeFlags.Number) {
4730
+ if (type.flags & ts5.TypeFlags.Number) {
4471
4731
  return { kind: "primitive", primitiveKind: "number" };
4472
4732
  }
4473
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
4733
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
4474
4734
  return { kind: "primitive", primitiveKind: "bigint" };
4475
4735
  }
4476
- if (type.flags & ts6.TypeFlags.Boolean) {
4736
+ if (type.flags & ts5.TypeFlags.Boolean) {
4477
4737
  return { kind: "primitive", primitiveKind: "boolean" };
4478
4738
  }
4479
- if (type.flags & ts6.TypeFlags.Null) {
4739
+ if (type.flags & ts5.TypeFlags.Null) {
4480
4740
  return { kind: "primitive", primitiveKind: "null" };
4481
4741
  }
4482
- if (type.flags & ts6.TypeFlags.Undefined) {
4742
+ if (type.flags & ts5.TypeFlags.Undefined) {
4483
4743
  return { kind: "primitive", primitiveKind: "null" };
4484
4744
  }
4485
- if (type.flags & ts6.TypeFlags.Void) {
4745
+ if (type.flags & ts5.TypeFlags.Void) {
4486
4746
  return { kind: "primitive", primitiveKind: "null" };
4487
4747
  }
4488
4748
  if (type.isStringLiteral()) {
@@ -4569,10 +4829,10 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4569
4829
  return { kind: "primitive", primitiveKind: "string" };
4570
4830
  }
4571
4831
  function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4572
- if (!(type.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
4832
+ if (!(type.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null)) && !(0, import_internal3._isIntegerBrandedType)(type)) {
4573
4833
  return null;
4574
4834
  }
4575
- const aliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
4835
+ const aliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
4576
4836
  if (!aliasDecl) {
4577
4837
  return null;
4578
4838
  }
@@ -4583,11 +4843,18 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
4583
4843
  ...extractJSDocConstraintNodes(aliasDecl, file, makeParseOptions(extensionRegistry)),
4584
4844
  ...extractTypeAliasConstraintNodes(aliasDecl.type, checker, file, extensionRegistry)
4585
4845
  ];
4586
- const annotations = extractJSDocAnnotationNodes(
4846
+ const localAnnotations = extractJSDocAnnotationNodes(
4587
4847
  aliasDecl,
4588
4848
  file,
4589
4849
  makeParseOptions(extensionRegistry)
4590
4850
  );
4851
+ const inheritedAnnotations = collectInheritedTypeAnnotations(
4852
+ aliasDecl,
4853
+ localAnnotations,
4854
+ checker,
4855
+ extensionRegistry
4856
+ );
4857
+ const annotations = [...localAnnotations, ...inheritedAnnotations];
4591
4858
  const metadata = resolveNodeMetadata(
4592
4859
  metadataPolicy,
4593
4860
  "type",
@@ -4622,8 +4889,8 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
4622
4889
  return { kind: "reference", name: aliasName, typeArguments: [] };
4623
4890
  }
4624
4891
  function getReferencedTypeAliasDeclaration(sourceNode, checker) {
4625
- const typeNode = sourceNode && (ts6.isPropertyDeclaration(sourceNode) || ts6.isPropertySignature(sourceNode) || ts6.isParameter(sourceNode)) ? sourceNode.type : void 0;
4626
- if (!typeNode || !ts6.isTypeReferenceNode(typeNode)) {
4892
+ const typeNode = sourceNode && (ts5.isPropertyDeclaration(sourceNode) || ts5.isPropertySignature(sourceNode) || ts5.isParameter(sourceNode)) ? sourceNode.type : void 0;
4893
+ if (!typeNode || !ts5.isTypeReferenceNode(typeNode)) {
4627
4894
  return void 0;
4628
4895
  }
4629
4896
  return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -4644,7 +4911,7 @@ function resolveNamedTypeWithSourceRecovery(type, sourceNode, checker) {
4644
4911
  return { typeName: refAliasDecl.name.text, namedDecl: refAliasDecl };
4645
4912
  }
4646
4913
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4647
- if (!ts6.isTypeReferenceNode(typeNode)) {
4914
+ if (!ts5.isTypeReferenceNode(typeNode)) {
4648
4915
  return false;
4649
4916
  }
4650
4917
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -4652,10 +4919,10 @@ function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4652
4919
  return false;
4653
4920
  }
4654
4921
  const resolved = checker.getTypeFromTypeNode(aliasDecl.type);
4655
- return !!(resolved.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null));
4922
+ return !!(resolved.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null));
4656
4923
  }
4657
4924
  function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics, visitedAliases = /* @__PURE__ */ new Set()) {
4658
- const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration);
4925
+ const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration);
4659
4926
  if (nestedAliasDecl !== void 0 && !visitedAliases.has(nestedAliasDecl)) {
4660
4927
  visitedAliases.add(nestedAliasDecl);
4661
4928
  return resolveAliasedPrimitiveTarget(
@@ -4670,22 +4937,22 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
4670
4937
  visitedAliases
4671
4938
  );
4672
4939
  }
4673
- if (isIntegerBrandedType(type)) {
4940
+ if ((0, import_internal3._isIntegerBrandedType)(type)) {
4674
4941
  return { kind: "primitive", primitiveKind: "integer" };
4675
4942
  }
4676
- if (type.flags & ts6.TypeFlags.String) {
4943
+ if (type.flags & ts5.TypeFlags.String) {
4677
4944
  return { kind: "primitive", primitiveKind: "string" };
4678
4945
  }
4679
- if (type.flags & ts6.TypeFlags.Number) {
4946
+ if (type.flags & ts5.TypeFlags.Number) {
4680
4947
  return { kind: "primitive", primitiveKind: "number" };
4681
4948
  }
4682
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
4949
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
4683
4950
  return { kind: "primitive", primitiveKind: "bigint" };
4684
4951
  }
4685
- if (type.flags & ts6.TypeFlags.Boolean) {
4952
+ if (type.flags & ts5.TypeFlags.Boolean) {
4686
4953
  return { kind: "primitive", primitiveKind: "boolean" };
4687
4954
  }
4688
- if (type.flags & ts6.TypeFlags.Null) {
4955
+ if (type.flags & ts5.TypeFlags.Null) {
4689
4956
  return { kind: "primitive", primitiveKind: "null" };
4690
4957
  }
4691
4958
  return resolveTypeNode(
@@ -4705,7 +4972,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4705
4972
  let typeName = null;
4706
4973
  let namedDecl;
4707
4974
  if (recovered !== null) {
4708
- const recoveredAliasDecl = ts6.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
4975
+ const recoveredAliasDecl = ts5.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
4709
4976
  if (recoveredAliasDecl !== void 0) {
4710
4977
  const aliasUnderlyingType = checker.getTypeFromTypeNode(recoveredAliasDecl.type);
4711
4978
  const isNonGeneric = recoveredAliasDecl.typeParameters === void 0 || recoveredAliasDecl.typeParameters.length === 0;
@@ -4727,13 +4994,13 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4727
4994
  (memberTypeNode) => !isNullishTypeNode(resolveAliasedTypeNode(memberTypeNode, checker))
4728
4995
  );
4729
4996
  const nonNullTypes = allTypes.filter(
4730
- (memberType) => !(memberType.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
4997
+ (memberType) => !(memberType.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4731
4998
  );
4732
4999
  const nonNullMembers = nonNullTypes.map((memberType, index) => ({
4733
5000
  memberType,
4734
5001
  sourceNode: nonNullSourceNodes.length === nonNullTypes.length ? nonNullSourceNodes[index] : void 0
4735
5002
  }));
4736
- const hasNull = allTypes.some((t) => t.flags & ts6.TypeFlags.Null);
5003
+ const hasNull = allTypes.some((t) => t.flags & ts5.TypeFlags.Null);
4737
5004
  const memberDisplayNames = /* @__PURE__ */ new Map();
4738
5005
  if (namedDecl) {
4739
5006
  for (const [value, label] of extractDisplayNameMetadata(namedDecl).memberDisplayNames) {
@@ -4753,7 +5020,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4753
5020
  if (existing !== void 0 && existing.type !== RESOLVING_TYPE_PLACEHOLDER) {
4754
5021
  return { kind: "reference", name: typeName, typeArguments: [] };
4755
5022
  }
4756
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5023
+ const annotations = namedDecl ? extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) : void 0;
4757
5024
  const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
4758
5025
  metadataPolicy,
4759
5026
  "type",
@@ -4780,7 +5047,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4780
5047
  const displayName = memberDisplayNames.get(String(value));
4781
5048
  return displayName !== void 0 ? { value, displayName } : { value };
4782
5049
  });
4783
- const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts6.TypeFlags.BooleanLiteral);
5050
+ const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts5.TypeFlags.BooleanLiteral);
4784
5051
  if (isBooleanUnion2) {
4785
5052
  const boolNode = { kind: "primitive", primitiveKind: "boolean" };
4786
5053
  const result = hasNull ? {
@@ -4872,7 +5139,7 @@ function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metad
4872
5139
  if (type.getProperties().length > 0) {
4873
5140
  return null;
4874
5141
  }
4875
- const indexInfo = checker.getIndexInfoOfType(type, ts6.IndexKind.String);
5142
+ const indexInfo = checker.getIndexInfoOfType(type, ts5.IndexKind.String);
4876
5143
  if (!indexInfo) {
4877
5144
  return null;
4878
5145
  }
@@ -4920,20 +5187,53 @@ function shouldEmitResolvedObjectProperty(property, declaration) {
4920
5187
  }
4921
5188
  if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
4922
5189
  const name = declaration.name;
4923
- if (ts6.isComputedPropertyName(name) || ts6.isPrivateIdentifier(name)) {
5190
+ if (ts5.isComputedPropertyName(name) || ts5.isPrivateIdentifier(name)) {
4924
5191
  return false;
4925
5192
  }
4926
- if (!ts6.isIdentifier(name) && !ts6.isStringLiteral(name) && !ts6.isNumericLiteral(name)) {
5193
+ if (!ts5.isIdentifier(name) && !ts5.isStringLiteral(name) && !ts5.isNumericLiteral(name)) {
4927
5194
  return false;
4928
5195
  }
4929
5196
  }
4930
5197
  return true;
4931
5198
  }
5199
+ function getPassThroughTypeAliasFromSourceNode(sourceNode, checker, extensionRegistry, resolvedTypeName) {
5200
+ const aliasDecl = getReferencedTypeAliasDeclaration(sourceNode, checker);
5201
+ if (!aliasDecl) return void 0;
5202
+ const aliasName = aliasDecl.name.text;
5203
+ if (aliasName === resolvedTypeName) return void 0;
5204
+ if (!ts5.isTypeReferenceNode(aliasDecl.type)) return void 0;
5205
+ if (!hasInheritableTypeAnnotation(aliasDecl, checker, extensionRegistry)) {
5206
+ return void 0;
5207
+ }
5208
+ return { aliasName, aliasDecl };
5209
+ }
5210
+ function hasInheritableTypeAnnotation(aliasDecl, checker, extensionRegistry) {
5211
+ const file = aliasDecl.getSourceFile().fileName;
5212
+ const local = extractJSDocAnnotationNodes(aliasDecl, file, makeParseOptions(extensionRegistry));
5213
+ for (const annotation of local) {
5214
+ if (!INHERITABLE_TYPE_ANNOTATION_KINDS.has(annotation.annotationKind)) continue;
5215
+ if (!isOverridingInheritableAnnotation(annotation)) continue;
5216
+ return true;
5217
+ }
5218
+ const inherited = collectInheritedTypeAnnotations(aliasDecl, local, checker, extensionRegistry);
5219
+ for (const annotation of inherited) {
5220
+ if (INHERITABLE_TYPE_ANNOTATION_KINDS.has(annotation.annotationKind)) return true;
5221
+ }
5222
+ return false;
5223
+ }
4932
5224
  function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4933
5225
  const collectedDiagnostics = diagnostics ?? [];
4934
5226
  const typeName = getNamedTypeName(type);
4935
5227
  const namedTypeName = typeName ?? void 0;
4936
5228
  const namedDecl = getNamedTypeDeclaration(type);
5229
+ const passThroughAlias = getPassThroughTypeAliasFromSourceNode(
5230
+ sourceNode,
5231
+ checker,
5232
+ extensionRegistry,
5233
+ namedTypeName
5234
+ );
5235
+ const effectiveTypeName = passThroughAlias?.aliasName ?? namedTypeName;
5236
+ const effectiveNamedDecl = passThroughAlias?.aliasDecl ?? namedDecl;
4937
5237
  const referenceTypeArguments = extractReferenceTypeArguments(
4938
5238
  type,
4939
5239
  checker,
@@ -4945,13 +5245,13 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
4945
5245
  extensionRegistry,
4946
5246
  collectedDiagnostics
4947
5247
  );
4948
- const instantiatedTypeName = namedTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
4949
- namedTypeName,
5248
+ const instantiatedTypeName = effectiveTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
5249
+ effectiveTypeName,
4950
5250
  referenceTypeArguments.map((argument) => argument.tsType),
4951
5251
  checker
4952
5252
  ) : void 0;
4953
- const registryTypeName = instantiatedTypeName ?? namedTypeName;
4954
- const shouldRegisterNamedType = registryTypeName !== void 0 && !(registryTypeName === "Record" && namedDecl?.getSourceFile().fileName !== file);
5253
+ const registryTypeName = instantiatedTypeName ?? effectiveTypeName;
5254
+ const shouldRegisterNamedType = registryTypeName !== void 0 && !(registryTypeName === "Record" && effectiveNamedDecl?.getSourceFile().fileName !== file);
4955
5255
  const clearNamedTypeRegistration = () => {
4956
5256
  if (registryTypeName === void 0 || !shouldRegisterNamedType) {
4957
5257
  return;
@@ -4972,7 +5272,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
4972
5272
  typeRegistry[registryTypeName] = {
4973
5273
  name: registryTypeName,
4974
5274
  type: RESOLVING_TYPE_PLACEHOLDER,
4975
- provenance: provenanceForDeclaration(namedDecl, file)
5275
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
4976
5276
  };
4977
5277
  }
4978
5278
  visiting.add(type);
@@ -5004,17 +5304,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5004
5304
  clearNamedTypeRegistration();
5005
5305
  return recordNode;
5006
5306
  }
5007
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5008
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
5307
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
5308
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
5009
5309
  metadataPolicy,
5010
5310
  "type",
5011
5311
  registryTypeName,
5012
- namedDecl,
5312
+ effectiveNamedDecl,
5013
5313
  checker,
5014
5314
  extensionRegistry,
5015
5315
  {
5016
5316
  checker,
5017
- declaration: namedDecl,
5317
+ declaration: effectiveNamedDecl,
5018
5318
  subjectType: type
5019
5319
  }
5020
5320
  ) : void 0;
@@ -5023,7 +5323,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5023
5323
  ...metadata !== void 0 && { metadata },
5024
5324
  type: recordNode,
5025
5325
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
5026
- provenance: provenanceForDeclaration(namedDecl, file)
5326
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
5027
5327
  };
5028
5328
  return {
5029
5329
  kind: "reference",
@@ -5049,7 +5349,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5049
5349
  if (!declaration) continue;
5050
5350
  if (!shouldEmitResolvedObjectProperty(prop, declaration)) continue;
5051
5351
  const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);
5052
- const optional = !!(prop.flags & ts6.SymbolFlags.Optional);
5352
+ const optional = !!(prop.flags & ts5.SymbolFlags.Optional);
5053
5353
  const propTypeNode = resolveTypeNode(
5054
5354
  propType,
5055
5355
  checker,
@@ -5062,7 +5362,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5062
5362
  collectedDiagnostics
5063
5363
  );
5064
5364
  const fieldNodeInfo = fieldInfoMap?.get(prop.name);
5065
- const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts6.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
5365
+ const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts5.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
5066
5366
  declaration,
5067
5367
  checker,
5068
5368
  file,
@@ -5072,7 +5372,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5072
5372
  type,
5073
5373
  metadataPolicy,
5074
5374
  extensionRegistry
5075
- ) : ts6.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
5375
+ ) : ts5.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
5076
5376
  declaration,
5077
5377
  checker,
5078
5378
  file,
@@ -5100,9 +5400,9 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5100
5400
  visiting.delete(type);
5101
5401
  const objectNode = {
5102
5402
  kind: "object",
5103
- properties: namedDecl !== void 0 && (ts6.isClassDeclaration(namedDecl) || ts6.isInterfaceDeclaration(namedDecl) || ts6.isTypeAliasDeclaration(namedDecl)) ? applyDiscriminatorToObjectProperties(
5403
+ properties: effectiveNamedDecl !== void 0 && (ts5.isClassDeclaration(effectiveNamedDecl) || ts5.isInterfaceDeclaration(effectiveNamedDecl) || ts5.isTypeAliasDeclaration(effectiveNamedDecl)) ? applyDiscriminatorToObjectProperties(
5104
5404
  properties,
5105
- namedDecl,
5405
+ effectiveNamedDecl,
5106
5406
  type,
5107
5407
  checker,
5108
5408
  file,
@@ -5112,17 +5412,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5112
5412
  additionalProperties: true
5113
5413
  };
5114
5414
  if (registryTypeName !== void 0 && shouldRegisterNamedType) {
5115
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5116
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
5415
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
5416
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
5117
5417
  metadataPolicy,
5118
5418
  "type",
5119
5419
  registryTypeName,
5120
- namedDecl,
5420
+ effectiveNamedDecl,
5121
5421
  checker,
5122
5422
  extensionRegistry,
5123
5423
  {
5124
5424
  checker,
5125
- declaration: namedDecl,
5425
+ declaration: effectiveNamedDecl,
5126
5426
  subjectType: type
5127
5427
  }
5128
5428
  ) : void 0;
@@ -5131,7 +5431,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5131
5431
  ...metadata !== void 0 && { metadata },
5132
5432
  type: objectNode,
5133
5433
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
5134
- provenance: provenanceForDeclaration(namedDecl, file)
5434
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
5135
5435
  };
5136
5436
  return {
5137
5437
  kind: "reference",
@@ -5148,12 +5448,12 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5148
5448
  for (const symbol of symbols) {
5149
5449
  const declarations = symbol.declarations;
5150
5450
  if (!declarations) continue;
5151
- const classDecl = declarations.find(ts6.isClassDeclaration);
5451
+ const classDecl = declarations.find(ts5.isClassDeclaration);
5152
5452
  if (classDecl) {
5153
5453
  const map = /* @__PURE__ */ new Map();
5154
5454
  const hostType = checker.getTypeAtLocation(classDecl);
5155
5455
  for (const member of classDecl.members) {
5156
- if (ts6.isPropertyDeclaration(member) && ts6.isIdentifier(member.name)) {
5456
+ if (ts5.isPropertyDeclaration(member) && ts5.isIdentifier(member.name)) {
5157
5457
  const fieldNode = analyzeFieldToIR(
5158
5458
  member,
5159
5459
  checker,
@@ -5177,7 +5477,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5177
5477
  }
5178
5478
  return map;
5179
5479
  }
5180
- const interfaceDecl = declarations.find(ts6.isInterfaceDeclaration);
5480
+ const interfaceDecl = declarations.find(ts5.isInterfaceDeclaration);
5181
5481
  if (interfaceDecl) {
5182
5482
  return buildFieldNodeInfoMap(
5183
5483
  interfaceDecl.members,
@@ -5191,7 +5491,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5191
5491
  extensionRegistry
5192
5492
  );
5193
5493
  }
5194
- const typeAliasDecl = declarations.find(ts6.isTypeAliasDeclaration);
5494
+ const typeAliasDecl = declarations.find(ts5.isTypeAliasDeclaration);
5195
5495
  const typeAliasMembers = typeAliasDecl === void 0 ? null : getObjectLikeTypeAliasMembers(typeAliasDecl.type);
5196
5496
  if (typeAliasDecl && typeAliasMembers !== null) {
5197
5497
  return buildFieldNodeInfoMap(
@@ -5215,10 +5515,10 @@ function extractArrayElementTypeNode(sourceNode, checker) {
5215
5515
  return void 0;
5216
5516
  }
5217
5517
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
5218
- if (ts6.isArrayTypeNode(resolvedTypeNode)) {
5518
+ if (ts5.isArrayTypeNode(resolvedTypeNode)) {
5219
5519
  return resolvedTypeNode.elementType;
5220
5520
  }
5221
- if (ts6.isTypeReferenceNode(resolvedTypeNode) && ts6.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
5521
+ if (ts5.isTypeReferenceNode(resolvedTypeNode) && ts5.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
5222
5522
  return resolvedTypeNode.typeArguments[0];
5223
5523
  }
5224
5524
  return void 0;
@@ -5229,13 +5529,13 @@ function extractUnionMemberTypeNodes(sourceNode, checker) {
5229
5529
  return [];
5230
5530
  }
5231
5531
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
5232
- return ts6.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
5532
+ return ts5.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
5233
5533
  }
5234
5534
  function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new Set()) {
5235
- if (ts6.isParenthesizedTypeNode(typeNode)) {
5535
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
5236
5536
  return resolveAliasedTypeNode(typeNode.type, checker, visited);
5237
5537
  }
5238
- if (!ts6.isTypeReferenceNode(typeNode) || !ts6.isIdentifier(typeNode.typeName)) {
5538
+ if (!ts5.isTypeReferenceNode(typeNode) || !ts5.isIdentifier(typeNode.typeName)) {
5239
5539
  return typeNode;
5240
5540
  }
5241
5541
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -5246,15 +5546,15 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
5246
5546
  return resolveAliasedTypeNode(aliasDecl.type, checker, visited);
5247
5547
  }
5248
5548
  function isNullishTypeNode(typeNode) {
5249
- if (typeNode.kind === ts6.SyntaxKind.NullKeyword || typeNode.kind === ts6.SyntaxKind.UndefinedKeyword) {
5549
+ if (typeNode.kind === ts5.SyntaxKind.NullKeyword || typeNode.kind === ts5.SyntaxKind.UndefinedKeyword) {
5250
5550
  return true;
5251
5551
  }
5252
- return ts6.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts6.SyntaxKind.NullKeyword || typeNode.literal.kind === ts6.SyntaxKind.UndefinedKeyword);
5552
+ return ts5.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts5.SyntaxKind.NullKeyword || typeNode.literal.kind === ts5.SyntaxKind.UndefinedKeyword);
5253
5553
  }
5254
5554
  function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, metadataPolicy, hostType, diagnostics, extensionRegistry) {
5255
5555
  const map = /* @__PURE__ */ new Map();
5256
5556
  for (const member of members) {
5257
- if (ts6.isPropertySignature(member)) {
5557
+ if (ts5.isPropertySignature(member)) {
5258
5558
  const fieldNode = analyzeInterfacePropertyToIR(
5259
5559
  member,
5260
5560
  checker,
@@ -5280,7 +5580,7 @@ function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, m
5280
5580
  }
5281
5581
  var MAX_ALIAS_CHAIN_DEPTH = 8;
5282
5582
  function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegistry, depth = 0) {
5283
- if (!ts6.isTypeReferenceNode(typeNode)) return [];
5583
+ if (!ts5.isTypeReferenceNode(typeNode)) return [];
5284
5584
  if (depth >= MAX_ALIAS_CHAIN_DEPTH) {
5285
5585
  const aliasName = typeNode.typeName.getText();
5286
5586
  throw new Error(
@@ -5289,7 +5589,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
5289
5589
  }
5290
5590
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
5291
5591
  if (!aliasDecl) return [];
5292
- if (ts6.isTypeLiteralNode(aliasDecl.type)) return [];
5592
+ if (ts5.isTypeLiteralNode(aliasDecl.type)) return [];
5293
5593
  const aliasFieldType = resolveTypeNode(
5294
5594
  checker.getTypeAtLocation(aliasDecl.type),
5295
5595
  checker,
@@ -5333,14 +5633,14 @@ function getNamedTypeName(type) {
5333
5633
  const symbol = type.getSymbol();
5334
5634
  if (symbol?.declarations) {
5335
5635
  const decl = symbol.declarations[0];
5336
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
5337
- const name = ts6.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
5636
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
5637
+ const name = ts5.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
5338
5638
  if (name) return name;
5339
5639
  }
5340
5640
  }
5341
5641
  const aliasSymbol = type.aliasSymbol;
5342
5642
  if (aliasSymbol?.declarations) {
5343
- const aliasDecl = aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
5643
+ const aliasDecl = aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
5344
5644
  if (aliasDecl) {
5345
5645
  return aliasDecl.name.text;
5346
5646
  }
@@ -5351,24 +5651,24 @@ function getNamedTypeDeclaration(type) {
5351
5651
  const symbol = type.getSymbol();
5352
5652
  if (symbol?.declarations) {
5353
5653
  const decl = symbol.declarations[0];
5354
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
5654
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
5355
5655
  return decl;
5356
5656
  }
5357
5657
  }
5358
5658
  const aliasSymbol = type.aliasSymbol;
5359
5659
  if (aliasSymbol?.declarations) {
5360
- return aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
5660
+ return aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
5361
5661
  }
5362
5662
  return void 0;
5363
5663
  }
5364
5664
  function analyzeMethod(method, checker) {
5365
- if (!ts6.isIdentifier(method.name)) {
5665
+ if (!ts5.isIdentifier(method.name)) {
5366
5666
  return null;
5367
5667
  }
5368
5668
  const name = method.name.text;
5369
5669
  const parameters = [];
5370
5670
  for (const param of method.parameters) {
5371
- if (ts6.isIdentifier(param.name)) {
5671
+ if (ts5.isIdentifier(param.name)) {
5372
5672
  const paramInfo = analyzeParameter(param, checker);
5373
5673
  parameters.push(paramInfo);
5374
5674
  }
@@ -5379,7 +5679,7 @@ function analyzeMethod(method, checker) {
5379
5679
  return { name, parameters, returnTypeNode, returnType };
5380
5680
  }
5381
5681
  function analyzeParameter(param, checker) {
5382
- const name = ts6.isIdentifier(param.name) ? param.name.text : "param";
5682
+ const name = ts5.isIdentifier(param.name) ? param.name.text : "param";
5383
5683
  const typeNode = param.type;
5384
5684
  const type = checker.getTypeAtLocation(param);
5385
5685
  const formSpecExportName = detectFormSpecReference(typeNode);
@@ -5388,15 +5688,15 @@ function analyzeParameter(param, checker) {
5388
5688
  }
5389
5689
  function detectFormSpecReference(typeNode) {
5390
5690
  if (!typeNode) return null;
5391
- if (!ts6.isTypeReferenceNode(typeNode)) return null;
5392
- const typeName = ts6.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts6.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
5691
+ if (!ts5.isTypeReferenceNode(typeNode)) return null;
5692
+ const typeName = ts5.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts5.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
5393
5693
  if (typeName !== "InferSchema" && typeName !== "InferFormSchema") return null;
5394
5694
  const typeArg = typeNode.typeArguments?.[0];
5395
- if (!typeArg || !ts6.isTypeQueryNode(typeArg)) return null;
5396
- if (ts6.isIdentifier(typeArg.exprName)) {
5695
+ if (!typeArg || !ts5.isTypeQueryNode(typeArg)) return null;
5696
+ if (ts5.isIdentifier(typeArg.exprName)) {
5397
5697
  return typeArg.exprName.text;
5398
5698
  }
5399
- if (ts6.isQualifiedName(typeArg.exprName)) {
5699
+ if (ts5.isQualifiedName(typeArg.exprName)) {
5400
5700
  return typeArg.exprName.right.text;
5401
5701
  }
5402
5702
  return null;
@@ -5418,23 +5718,23 @@ function createProgramContextFromProgram(program, filePath) {
5418
5718
  function createProgramContext(filePath, additionalFiles) {
5419
5719
  const absolutePath = path.resolve(filePath);
5420
5720
  const fileDir = path.dirname(absolutePath);
5421
- const configPath = ts7.findConfigFile(fileDir, ts7.sys.fileExists.bind(ts7.sys), "tsconfig.json");
5721
+ const configPath = ts6.findConfigFile(fileDir, ts6.sys.fileExists.bind(ts6.sys), "tsconfig.json");
5422
5722
  let compilerOptions;
5423
5723
  let fileNames;
5424
5724
  if (configPath) {
5425
- const configFile = ts7.readConfigFile(configPath, ts7.sys.readFile.bind(ts7.sys));
5725
+ const configFile = ts6.readConfigFile(configPath, ts6.sys.readFile.bind(ts6.sys));
5426
5726
  if (configFile.error) {
5427
5727
  throw new Error(
5428
- `Error reading tsconfig.json: ${ts7.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
5728
+ `Error reading tsconfig.json: ${ts6.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
5429
5729
  );
5430
5730
  }
5431
- const parsed = ts7.parseJsonConfigFileContent(
5731
+ const parsed = ts6.parseJsonConfigFileContent(
5432
5732
  configFile.config,
5433
- ts7.sys,
5733
+ ts6.sys,
5434
5734
  path.dirname(configPath)
5435
5735
  );
5436
5736
  if (parsed.errors.length > 0) {
5437
- const errorMessages = parsed.errors.map((e) => ts7.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
5737
+ const errorMessages = parsed.errors.map((e) => ts6.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
5438
5738
  throw new Error(`Error parsing tsconfig.json: ${errorMessages}`);
5439
5739
  }
5440
5740
  compilerOptions = parsed.options;
@@ -5442,9 +5742,9 @@ function createProgramContext(filePath, additionalFiles) {
5442
5742
  fileNames = [.../* @__PURE__ */ new Set([...parsed.fileNames, absolutePath, ...normalizedAdditional])];
5443
5743
  } else {
5444
5744
  compilerOptions = {
5445
- target: ts7.ScriptTarget.ES2022,
5446
- module: ts7.ModuleKind.NodeNext,
5447
- moduleResolution: ts7.ModuleResolutionKind.NodeNext,
5745
+ target: ts6.ScriptTarget.ES2022,
5746
+ module: ts6.ModuleKind.NodeNext,
5747
+ moduleResolution: ts6.ModuleResolutionKind.NodeNext,
5448
5748
  strict: true,
5449
5749
  skipLibCheck: true,
5450
5750
  declaration: true
@@ -5452,7 +5752,7 @@ function createProgramContext(filePath, additionalFiles) {
5452
5752
  const normalizedAdditional = (additionalFiles ?? []).map((f) => path.resolve(f));
5453
5753
  fileNames = [.../* @__PURE__ */ new Set([absolutePath, ...normalizedAdditional])];
5454
5754
  }
5455
- const program = ts7.createProgram(fileNames, compilerOptions);
5755
+ const program = ts6.createProgram(fileNames, compilerOptions);
5456
5756
  const sourceFile = program.getSourceFile(absolutePath);
5457
5757
  if (!sourceFile) {
5458
5758
  throw new Error(`Could not find source file: ${absolutePath}`);
@@ -5471,19 +5771,19 @@ function findNodeByName(sourceFile, name, predicate, getName) {
5471
5771
  result = node;
5472
5772
  return;
5473
5773
  }
5474
- ts7.forEachChild(node, visit);
5774
+ ts6.forEachChild(node, visit);
5475
5775
  }
5476
5776
  visit(sourceFile);
5477
5777
  return result;
5478
5778
  }
5479
5779
  function findClassByName(sourceFile, className) {
5480
- return findNodeByName(sourceFile, className, ts7.isClassDeclaration, (n) => n.name?.text);
5780
+ return findNodeByName(sourceFile, className, ts6.isClassDeclaration, (n) => n.name?.text);
5481
5781
  }
5482
5782
  function findInterfaceByName(sourceFile, interfaceName) {
5483
- return findNodeByName(sourceFile, interfaceName, ts7.isInterfaceDeclaration, (n) => n.name.text);
5783
+ return findNodeByName(sourceFile, interfaceName, ts6.isInterfaceDeclaration, (n) => n.name.text);
5484
5784
  }
5485
5785
  function findTypeAliasByName(sourceFile, aliasName) {
5486
- return findNodeByName(sourceFile, aliasName, ts7.isTypeAliasDeclaration, (n) => n.name.text);
5786
+ return findNodeByName(sourceFile, aliasName, ts6.isTypeAliasDeclaration, (n) => n.name.text);
5487
5787
  }
5488
5788
  function getResolvedObjectRootType(rootType, typeRegistry) {
5489
5789
  if (rootType.kind === "object") {
@@ -5523,22 +5823,22 @@ function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInf
5523
5823
  };
5524
5824
  }
5525
5825
  function containsTypeReferenceInObjectLikeAlias(typeNode) {
5526
- if (ts7.isParenthesizedTypeNode(typeNode)) {
5826
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
5527
5827
  return containsTypeReferenceInObjectLikeAlias(typeNode.type);
5528
5828
  }
5529
- if (ts7.isTypeReferenceNode(typeNode)) {
5829
+ if (ts6.isTypeReferenceNode(typeNode)) {
5530
5830
  return true;
5531
5831
  }
5532
- return ts7.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5832
+ return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5533
5833
  }
5534
5834
  function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5535
- if (ts7.isParenthesizedTypeNode(typeNode)) {
5835
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
5536
5836
  return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
5537
5837
  }
5538
- if (ts7.isTypeLiteralNode(typeNode)) {
5838
+ if (ts6.isTypeLiteralNode(typeNode)) {
5539
5839
  const propertyNames = [];
5540
5840
  for (const member of typeNode.members) {
5541
- if (!ts7.isPropertySignature(member)) {
5841
+ if (!ts6.isPropertySignature(member)) {
5542
5842
  continue;
5543
5843
  }
5544
5844
  const propertyName = getAnalyzableObjectLikePropertyName(member.name);
@@ -5548,13 +5848,13 @@ function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5548
5848
  }
5549
5849
  return propertyNames;
5550
5850
  }
5551
- if (ts7.isTypeReferenceNode(typeNode)) {
5851
+ if (ts6.isTypeReferenceNode(typeNode)) {
5552
5852
  return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
5553
5853
  }
5554
5854
  return null;
5555
5855
  }
5556
5856
  function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
5557
- if (!ts7.isIntersectionTypeNode(typeNode)) {
5857
+ if (!ts6.isIntersectionTypeNode(typeNode)) {
5558
5858
  return [];
5559
5859
  }
5560
5860
  const seen = /* @__PURE__ */ new Set();
@@ -5755,7 +6055,7 @@ function makeFileProvenance(filePath) {
5755
6055
  }
5756
6056
 
5757
6057
  // src/extensions/symbol-registry.ts
5758
- var ts8 = __toESM(require("typescript"), 1);
6058
+ var ts7 = __toESM(require("typescript"), 1);
5759
6059
  var path2 = __toESM(require("path"), 1);
5760
6060
  function buildSymbolMapFromConfig(configPath, program, checker, extensionRegistry) {
5761
6061
  const symbolMap = /* @__PURE__ */ new Map();
@@ -5765,10 +6065,10 @@ function buildSymbolMapFromConfig(configPath, program, checker, extensionRegistr
5765
6065
  return symbolMap;
5766
6066
  }
5767
6067
  function visit(node) {
5768
- if (ts8.isCallExpression(node) && isDefineCustomTypeCall(node, checker)) {
6068
+ if (ts7.isCallExpression(node) && isDefineCustomTypeCall(node, checker)) {
5769
6069
  processDefineCustomTypeCall(node);
5770
6070
  }
5771
- ts8.forEachChild(node, visit);
6071
+ ts7.forEachChild(node, visit);
5772
6072
  }
5773
6073
  function processDefineCustomTypeCall(call) {
5774
6074
  const typeArgNode = call.typeArguments?.[0];
@@ -5805,7 +6105,7 @@ function isDefineCustomTypeCall(node, checker) {
5805
6105
  if (node.typeArguments === void 0 || node.typeArguments.length === 0) return false;
5806
6106
  const callSymbol = checker.getSymbolAtLocation(node.expression);
5807
6107
  if (callSymbol !== void 0) {
5808
- const resolved = callSymbol.flags & ts8.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
6108
+ const resolved = callSymbol.flags & ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
5809
6109
  const decl = resolved.declarations?.[0];
5810
6110
  if (decl !== void 0) {
5811
6111
  const sourceFile = decl.getSourceFile().fileName.replace(/\\/g, "/");
@@ -5813,24 +6113,24 @@ function isDefineCustomTypeCall(node, checker) {
5813
6113
  (sourceFile.includes("@formspec/core") || sourceFile.includes("/packages/core/"));
5814
6114
  }
5815
6115
  }
5816
- return ts8.isIdentifier(node.expression) && node.expression.text === "defineCustomType";
6116
+ return ts7.isIdentifier(node.expression) && node.expression.text === "defineCustomType";
5817
6117
  }
5818
6118
  function extractTypeNameFromCallArg(call) {
5819
6119
  const arg = call.arguments[0];
5820
- if (arg === void 0 || !ts8.isObjectLiteralExpression(arg)) {
6120
+ if (arg === void 0 || !ts7.isObjectLiteralExpression(arg)) {
5821
6121
  return null;
5822
6122
  }
5823
6123
  const typeNameProp = arg.properties.find(
5824
- (p) => ts8.isPropertyAssignment(p) && ts8.isIdentifier(p.name) && p.name.text === "typeName"
6124
+ (p) => ts7.isPropertyAssignment(p) && ts7.isIdentifier(p.name) && p.name.text === "typeName"
5825
6125
  );
5826
- if (typeNameProp === void 0 || !ts8.isStringLiteral(typeNameProp.initializer)) {
6126
+ if (typeNameProp === void 0 || !ts7.isStringLiteral(typeNameProp.initializer)) {
5827
6127
  return null;
5828
6128
  }
5829
6129
  return typeNameProp.initializer.text;
5830
6130
  }
5831
6131
  function extractEnclosingExtensionId(call, checker) {
5832
- for (let node = call.parent; !ts8.isSourceFile(node); node = node.parent) {
5833
- if (ts8.isCallExpression(node) && isDefineExtensionCall(node, checker)) {
6132
+ for (let node = call.parent; !ts7.isSourceFile(node); node = node.parent) {
6133
+ if (ts7.isCallExpression(node) && isDefineExtensionCall(node, checker)) {
5834
6134
  return extractExtensionIdFromCallArg(node);
5835
6135
  }
5836
6136
  }
@@ -5839,24 +6139,24 @@ function extractEnclosingExtensionId(call, checker) {
5839
6139
  function isDefineExtensionCall(node, checker) {
5840
6140
  const callSymbol = checker.getSymbolAtLocation(node.expression);
5841
6141
  if (callSymbol !== void 0) {
5842
- const resolved = callSymbol.flags & ts8.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
6142
+ const resolved = callSymbol.flags & ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
5843
6143
  const decl = resolved.declarations?.[0];
5844
6144
  if (decl !== void 0) {
5845
6145
  const sourceFile = decl.getSourceFile().fileName.replace(/\\/g, "/");
5846
6146
  return resolved.name === "defineExtension" && (sourceFile.includes("@formspec/core") || sourceFile.includes("/packages/core/"));
5847
6147
  }
5848
6148
  }
5849
- return ts8.isIdentifier(node.expression) && node.expression.text === "defineExtension";
6149
+ return ts7.isIdentifier(node.expression) && node.expression.text === "defineExtension";
5850
6150
  }
5851
6151
  function extractExtensionIdFromCallArg(call) {
5852
6152
  const arg = call.arguments[0];
5853
- if (arg === void 0 || !ts8.isObjectLiteralExpression(arg)) {
6153
+ if (arg === void 0 || !ts7.isObjectLiteralExpression(arg)) {
5854
6154
  return null;
5855
6155
  }
5856
6156
  const prop = arg.properties.find(
5857
- (p) => ts8.isPropertyAssignment(p) && ts8.isIdentifier(p.name) && p.name.text === "extensionId"
6157
+ (p) => ts7.isPropertyAssignment(p) && ts7.isIdentifier(p.name) && p.name.text === "extensionId"
5858
6158
  );
5859
- if (prop === void 0 || !ts8.isStringLiteral(prop.initializer)) {
6159
+ if (prop === void 0 || !ts7.isStringLiteral(prop.initializer)) {
5860
6160
  return null;
5861
6161
  }
5862
6162
  return prop.initializer.text;
@@ -5876,9 +6176,9 @@ function findRegistrationByTypeName(registry, typeName) {
5876
6176
  }
5877
6177
 
5878
6178
  // src/validate/constraint-validator.ts
5879
- var import_internal6 = require("@formspec/analysis/internal");
6179
+ var import_internal7 = require("@formspec/analysis/internal");
5880
6180
  function validateFieldNode(ctx, field) {
5881
- const analysis = (0, import_internal6.analyzeConstraintTargets)(
6181
+ const analysis = (0, import_internal7.analyzeConstraintTargets)(
5882
6182
  field.name,
5883
6183
  field.type,
5884
6184
  field.constraints,
@@ -5896,7 +6196,7 @@ function validateFieldNode(ctx, field) {
5896
6196
  }
5897
6197
  function validateObjectProperty(ctx, parentName, property) {
5898
6198
  const qualifiedName = `${parentName}.${property.name}`;
5899
- const analysis = (0, import_internal6.analyzeConstraintTargets)(
6199
+ const analysis = (0, import_internal7.analyzeConstraintTargets)(
5900
6200
  qualifiedName,
5901
6201
  property.type,
5902
6202
  property.constraints,
@@ -6118,7 +6418,7 @@ function generateSchemasBatch(options) {
6118
6418
  return options.targets.map((target) => {
6119
6419
  let ctx;
6120
6420
  try {
6121
- const cacheKey = ts9.sys.useCaseSensitiveFileNames ? target.filePath : target.filePath.toLowerCase();
6421
+ const cacheKey = ts8.sys.useCaseSensitiveFileNames ? target.filePath : target.filePath.toLowerCase();
6122
6422
  const cachedContext = contextCache.get(cacheKey);
6123
6423
  if (cachedContext === void 0) {
6124
6424
  const additionalFiles = options.configPath !== void 0 ? [options.configPath] : void 0;
@@ -6177,7 +6477,7 @@ function isMutableRegistry(reg) {
6177
6477
  }
6178
6478
  function resolveStaticOptions(options) {
6179
6479
  const legacyRegistry = options.extensionRegistry;
6180
- const configRegistry = legacyRegistry === void 0 && options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6480
+ const configRegistry = legacyRegistry === void 0 && options.config?.extensions !== void 0 && options.config.extensions.length > 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6181
6481
  return {
6182
6482
  extensionRegistry: legacyRegistry ?? configRegistry,
6183
6483
  // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
@@ -6189,7 +6489,7 @@ function resolveStaticOptions(options) {
6189
6489
  };
6190
6490
  }
6191
6491
  function resolveOptions(options) {
6192
- const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6492
+ const configRegistry = options.config?.extensions !== void 0 && options.config.extensions.length > 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6193
6493
  const legacyRegistry = options.extensionRegistry;
6194
6494
  return {
6195
6495
  // When the caller provides the deprecated extensionRegistry field directly,
@@ -6274,7 +6574,7 @@ function createProgramContextFailureDiagnostic(filePath, error) {
6274
6574
  }
6275
6575
 
6276
6576
  // src/static-build.ts
6277
- var ts10 = __toESM(require("typescript"), 1);
6577
+ var ts9 = __toESM(require("typescript"), 1);
6278
6578
  function toStaticBuildContext(context) {
6279
6579
  return context;
6280
6580
  }
@@ -6289,7 +6589,7 @@ function getModuleSymbol(context) {
6289
6589
  return context.checker.getSymbolAtLocation(context.sourceFile) ?? sourceFileWithSymbol.symbol;
6290
6590
  }
6291
6591
  function isSchemaSourceDeclaration(declaration) {
6292
- return ts10.isClassDeclaration(declaration) || ts10.isInterfaceDeclaration(declaration) || ts10.isTypeAliasDeclaration(declaration);
6592
+ return ts9.isClassDeclaration(declaration) || ts9.isInterfaceDeclaration(declaration) || ts9.isTypeAliasDeclaration(declaration);
6293
6593
  }
6294
6594
  function resolveModuleExport(context, exportName = "default") {
6295
6595
  const moduleSymbol = getModuleSymbol(context);
@@ -6300,15 +6600,15 @@ function resolveModuleExport(context, exportName = "default") {
6300
6600
  if (exportSymbol === null) {
6301
6601
  return null;
6302
6602
  }
6303
- return exportSymbol.flags & ts10.SymbolFlags.Alias ? context.checker.getAliasedSymbol(exportSymbol) : exportSymbol;
6603
+ return exportSymbol.flags & ts9.SymbolFlags.Alias ? context.checker.getAliasedSymbol(exportSymbol) : exportSymbol;
6304
6604
  }
6305
6605
  function resolveModuleExportDeclaration(context, exportName = "default") {
6306
6606
  return resolveModuleExport(context, exportName)?.declarations?.find(isSchemaSourceDeclaration) ?? null;
6307
6607
  }
6308
6608
 
6309
6609
  // src/generators/discovered-schema.ts
6310
- var ts11 = __toESM(require("typescript"), 1);
6311
- var import_internal7 = require("@formspec/analysis/internal");
6610
+ var ts10 = __toESM(require("typescript"), 1);
6611
+ var import_internal8 = require("@formspec/analysis/internal");
6312
6612
  var import_internals6 = require("@formspec/core/internals");
6313
6613
  function toDiscoveredTypeSchemas(result, resolvedMetadata) {
6314
6614
  return {
@@ -6317,17 +6617,17 @@ function toDiscoveredTypeSchemas(result, resolvedMetadata) {
6317
6617
  };
6318
6618
  }
6319
6619
  function isNamedTypeDeclaration(declaration) {
6320
- return ts11.isClassDeclaration(declaration) || ts11.isInterfaceDeclaration(declaration) || ts11.isTypeAliasDeclaration(declaration);
6620
+ return ts10.isClassDeclaration(declaration) || ts10.isInterfaceDeclaration(declaration) || ts10.isTypeAliasDeclaration(declaration);
6321
6621
  }
6322
6622
  function hasConcreteTypeArguments(type, checker) {
6323
6623
  if ("aliasTypeArguments" in type && Array.isArray(type.aliasTypeArguments) && type.aliasTypeArguments.length > 0) {
6324
6624
  return true;
6325
6625
  }
6326
- if ((type.flags & ts11.TypeFlags.Object) === 0) {
6626
+ if ((type.flags & ts10.TypeFlags.Object) === 0) {
6327
6627
  return false;
6328
6628
  }
6329
6629
  const objectType = type;
6330
- if ((objectType.objectFlags & ts11.ObjectFlags.Reference) === 0) {
6630
+ if ((objectType.objectFlags & ts10.ObjectFlags.Reference) === 0) {
6331
6631
  return false;
6332
6632
  }
6333
6633
  return checker.getTypeArguments(objectType).length > 0;
@@ -6340,13 +6640,13 @@ function getNamedTypeDeclaration2(type) {
6340
6640
  return declaration;
6341
6641
  }
6342
6642
  }
6343
- const aliasDeclaration = type.aliasSymbol?.declarations?.find(ts11.isTypeAliasDeclaration);
6643
+ const aliasDeclaration = type.aliasSymbol?.declarations?.find(ts10.isTypeAliasDeclaration);
6344
6644
  return aliasDeclaration;
6345
6645
  }
6346
6646
  function getFallbackName(sourceNode, fallback = "AnonymousType") {
6347
6647
  if (sourceNode !== void 0 && "name" in sourceNode) {
6348
6648
  const namedNode = sourceNode;
6349
- if (namedNode.name !== void 0 && ts11.isIdentifier(namedNode.name)) {
6649
+ if (namedNode.name !== void 0 && ts10.isIdentifier(namedNode.name)) {
6350
6650
  return namedNode.name.text;
6351
6651
  }
6352
6652
  }
@@ -6568,7 +6868,7 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
6568
6868
  function generateSchemasFromDeclaration(options) {
6569
6869
  const filePath = options.declaration.getSourceFile().fileName;
6570
6870
  const resolved = resolveStaticOptions(options);
6571
- if (ts11.isClassDeclaration(options.declaration)) {
6871
+ if (ts10.isClassDeclaration(options.declaration)) {
6572
6872
  return generateSchemasFromAnalysis(
6573
6873
  analyzeClassToIR(
6574
6874
  options.declaration,
@@ -6582,7 +6882,7 @@ function generateSchemasFromDeclaration(options) {
6582
6882
  resolved
6583
6883
  );
6584
6884
  }
6585
- if (ts11.isInterfaceDeclaration(options.declaration)) {
6885
+ if (ts10.isInterfaceDeclaration(options.declaration)) {
6586
6886
  return generateSchemasFromAnalysis(
6587
6887
  analyzeInterfaceToIR(
6588
6888
  options.declaration,
@@ -6596,7 +6896,7 @@ function generateSchemasFromDeclaration(options) {
6596
6896
  resolved
6597
6897
  );
6598
6898
  }
6599
- if (ts11.isTypeAliasDeclaration(options.declaration)) {
6899
+ if (ts10.isTypeAliasDeclaration(options.declaration)) {
6600
6900
  const analyzedAlias = analyzeTypeAliasToIR(
6601
6901
  options.declaration,
6602
6902
  options.context.checker,
@@ -6655,7 +6955,7 @@ function generateSchemasFromReturnType(options) {
6655
6955
  const returnType = signature !== void 0 ? options.context.checker.getReturnTypeOfSignature(signature) : options.context.checker.getTypeAtLocation(options.declaration);
6656
6956
  const type = unwrapPromiseType(options.context.checker, returnType);
6657
6957
  const sourceNode = type !== returnType ? unwrapPromiseTypeNode(options.declaration.type) ?? options.declaration.type ?? options.declaration : options.declaration.type ?? options.declaration;
6658
- const fallbackName = options.declaration.name !== void 0 && ts11.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
6958
+ const fallbackName = options.declaration.name !== void 0 && ts10.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
6659
6959
  return generateSchemasFromResolvedType({
6660
6960
  ...options,
6661
6961
  type,
@@ -6665,7 +6965,7 @@ function generateSchemasFromReturnType(options) {
6665
6965
  }
6666
6966
  function resolveDeclarationMetadata(options) {
6667
6967
  const resolved = resolveStaticOptions(options);
6668
- const analysis = (0, import_internal7.analyzeMetadataForNodeWithChecker)({
6968
+ const analysis = (0, import_internal8.analyzeMetadataForNodeWithChecker)({
6669
6969
  checker: options.context.checker,
6670
6970
  node: options.declaration,
6671
6971
  metadata: resolved.metadata,
@@ -6702,14 +7002,14 @@ function unwrapPromiseTypeNode(typeNode) {
6702
7002
  if (typeNode === void 0) {
6703
7003
  return void 0;
6704
7004
  }
6705
- if (ts11.isParenthesizedTypeNode(typeNode)) {
7005
+ if (ts10.isParenthesizedTypeNode(typeNode)) {
6706
7006
  const unwrapped = unwrapPromiseTypeNode(typeNode.type);
6707
7007
  return unwrapped ?? typeNode;
6708
7008
  }
6709
7009
  return isPromiseTypeReferenceNode(typeNode) ? typeNode.typeArguments[0] : typeNode;
6710
7010
  }
6711
7011
  function isPromiseTypeReferenceNode(typeNode) {
6712
- return ts11.isTypeReferenceNode(typeNode) && ts11.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
7012
+ return ts10.isTypeReferenceNode(typeNode) && ts10.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
6713
7013
  }
6714
7014
 
6715
7015
  // src/generators/mixed-authoring.ts