@formspec/build 0.1.0-alpha.58 → 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/cli.js CHANGED
@@ -1048,7 +1048,7 @@ function generateJsonSchemaFromIR(ir, options) {
1048
1048
  applyConstraints(ctx.defs[schemaName], typeDef.constraints, ctx);
1049
1049
  }
1050
1050
  if (typeDef.annotations && typeDef.annotations.length > 0) {
1051
- applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx);
1051
+ applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx, typeDef.type);
1052
1052
  }
1053
1053
  }
1054
1054
  const properties = {};
@@ -1121,7 +1121,7 @@ function generateFieldSchema(field, ctx) {
1121
1121
  }
1122
1122
  }
1123
1123
  applyResolvedMetadata(schema, field.metadata);
1124
- applyAnnotations(schema, rootAnnotations, ctx);
1124
+ applyAnnotations(schema, rootAnnotations, ctx, field.type);
1125
1125
  if (itemStringSchema !== void 0) {
1126
1126
  applyAnnotations(itemStringSchema, itemAnnotations, ctx);
1127
1127
  }
@@ -1164,32 +1164,36 @@ function applyPathTargetedConstraints(schema, pathConstraints, ctx, typeNode) {
1164
1164
  return schema;
1165
1165
  }
1166
1166
  if (schema.$ref) {
1167
- const { $ref, ...rest } = schema;
1168
- const refPart = { $ref };
1169
- const overridePart = {
1170
- properties: propertyOverrides,
1171
- ...rest
1167
+ return {
1168
+ ...schema,
1169
+ properties: propertyOverrides
1172
1170
  };
1173
- return { allOf: [refPart, overridePart] };
1174
1171
  }
1175
1172
  if (schema.type === "object" && schema.properties) {
1176
- const missingOverrides = {};
1177
1173
  for (const [target, overrideSchema] of Object.entries(propertyOverrides)) {
1178
- if (schema.properties[target]) {
1179
- mergeSchemaOverride(schema.properties[target], overrideSchema);
1180
- } else {
1181
- missingOverrides[target] = overrideSchema;
1174
+ if (Object.hasOwn(schema.properties, target)) {
1175
+ const existing = schema.properties[target];
1176
+ if (existing) {
1177
+ mergeSchemaOverride(existing, overrideSchema);
1178
+ continue;
1179
+ }
1182
1180
  }
1181
+ Object.defineProperty(schema.properties, target, {
1182
+ value: overrideSchema,
1183
+ writable: true,
1184
+ enumerable: true,
1185
+ configurable: true
1186
+ });
1183
1187
  }
1184
- if (Object.keys(missingOverrides).length === 0) {
1185
- return schema;
1186
- }
1187
- return {
1188
- allOf: [schema, { properties: missingOverrides }]
1189
- };
1188
+ return schema;
1190
1189
  }
1191
1190
  if (schema.allOf) {
1192
- schema.allOf = [...schema.allOf, { properties: propertyOverrides }];
1191
+ const overrideMember = { properties: propertyOverrides };
1192
+ const flattened = tryFlattenAllOfToSiblings(schema, overrideMember);
1193
+ if (flattened !== void 0) {
1194
+ return flattened;
1195
+ }
1196
+ schema.allOf = [...schema.allOf, overrideMember];
1193
1197
  return schema;
1194
1198
  }
1195
1199
  return schema;
@@ -1302,7 +1306,7 @@ function generatePropertySchema(prop, ctx) {
1302
1306
  const schema = generateTypeNode(prop.type, ctx);
1303
1307
  applyConstraints(schema, prop.constraints, ctx);
1304
1308
  applyResolvedMetadata(schema, prop.metadata);
1305
- applyAnnotations(schema, prop.annotations, ctx);
1309
+ applyAnnotations(schema, prop.annotations, ctx, prop.type);
1306
1310
  return schema;
1307
1311
  }
1308
1312
  function generateUnionType(type, ctx) {
@@ -1405,13 +1409,20 @@ function buildPropertyOverrides(pathConstraints, typeNode, ctx) {
1405
1409
  grouped.push(constraint);
1406
1410
  byTarget.set(target, grouped);
1407
1411
  }
1408
- const overrides = {};
1412
+ const overrides = /* @__PURE__ */ Object.create(null);
1409
1413
  for (const [target, constraints] of byTarget) {
1410
- overrides[resolveSerializedPropertyName(target, typeNode, ctx)] = buildPathOverrideSchema(
1414
+ const resolvedName = resolveSerializedPropertyName(target, typeNode, ctx);
1415
+ const schema = buildPathOverrideSchema(
1411
1416
  constraints.map(stripLeadingPathSegment),
1412
1417
  resolveTargetTypeNode(target, typeNode, ctx),
1413
1418
  ctx
1414
1419
  );
1420
+ Object.defineProperty(overrides, resolvedName, {
1421
+ value: schema,
1422
+ writable: true,
1423
+ enumerable: true,
1424
+ configurable: true
1425
+ });
1415
1426
  }
1416
1427
  return overrides;
1417
1428
  }
@@ -1438,6 +1449,34 @@ function buildPathOverrideSchema(constraints, typeNode, ctx) {
1438
1449
  schema.properties = buildPropertyOverrides(nestedConstraints, effectiveType, ctx);
1439
1450
  return schema;
1440
1451
  }
1452
+ function tryFlattenAllOfToSiblings(schema, overrideMember) {
1453
+ if (schema.allOf?.length !== 1) {
1454
+ return void 0;
1455
+ }
1456
+ const [soleMember] = schema.allOf;
1457
+ if (soleMember === void 0) {
1458
+ return void 0;
1459
+ }
1460
+ const { allOf: _allOf, ...outerRest } = schema;
1461
+ const outerKeys = new Set(Object.keys(outerRest));
1462
+ const memberKeys = new Set(Object.keys(soleMember));
1463
+ const overrideKeys = new Set(Object.keys(overrideMember));
1464
+ for (const key of memberKeys) {
1465
+ if (outerKeys.has(key) || overrideKeys.has(key)) {
1466
+ return void 0;
1467
+ }
1468
+ }
1469
+ for (const key of overrideKeys) {
1470
+ if (outerKeys.has(key)) {
1471
+ return void 0;
1472
+ }
1473
+ }
1474
+ return {
1475
+ ...outerRest,
1476
+ ...soleMember,
1477
+ ...overrideMember
1478
+ };
1479
+ }
1441
1480
  function mergeSchemaOverride(target, override) {
1442
1481
  const nullableValueBranch = getNullableUnionValueSchema(target);
1443
1482
  if (nullableValueBranch !== void 0) {
@@ -1445,11 +1484,16 @@ function mergeSchemaOverride(target, override) {
1445
1484
  return;
1446
1485
  }
1447
1486
  if (override.properties !== void 0) {
1448
- const mergedProperties = target.properties ?? {};
1487
+ const mergedProperties = target.properties ?? /* @__PURE__ */ Object.create(null);
1449
1488
  for (const [name, propertyOverride] of Object.entries(override.properties)) {
1450
- const existing = mergedProperties[name];
1489
+ const existing = Object.hasOwn(mergedProperties, name) ? mergedProperties[name] : void 0;
1451
1490
  if (existing === void 0) {
1452
- mergedProperties[name] = propertyOverride;
1491
+ Object.defineProperty(mergedProperties, name, {
1492
+ value: propertyOverride,
1493
+ writable: true,
1494
+ enumerable: true,
1495
+ configurable: true
1496
+ });
1453
1497
  } else {
1454
1498
  mergeSchemaOverride(existing, propertyOverride);
1455
1499
  }
@@ -1467,7 +1511,12 @@ function mergeSchemaOverride(target, override) {
1467
1511
  if (key === "properties" || key === "items") {
1468
1512
  continue;
1469
1513
  }
1470
- target[key] = value;
1514
+ Object.defineProperty(target, key, {
1515
+ value,
1516
+ writable: true,
1517
+ enumerable: true,
1518
+ configurable: true
1519
+ });
1471
1520
  }
1472
1521
  }
1473
1522
  function stripLeadingPathSegment(constraint) {
@@ -1567,7 +1616,7 @@ function applyConstraints(schema, constraints, ctx) {
1567
1616
  }
1568
1617
  }
1569
1618
  }
1570
- function applyAnnotations(schema, annotations, ctx) {
1619
+ function applyAnnotations(schema, annotations, ctx, typeNode) {
1571
1620
  for (const annotation of annotations) {
1572
1621
  switch (annotation.annotationKind) {
1573
1622
  case "displayName":
@@ -1580,7 +1629,7 @@ function applyAnnotations(schema, annotations, ctx) {
1580
1629
  schema[`${ctx.vendorPrefix}-remarks`] = annotation.value;
1581
1630
  break;
1582
1631
  case "defaultValue":
1583
- schema.default = annotation.value;
1632
+ schema.default = coerceDefaultValue(annotation.value, typeNode, schema, ctx);
1584
1633
  break;
1585
1634
  case "format":
1586
1635
  schema.format = annotation.value;
@@ -1605,6 +1654,34 @@ function applyAnnotations(schema, annotations, ctx) {
1605
1654
  }
1606
1655
  }
1607
1656
  }
1657
+ function coerceDefaultValue(value, typeNode, emittedSchema, ctx) {
1658
+ if (typeNode?.kind !== "custom") {
1659
+ return value;
1660
+ }
1661
+ const registration = ctx.extensionRegistry?.findType(typeNode.typeId);
1662
+ if (registration === void 0) {
1663
+ return value;
1664
+ }
1665
+ if (registration.serializeDefault !== void 0) {
1666
+ return registration.serializeDefault(value, typeNode.payload);
1667
+ }
1668
+ const declaredType = emittedSchema["type"];
1669
+ if (declaredType === "string" && typeof value !== "string") {
1670
+ if (typeof value === "number") {
1671
+ if (!Number.isFinite(value)) {
1672
+ return value;
1673
+ }
1674
+ return String(value);
1675
+ }
1676
+ if (typeof value === "boolean") {
1677
+ return String(value);
1678
+ }
1679
+ if (typeof value === "bigint") {
1680
+ return value.toString();
1681
+ }
1682
+ }
1683
+ return value;
1684
+ }
1608
1685
  function generateCustomType(type, ctx) {
1609
1686
  const registration = ctx.extensionRegistry?.findType(type.typeId);
1610
1687
  if (registration === void 0) {
@@ -2062,7 +2139,9 @@ import {
2062
2139
  import {
2063
2140
  getTagDefinition,
2064
2141
  normalizeFormSpecTagName,
2065
- getSyntheticLogger
2142
+ getSyntheticLogger,
2143
+ _validateExtensionSetup,
2144
+ logSetupDiagnostics
2066
2145
  } from "@formspec/analysis/internal";
2067
2146
  function buildConstraintTagSources(extensions) {
2068
2147
  return extensions.map((extension) => ({
@@ -2071,6 +2150,16 @@ function buildConstraintTagSources(extensions) {
2071
2150
  constraintTags: extension.constraintTags.map((tag) => ({
2072
2151
  tagName: normalizeFormSpecTagName(tag.tagName)
2073
2152
  }))
2153
+ } : {},
2154
+ // Include customTypes so _validateExtensionSetup can check tsTypeNames for
2155
+ // unsupported built-in overrides and invalid identifier patterns.
2156
+ ...extension.types !== void 0 ? {
2157
+ customTypes: extension.types.map((type) => ({
2158
+ // tsTypeNames: deprecated in favour of symbol-based detection, but
2159
+ // still required for name-based validation in _validateExtensionSetup
2160
+ // until the bridge is fully retired (see §synthetic-checker-retirement §4C).
2161
+ tsTypeNames: type.tsTypeNames ?? [type.typeName]
2162
+ }))
2074
2163
  } : {}
2075
2164
  }));
2076
2165
  }
@@ -2080,7 +2169,13 @@ function createExtensionRegistry(extensions) {
2080
2169
  extensionCount: extensions.length,
2081
2170
  extensionIds: extensions.map((e) => e.extensionId)
2082
2171
  });
2083
- const reservedTagSources = buildConstraintTagSources(extensions);
2172
+ const extensionTagSources = buildConstraintTagSources(extensions);
2173
+ const setupDiagnostics = _validateExtensionSetup(extensionTagSources);
2174
+ logSetupDiagnostics(registryLog, {
2175
+ diagnosticCount: setupDiagnostics.length,
2176
+ codes: setupDiagnostics.map((d) => d.kind)
2177
+ });
2178
+ const reservedTagSources = extensionTagSources;
2084
2179
  let symbolMap = /* @__PURE__ */ new Map();
2085
2180
  const typeMap = /* @__PURE__ */ new Map();
2086
2181
  const typeNameMap = /* @__PURE__ */ new Map();
@@ -2217,10 +2312,12 @@ function createExtensionRegistry(extensions) {
2217
2312
  constraintTagCount: constraintTagMap.size,
2218
2313
  broadeningCount: builtinBroadeningMap.size,
2219
2314
  annotationCount: annotationMap.size,
2220
- metadataSlotCount: metadataSlotMap.size
2315
+ metadataSlotCount: metadataSlotMap.size,
2316
+ setupDiagnosticCount: setupDiagnostics.length
2221
2317
  });
2222
2318
  return {
2223
2319
  extensions,
2320
+ setupDiagnostics,
2224
2321
  findType: (typeId) => typeMap.get(typeId),
2225
2322
  findTypeByName: (typeName) => typeNameMap.get(typeName),
2226
2323
  findTypeByBrand: (brand) => brandMap.get(brand),
@@ -2320,21 +2417,6 @@ var init_schema2 = __esm({
2320
2417
 
2321
2418
  // src/extensions/ts-type-utils.ts
2322
2419
  import * as ts from "typescript";
2323
- function collectBrandIdentifiers(type) {
2324
- if (!type.isIntersection()) {
2325
- return [];
2326
- }
2327
- const brands = [];
2328
- for (const prop of type.getProperties()) {
2329
- const decl = prop.valueDeclaration ?? prop.declarations?.[0];
2330
- if (decl === void 0) continue;
2331
- if (!ts.isPropertySignature(decl) && !ts.isPropertyDeclaration(decl)) continue;
2332
- if (!ts.isComputedPropertyName(decl.name)) continue;
2333
- if (!ts.isIdentifier(decl.name.expression)) continue;
2334
- brands.push(decl.name.expression.text);
2335
- }
2336
- return brands;
2337
- }
2338
2420
  function resolveCanonicalSymbol(type, checker) {
2339
2421
  const raw = type.aliasSymbol ?? type.getSymbol();
2340
2422
  if (raw === void 0) return void 0;
@@ -2365,7 +2447,7 @@ var init_ts_type_utils = __esm({
2365
2447
 
2366
2448
  // src/extensions/resolve-custom-type.ts
2367
2449
  import * as ts2 from "typescript";
2368
- import { stripNullishUnion } from "@formspec/analysis/internal";
2450
+ import { _collectBrandIdentifiers, stripNullishUnion } from "@formspec/analysis/internal";
2369
2451
  function getTypeNodeRegistrationName(typeNode) {
2370
2452
  if (ts2.isTypeReferenceNode(typeNode)) {
2371
2453
  return ts2.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : typeNode.typeName.right.text;
@@ -2426,7 +2508,7 @@ function resolveCustomTypeFromTsType(type, checker, registry, sourceNode) {
2426
2508
  return bySymbol;
2427
2509
  }
2428
2510
  }
2429
- for (const brand of collectBrandIdentifiers(stripped)) {
2511
+ for (const brand of _collectBrandIdentifiers(stripped)) {
2430
2512
  const byBrand = registry.findTypeByBrand(brand);
2431
2513
  if (byBrand !== void 0) {
2432
2514
  return byBrand;
@@ -2445,21 +2527,15 @@ var init_resolve_custom_type = __esm({
2445
2527
  });
2446
2528
 
2447
2529
  // src/analyzer/builtin-brands.ts
2448
- import * as ts3 from "typescript";
2449
- function isIntegerBrandedType(type) {
2450
- if (!type.isIntersection()) return false;
2451
- if (!type.types.some((member) => !!(member.flags & ts3.TypeFlags.Number))) return false;
2452
- return collectBrandIdentifiers(type).includes("__integerBrand");
2453
- }
2530
+ import { _isIntegerBrandedType } from "@formspec/analysis/internal";
2454
2531
  var init_builtin_brands = __esm({
2455
2532
  "src/analyzer/builtin-brands.ts"() {
2456
2533
  "use strict";
2457
- init_ts_type_utils();
2458
2534
  }
2459
2535
  });
2460
2536
 
2461
2537
  // src/analyzer/tsdoc-parser.ts
2462
- import * as ts4 from "typescript";
2538
+ import * as ts3 from "typescript";
2463
2539
  import {
2464
2540
  checkSyntheticTagApplication,
2465
2541
  choosePreferredPayloadText,
@@ -2484,10 +2560,14 @@ import {
2484
2560
  import "@formspec/core/internals";
2485
2561
  import { noopLogger as noopLogger4 } from "@formspec/core";
2486
2562
  import {
2563
+ _emitSetupDiagnostics,
2564
+ _mapSetupDiagnosticCode,
2487
2565
  getBuildLogger,
2488
2566
  getBroadeningLogger,
2489
2567
  getSyntheticLogger as getSyntheticLogger2,
2490
2568
  getTypedParserLogger,
2569
+ extractEffectiveArgumentText,
2570
+ mapTypedParserDiagnosticCode,
2491
2571
  parseTagArgument,
2492
2572
  describeTypeKind,
2493
2573
  elapsedMicros,
@@ -2513,23 +2593,23 @@ function getExtensionTypeNames(registry) {
2513
2593
  function collectImportedNames(sourceFile) {
2514
2594
  const importedNames = /* @__PURE__ */ new Set();
2515
2595
  for (const statement of sourceFile.statements) {
2516
- if (ts4.isImportDeclaration(statement) && statement.importClause !== void 0) {
2596
+ if (ts3.isImportDeclaration(statement) && statement.importClause !== void 0) {
2517
2597
  const clause = statement.importClause;
2518
2598
  if (clause.name !== void 0) {
2519
2599
  importedNames.add(clause.name.text);
2520
2600
  }
2521
2601
  if (clause.namedBindings !== void 0) {
2522
- if (ts4.isNamedImports(clause.namedBindings)) {
2602
+ if (ts3.isNamedImports(clause.namedBindings)) {
2523
2603
  for (const specifier of clause.namedBindings.elements) {
2524
2604
  importedNames.add(specifier.name.text);
2525
2605
  }
2526
- } else if (ts4.isNamespaceImport(clause.namedBindings)) {
2606
+ } else if (ts3.isNamespaceImport(clause.namedBindings)) {
2527
2607
  importedNames.add(clause.namedBindings.name.text);
2528
2608
  }
2529
2609
  }
2530
2610
  continue;
2531
2611
  }
2532
- if (ts4.isImportEqualsDeclaration(statement)) {
2612
+ if (ts3.isImportEqualsDeclaration(statement)) {
2533
2613
  importedNames.add(statement.name.text);
2534
2614
  }
2535
2615
  }
@@ -2537,13 +2617,13 @@ function collectImportedNames(sourceFile) {
2537
2617
  }
2538
2618
  function isNonReferenceIdentifier(node) {
2539
2619
  const parent = node.parent;
2540
- 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) {
2620
+ 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) {
2541
2621
  return true;
2542
2622
  }
2543
- if ((ts4.isPropertyAssignment(parent) || ts4.isPropertyAccessExpression(parent)) && parent.name === node) {
2623
+ if ((ts3.isPropertyAssignment(parent) || ts3.isPropertyAccessExpression(parent)) && parent.name === node) {
2544
2624
  return true;
2545
2625
  }
2546
- if (ts4.isQualifiedName(parent) && parent.right === node) {
2626
+ if (ts3.isQualifiedName(parent) && parent.right === node) {
2547
2627
  return true;
2548
2628
  }
2549
2629
  return false;
@@ -2555,20 +2635,20 @@ function astReferencesImportedName(root, importedNames) {
2555
2635
  let found = false;
2556
2636
  const visit = (node) => {
2557
2637
  if (found) return;
2558
- if (ts4.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
2638
+ if (ts3.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
2559
2639
  found = true;
2560
2640
  return;
2561
2641
  }
2562
- ts4.forEachChild(node, visit);
2642
+ ts3.forEachChild(node, visit);
2563
2643
  };
2564
2644
  visit(root);
2565
2645
  return found;
2566
2646
  }
2567
2647
  function getObjectMembers(statement) {
2568
- if (ts4.isInterfaceDeclaration(statement)) {
2648
+ if (ts3.isInterfaceDeclaration(statement)) {
2569
2649
  return statement.members;
2570
2650
  }
2571
- if (ts4.isTypeLiteralNode(statement.type)) {
2651
+ if (ts3.isTypeLiteralNode(statement.type)) {
2572
2652
  return statement.type.members;
2573
2653
  }
2574
2654
  return void 0;
@@ -2580,7 +2660,7 @@ function rewriteImportedMemberTypes(statement, sourceFile, importedNames) {
2580
2660
  }
2581
2661
  const replacements = [];
2582
2662
  for (const member of members) {
2583
- if (!ts4.isPropertySignature(member)) {
2663
+ if (!ts3.isPropertySignature(member)) {
2584
2664
  if (astReferencesImportedName(member, importedNames)) {
2585
2665
  return null;
2586
2666
  }
@@ -2612,14 +2692,14 @@ function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
2612
2692
  );
2613
2693
  const result = [];
2614
2694
  for (const statement of sourceFile.statements) {
2615
- if (ts4.isImportDeclaration(statement)) continue;
2616
- if (ts4.isImportEqualsDeclaration(statement)) continue;
2617
- if (ts4.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
2695
+ if (ts3.isImportDeclaration(statement)) continue;
2696
+ if (ts3.isImportEqualsDeclaration(statement)) continue;
2697
+ if (ts3.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
2618
2698
  if (!astReferencesImportedName(statement, importedNamesToSkip)) {
2619
2699
  result.push(statement.getText(sourceFile));
2620
2700
  continue;
2621
2701
  }
2622
- if (ts4.isInterfaceDeclaration(statement) || ts4.isTypeAliasDeclaration(statement)) {
2702
+ if (ts3.isInterfaceDeclaration(statement) || ts3.isTypeAliasDeclaration(statement)) {
2623
2703
  const rewritten = rewriteImportedMemberTypes(statement, sourceFile, importedNamesToSkip);
2624
2704
  if (rewritten !== null) {
2625
2705
  result.push(rewritten);
@@ -2720,7 +2800,7 @@ function stripHintNullishUnion(type) {
2720
2800
  return type;
2721
2801
  }
2722
2802
  const nonNullish = type.types.filter(
2723
- (member) => (member.flags & (ts4.TypeFlags.Null | ts4.TypeFlags.Undefined)) === 0
2803
+ (member) => (member.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined)) === 0
2724
2804
  );
2725
2805
  if (nonNullish.length === 1 && nonNullish[0] !== void 0) {
2726
2806
  return nonNullish[0];
@@ -2736,10 +2816,10 @@ function isUserEmittableHintProperty(property, declaration) {
2736
2816
  }
2737
2817
  if ("name" in declaration && declaration.name !== void 0) {
2738
2818
  const name = declaration.name;
2739
- if (ts4.isComputedPropertyName(name) || ts4.isPrivateIdentifier(name)) {
2819
+ if (ts3.isComputedPropertyName(name) || ts3.isPrivateIdentifier(name)) {
2740
2820
  return false;
2741
2821
  }
2742
- if (!ts4.isIdentifier(name) && !ts4.isStringLiteral(name) && !ts4.isNumericLiteral(name)) {
2822
+ if (!ts3.isIdentifier(name) && !ts3.isStringLiteral(name) && !ts3.isNumericLiteral(name)) {
2743
2823
  return false;
2744
2824
  }
2745
2825
  }
@@ -2985,7 +3065,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2985
3065
  }
2986
3066
  const hasBroadening = (() => {
2987
3067
  if (target === null) {
2988
- if (isIntegerBrandedType(stripNullishUnion2(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
3068
+ if (_isIntegerBrandedType(stripNullishUnion2(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
2989
3069
  return true;
2990
3070
  }
2991
3071
  return hasBuiltinConstraintBroadening(tagName, options);
@@ -3016,10 +3096,10 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
3016
3096
  ]);
3017
3097
  }
3018
3098
  }
3019
- const effectiveArgumentText = parsedTag !== null ? parseTagSyntax(tagName, rawText).argumentText : rawText;
3020
3099
  if (hasBroadening) {
3021
3100
  return emit("bypass", []);
3022
3101
  }
3102
+ const effectiveArgumentText = extractEffectiveArgumentText(tagName, rawText, parsedTag);
3023
3103
  const typedParseResult = parseTagArgument(tagName, effectiveArgumentText, "build");
3024
3104
  if (!typedParseResult.ok) {
3025
3105
  if (typedParserTraceEnabled) {
@@ -3032,23 +3112,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
3032
3112
  diagnosticCode: typedParseResult.diagnostic.code
3033
3113
  });
3034
3114
  }
3035
- let mappedCode;
3036
- switch (typedParseResult.diagnostic.code) {
3037
- case "MISSING_TAG_ARGUMENT":
3038
- mappedCode = "MISSING_TAG_ARGUMENT";
3039
- break;
3040
- case "INVALID_TAG_ARGUMENT":
3041
- mappedCode = "INVALID_TAG_ARGUMENT";
3042
- break;
3043
- case "UNKNOWN_TAG":
3044
- throw new Error(
3045
- `Unexpected UNKNOWN_TAG from parseTagArgument("${tagName}") \u2014 tag was resolved via getTagDefinition.`
3046
- );
3047
- default: {
3048
- const _exhaustive = typedParseResult.diagnostic.code;
3049
- throw new Error(`Unknown diagnostic code: ${String(_exhaustive)}`);
3050
- }
3051
- }
3115
+ const mappedCode = mapTypedParserDiagnosticCode(typedParseResult.diagnostic.code, tagName);
3052
3116
  return emit("C-reject", [
3053
3117
  makeDiagnostic(mappedCode, typedParseResult.diagnostic.message, provenance)
3054
3118
  ]);
@@ -3105,13 +3169,13 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
3105
3169
  } : {}
3106
3170
  });
3107
3171
  if (result.diagnostics.length === 0) {
3108
- return emit("C-pass", []);
3172
+ return emit("D-pass", []);
3109
3173
  }
3110
3174
  const setupDiagnostic = result.diagnostics.find((diagnostic) => diagnostic.kind !== "typescript");
3111
3175
  if (setupDiagnostic !== void 0) {
3112
3176
  return emit("C-reject", [
3113
3177
  makeDiagnostic(
3114
- setupDiagnostic.kind === "unsupported-custom-type-override" ? "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" : "SYNTHETIC_SETUP_FAILURE",
3178
+ _mapSetupDiagnosticCode(setupDiagnostic.kind),
3115
3179
  setupDiagnostic.message,
3116
3180
  provenance
3117
3181
  )
@@ -3178,6 +3242,16 @@ function parseTSDocTags(node, file = "", options) {
3178
3242
  if (cached !== void 0) {
3179
3243
  return cached;
3180
3244
  }
3245
+ const setupDiags = options?.extensionRegistry?.setupDiagnostics;
3246
+ if (setupDiags !== void 0 && setupDiags.length > 0) {
3247
+ const result2 = {
3248
+ constraints: [],
3249
+ annotations: [],
3250
+ diagnostics: _emitSetupDiagnostics(setupDiags, file)
3251
+ };
3252
+ parseResultCache.set(cacheKey, result2);
3253
+ return result2;
3254
+ }
3181
3255
  const constraints = [];
3182
3256
  const annotations = [];
3183
3257
  const diagnostics = [];
@@ -3189,12 +3263,12 @@ function parseTSDocTags(node, file = "", options) {
3189
3263
  const sourceText = sourceFile.getFullText();
3190
3264
  const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
3191
3265
  const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
3192
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
3266
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
3193
3267
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
3194
3268
  const extensionTagNames = getExtensionTagNames(options);
3195
3269
  if (commentRanges) {
3196
3270
  for (const range of commentRanges) {
3197
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) {
3271
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) {
3198
3272
  continue;
3199
3273
  }
3200
3274
  const commentText = sourceText.substring(range.pos, range.end);
@@ -3351,10 +3425,10 @@ function extractDisplayNameMetadata(node) {
3351
3425
  const memberDisplayNames = /* @__PURE__ */ new Map();
3352
3426
  const sourceFile = node.getSourceFile();
3353
3427
  const sourceText = sourceFile.getFullText();
3354
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
3428
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
3355
3429
  if (commentRanges) {
3356
3430
  for (const range of commentRanges) {
3357
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) continue;
3431
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) continue;
3358
3432
  const commentText = sourceText.substring(range.pos, range.end);
3359
3433
  if (!commentText.startsWith("/**")) continue;
3360
3434
  const unified = parseUnifiedComment(commentText);
@@ -3379,7 +3453,7 @@ function extractDisplayNameMetadata(node) {
3379
3453
  }
3380
3454
  function collectRawTextFallbacks(node, file) {
3381
3455
  const fallbacks = /* @__PURE__ */ new Map();
3382
- for (const tag of ts4.getJSDocTags(node)) {
3456
+ for (const tag of ts3.getJSDocTags(node)) {
3383
3457
  const tagName = normalizeConstraintTagName2(tag.tagName.text);
3384
3458
  if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
3385
3459
  const commentText = getTagCommentText(tag)?.trim() ?? "";
@@ -3434,7 +3508,7 @@ function getTagCommentText(tag) {
3434
3508
  if (typeof tag.comment === "string") {
3435
3509
  return tag.comment;
3436
3510
  }
3437
- return ts4.getTextOfJSDocComment(tag.comment);
3511
+ return ts3.getTextOfJSDocComment(tag.comment);
3438
3512
  }
3439
3513
  var SYNTHETIC_TYPE_FORMAT_FLAGS, MAX_HINT_CANDIDATES, MAX_HINT_DEPTH, parseResultCache;
3440
3514
  var init_tsdoc_parser = __esm({
@@ -3442,7 +3516,7 @@ var init_tsdoc_parser = __esm({
3442
3516
  "use strict";
3443
3517
  init_resolve_custom_type();
3444
3518
  init_builtin_brands();
3445
- SYNTHETIC_TYPE_FORMAT_FLAGS = ts4.TypeFormatFlags.NoTruncation | ts4.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
3519
+ SYNTHETIC_TYPE_FORMAT_FLAGS = ts3.TypeFormatFlags.NoTruncation | ts3.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
3446
3520
  MAX_HINT_CANDIDATES = 5;
3447
3521
  MAX_HINT_DEPTH = 3;
3448
3522
  parseResultCache = /* @__PURE__ */ new Map();
@@ -3450,7 +3524,7 @@ var init_tsdoc_parser = __esm({
3450
3524
  });
3451
3525
 
3452
3526
  // src/analyzer/jsdoc-constraints.ts
3453
- import * as ts5 from "typescript";
3527
+ import * as ts4 from "typescript";
3454
3528
  function extractJSDocParseResult(node, file = "", options) {
3455
3529
  return parseTSDocTags(node, file, options);
3456
3530
  }
@@ -3465,18 +3539,18 @@ function extractJSDocAnnotationNodes(node, file = "", options) {
3465
3539
  function extractDefaultValueAnnotation(initializer, file = "") {
3466
3540
  if (!initializer) return null;
3467
3541
  let value;
3468
- if (ts5.isStringLiteral(initializer)) {
3542
+ if (ts4.isStringLiteral(initializer)) {
3469
3543
  value = initializer.text;
3470
- } else if (ts5.isNumericLiteral(initializer)) {
3544
+ } else if (ts4.isNumericLiteral(initializer)) {
3471
3545
  value = Number(initializer.text);
3472
- } else if (initializer.kind === ts5.SyntaxKind.TrueKeyword) {
3546
+ } else if (initializer.kind === ts4.SyntaxKind.TrueKeyword) {
3473
3547
  value = true;
3474
- } else if (initializer.kind === ts5.SyntaxKind.FalseKeyword) {
3548
+ } else if (initializer.kind === ts4.SyntaxKind.FalseKeyword) {
3475
3549
  value = false;
3476
- } else if (initializer.kind === ts5.SyntaxKind.NullKeyword) {
3550
+ } else if (initializer.kind === ts4.SyntaxKind.NullKeyword) {
3477
3551
  value = null;
3478
- } else if (ts5.isPrefixUnaryExpression(initializer)) {
3479
- if (initializer.operator === ts5.SyntaxKind.MinusToken && ts5.isNumericLiteral(initializer.operand)) {
3552
+ } else if (ts4.isPrefixUnaryExpression(initializer)) {
3553
+ if (initializer.operator === ts4.SyntaxKind.MinusToken && ts4.isNumericLiteral(initializer.operand)) {
3480
3554
  value = -Number(initializer.operand.text);
3481
3555
  }
3482
3556
  }
@@ -3503,34 +3577,34 @@ var init_jsdoc_constraints = __esm({
3503
3577
  });
3504
3578
 
3505
3579
  // src/analyzer/class-analyzer.ts
3506
- import * as ts6 from "typescript";
3580
+ import * as ts5 from "typescript";
3507
3581
  import {
3508
3582
  analyzeMetadataForNodeWithChecker,
3509
3583
  parseCommentBlock
3510
3584
  } from "@formspec/analysis/internal";
3511
3585
  function isObjectType(type) {
3512
- return !!(type.flags & ts6.TypeFlags.Object);
3586
+ return !!(type.flags & ts5.TypeFlags.Object);
3513
3587
  }
3514
3588
  function isIntersectionType(type) {
3515
- return !!(type.flags & ts6.TypeFlags.Intersection);
3589
+ return !!(type.flags & ts5.TypeFlags.Intersection);
3516
3590
  }
3517
3591
  function isResolvableObjectLikeAliasTypeNode(typeNode) {
3518
- if (ts6.isParenthesizedTypeNode(typeNode)) {
3592
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3519
3593
  return isResolvableObjectLikeAliasTypeNode(typeNode.type);
3520
3594
  }
3521
- if (ts6.isTypeLiteralNode(typeNode) || ts6.isTypeReferenceNode(typeNode)) {
3595
+ if (ts5.isTypeLiteralNode(typeNode) || ts5.isTypeReferenceNode(typeNode)) {
3522
3596
  return true;
3523
3597
  }
3524
- return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
3598
+ return ts5.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
3525
3599
  }
3526
3600
  function isSemanticallyPlainObjectLikeType(type, checker) {
3527
3601
  if (isIntersectionType(type)) {
3528
3602
  return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
3529
3603
  }
3530
- 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);
3604
+ 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);
3531
3605
  }
3532
3606
  function isTypeReference(type) {
3533
- return !!(type.flags & ts6.TypeFlags.Object) && !!(type.objectFlags & ts6.ObjectFlags.Reference);
3607
+ return !!(type.flags & ts5.TypeFlags.Object) && !!(type.objectFlags & ts5.ObjectFlags.Reference);
3534
3608
  }
3535
3609
  function makeParseOptions(extensionRegistry, fieldType, checker, subjectType, hostType) {
3536
3610
  if (extensionRegistry === void 0 && fieldType === void 0 && checker === void 0 && subjectType === void 0 && hostType === void 0) {
@@ -3551,6 +3625,17 @@ function createAnalyzerMetadataPolicy(input, discriminator) {
3551
3625
  discriminator
3552
3626
  };
3553
3627
  }
3628
+ function deduplicateDiagnostics(diagnostics) {
3629
+ if (diagnostics.length <= 1) return diagnostics;
3630
+ const seen = /* @__PURE__ */ new Set();
3631
+ return diagnostics.filter((d) => {
3632
+ if (!DEDUPLICATABLE_DIAGNOSTIC_CODES.has(d.code)) return true;
3633
+ const key = `${d.code}\0${d.message}`;
3634
+ if (seen.has(key)) return false;
3635
+ seen.add(key);
3636
+ return true;
3637
+ });
3638
+ }
3554
3639
  function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node, checker, extensionRegistry, buildContext) {
3555
3640
  const analysis = analyzeMetadataForNodeWithChecker({
3556
3641
  checker,
@@ -3587,10 +3672,120 @@ function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node,
3587
3672
  }
3588
3673
  return resolvedMetadata;
3589
3674
  }
3675
+ function getInheritableAnnotationStringValue(annotation) {
3676
+ if (annotation.annotationKind === "format") return annotation.value;
3677
+ return void 0;
3678
+ }
3679
+ function isOverridingInheritableAnnotation(annotation) {
3680
+ const value = getInheritableAnnotationStringValue(annotation);
3681
+ if (value === void 0) return true;
3682
+ return value.trim().length > 0;
3683
+ }
3684
+ function collectInheritedTypeAnnotations(derivedDecl, existingAnnotations, checker, extensionRegistry) {
3685
+ const existingKinds = new Set(
3686
+ existingAnnotations.filter(isOverridingInheritableAnnotation).map((a) => a.annotationKind)
3687
+ );
3688
+ const needed = /* @__PURE__ */ new Set();
3689
+ for (const kind of INHERITABLE_TYPE_ANNOTATION_KINDS) {
3690
+ if (!existingKinds.has(kind)) needed.add(kind);
3691
+ }
3692
+ if (needed.size === 0) return [];
3693
+ const inherited = [];
3694
+ const seen = /* @__PURE__ */ new Set([derivedDecl]);
3695
+ const queue = [];
3696
+ const resolveSymbolTarget = (sym) => {
3697
+ if ((sym.flags & ts5.SymbolFlags.Alias) === 0) return sym;
3698
+ try {
3699
+ return checker.getAliasedSymbol(sym);
3700
+ } catch {
3701
+ return sym;
3702
+ }
3703
+ };
3704
+ const isObjectShapedTypeAlias = (alias) => {
3705
+ const type = checker.getTypeFromTypeNode(alias.type);
3706
+ if ((type.flags & ts5.TypeFlags.Object) !== 0) return true;
3707
+ if (type.isIntersection()) return true;
3708
+ return false;
3709
+ };
3710
+ const enqueueCandidate = (baseDecl, fromTypeAliasRhs) => {
3711
+ if (seen.has(baseDecl)) return;
3712
+ if (ts5.isClassDeclaration(baseDecl) || ts5.isInterfaceDeclaration(baseDecl)) {
3713
+ seen.add(baseDecl);
3714
+ queue.push(baseDecl);
3715
+ return;
3716
+ }
3717
+ if (ts5.isTypeAliasDeclaration(baseDecl)) {
3718
+ if (!fromTypeAliasRhs && !isObjectShapedTypeAlias(baseDecl)) return;
3719
+ seen.add(baseDecl);
3720
+ queue.push(baseDecl);
3721
+ }
3722
+ };
3723
+ const enqueueBasesOf = (decl) => {
3724
+ if (ts5.isTypeAliasDeclaration(decl)) {
3725
+ const rhs = decl.type;
3726
+ if (!ts5.isTypeReferenceNode(rhs)) return;
3727
+ const sym = checker.getSymbolAtLocation(rhs.typeName);
3728
+ if (!sym) return;
3729
+ const target = resolveSymbolTarget(sym);
3730
+ for (const baseDecl of target.declarations ?? []) {
3731
+ enqueueCandidate(
3732
+ baseDecl,
3733
+ /*fromTypeAliasRhs*/
3734
+ true
3735
+ );
3736
+ }
3737
+ return;
3738
+ }
3739
+ const heritageClauses = decl.heritageClauses;
3740
+ if (!heritageClauses) return;
3741
+ for (const clause of heritageClauses) {
3742
+ if (clause.token !== ts5.SyntaxKind.ExtendsKeyword) continue;
3743
+ for (const typeExpr of clause.types) {
3744
+ const sym = checker.getSymbolAtLocation(typeExpr.expression);
3745
+ if (!sym) continue;
3746
+ const target = resolveSymbolTarget(sym);
3747
+ for (const baseDecl of target.declarations ?? []) {
3748
+ enqueueCandidate(
3749
+ baseDecl,
3750
+ /*fromTypeAliasRhs*/
3751
+ false
3752
+ );
3753
+ }
3754
+ }
3755
+ }
3756
+ };
3757
+ enqueueBasesOf(derivedDecl);
3758
+ for (let queueIndex = 0; queueIndex < queue.length && needed.size > 0; queueIndex++) {
3759
+ const baseDecl = queue[queueIndex];
3760
+ if (baseDecl === void 0) continue;
3761
+ const baseFile = baseDecl.getSourceFile().fileName;
3762
+ const baseAnnotations = extractJSDocAnnotationNodes(
3763
+ baseDecl,
3764
+ baseFile,
3765
+ makeParseOptions(extensionRegistry)
3766
+ );
3767
+ for (const annotation of baseAnnotations) {
3768
+ if (!needed.has(annotation.annotationKind)) continue;
3769
+ if (!isOverridingInheritableAnnotation(annotation)) continue;
3770
+ inherited.push(annotation);
3771
+ needed.delete(annotation.annotationKind);
3772
+ }
3773
+ if (needed.size > 0) {
3774
+ enqueueBasesOf(baseDecl);
3775
+ }
3776
+ }
3777
+ return inherited;
3778
+ }
3779
+ function extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) {
3780
+ const local = extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry));
3781
+ const inherited = collectInheritedTypeAnnotations(namedDecl, local, checker, extensionRegistry);
3782
+ if (inherited.length === 0) return [...local];
3783
+ return [...local, ...inherited];
3784
+ }
3590
3785
  function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRegistry, metadataPolicy) {
3591
3786
  const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
3592
3787
  const declarationType = checker.getTypeAtLocation(declaration);
3593
- const logicalName = ts6.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
3788
+ const logicalName = ts5.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
3594
3789
  const docResult = extractJSDocParseResult(
3595
3790
  declaration,
3596
3791
  file,
@@ -3632,13 +3827,19 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3632
3827
  file,
3633
3828
  makeParseOptions(extensionRegistry, void 0, checker, classType, classType)
3634
3829
  );
3635
- const annotations = [...classDoc.annotations];
3830
+ const inheritedClassAnnotations = collectInheritedTypeAnnotations(
3831
+ classDecl,
3832
+ classDoc.annotations,
3833
+ checker,
3834
+ extensionRegistry
3835
+ );
3836
+ const annotations = [...classDoc.annotations, ...inheritedClassAnnotations];
3636
3837
  diagnostics.push(...classDoc.diagnostics);
3637
3838
  const visiting = /* @__PURE__ */ new Set();
3638
3839
  const instanceMethods = [];
3639
3840
  const staticMethods = [];
3640
3841
  for (const member of classDecl.members) {
3641
- if (ts6.isPropertyDeclaration(member)) {
3842
+ if (ts5.isPropertyDeclaration(member)) {
3642
3843
  const fieldNode = analyzeFieldToIR(
3643
3844
  member,
3644
3845
  checker,
@@ -3654,10 +3855,10 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3654
3855
  fields.push(fieldNode);
3655
3856
  fieldLayouts.push({});
3656
3857
  }
3657
- } else if (ts6.isMethodDeclaration(member)) {
3858
+ } else if (ts5.isMethodDeclaration(member)) {
3658
3859
  const methodInfo = analyzeMethod(member, checker);
3659
3860
  if (methodInfo) {
3660
- const isStatic = member.modifiers?.some((m) => m.kind === ts6.SyntaxKind.StaticKeyword);
3861
+ const isStatic = member.modifiers?.some((m) => m.kind === ts5.SyntaxKind.StaticKeyword);
3661
3862
  if (isStatic) {
3662
3863
  staticMethods.push(methodInfo);
3663
3864
  } else {
@@ -3689,6 +3890,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3689
3890
  hostType: classType
3690
3891
  }
3691
3892
  );
3893
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3692
3894
  return {
3693
3895
  name,
3694
3896
  ...metadata !== void 0 && { metadata },
@@ -3696,7 +3898,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3696
3898
  fieldLayouts,
3697
3899
  typeRegistry,
3698
3900
  ...annotations.length > 0 && { annotations },
3699
- ...diagnostics.length > 0 && { diagnostics },
3901
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3700
3902
  instanceMethods,
3701
3903
  staticMethods
3702
3904
  };
@@ -3716,11 +3918,20 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3716
3918
  file,
3717
3919
  makeParseOptions(extensionRegistry, void 0, checker, interfaceType, interfaceType)
3718
3920
  );
3719
- const annotations = [...interfaceDoc.annotations];
3921
+ const inheritedInterfaceAnnotations = collectInheritedTypeAnnotations(
3922
+ interfaceDecl,
3923
+ interfaceDoc.annotations,
3924
+ checker,
3925
+ extensionRegistry
3926
+ );
3927
+ const annotations = [
3928
+ ...interfaceDoc.annotations,
3929
+ ...inheritedInterfaceAnnotations
3930
+ ];
3720
3931
  diagnostics.push(...interfaceDoc.diagnostics);
3721
3932
  const visiting = /* @__PURE__ */ new Set();
3722
3933
  for (const member of interfaceDecl.members) {
3723
- if (ts6.isPropertySignature(member)) {
3934
+ if (ts5.isPropertySignature(member)) {
3724
3935
  const fieldNode = analyzeInterfacePropertyToIR(
3725
3936
  member,
3726
3937
  checker,
@@ -3761,6 +3972,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3761
3972
  hostType: interfaceType
3762
3973
  }
3763
3974
  );
3975
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3764
3976
  return {
3765
3977
  name,
3766
3978
  ...metadata !== void 0 && { metadata },
@@ -3768,7 +3980,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3768
3980
  fieldLayouts,
3769
3981
  typeRegistry,
3770
3982
  ...annotations.length > 0 && { annotations },
3771
- ...diagnostics.length > 0 && { diagnostics },
3983
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3772
3984
  instanceMethods: [],
3773
3985
  staticMethods: []
3774
3986
  };
@@ -3778,7 +3990,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3778
3990
  if (members === null) {
3779
3991
  const sourceFile = typeAlias.getSourceFile();
3780
3992
  const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
3781
- const kindDesc = ts6.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3993
+ const kindDesc = ts5.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3782
3994
  return {
3783
3995
  ok: false,
3784
3996
  kind: "not-object-like",
@@ -3813,7 +4025,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3813
4025
  diagnostics.push(...typeAliasDoc.diagnostics);
3814
4026
  const visiting = /* @__PURE__ */ new Set();
3815
4027
  for (const member of members) {
3816
- if (ts6.isPropertySignature(member)) {
4028
+ if (ts5.isPropertySignature(member)) {
3817
4029
  const fieldNode = analyzeInterfacePropertyToIR(
3818
4030
  member,
3819
4031
  checker,
@@ -3853,6 +4065,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3853
4065
  hostType: aliasType
3854
4066
  }
3855
4067
  );
4068
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3856
4069
  return {
3857
4070
  ok: true,
3858
4071
  analysis: {
@@ -3862,7 +4075,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3862
4075
  fieldLayouts: specializedFields.map(() => ({})),
3863
4076
  typeRegistry,
3864
4077
  ...annotations.length > 0 && { annotations },
3865
- ...diagnostics.length > 0 && { diagnostics },
4078
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3866
4079
  instanceMethods: [],
3867
4080
  staticMethods: []
3868
4081
  }
@@ -3880,13 +4093,13 @@ function makeAnalysisDiagnostic(code, message, primaryLocation, relatedLocations
3880
4093
  function getLeadingParsedTags(node) {
3881
4094
  const sourceFile = node.getSourceFile();
3882
4095
  const sourceText = sourceFile.getFullText();
3883
- const commentRanges = ts6.getLeadingCommentRanges(sourceText, node.getFullStart());
4096
+ const commentRanges = ts5.getLeadingCommentRanges(sourceText, node.getFullStart());
3884
4097
  if (commentRanges === void 0) {
3885
4098
  return [];
3886
4099
  }
3887
4100
  const parsedTags = [];
3888
4101
  for (const range of commentRanges) {
3889
- if (range.kind !== ts6.SyntaxKind.MultiLineCommentTrivia) {
4102
+ if (range.kind !== ts5.SyntaxKind.MultiLineCommentTrivia) {
3890
4103
  continue;
3891
4104
  }
3892
4105
  const commentText = sourceText.slice(range.pos, range.end);
@@ -3904,19 +4117,19 @@ function resolveDiscriminatorProperty(node, checker, fieldName) {
3904
4117
  return null;
3905
4118
  }
3906
4119
  const declaration = propertySymbol.valueDeclaration ?? propertySymbol.declarations?.find(
3907
- (candidate) => ts6.isPropertyDeclaration(candidate) || ts6.isPropertySignature(candidate)
4120
+ (candidate) => ts5.isPropertyDeclaration(candidate) || ts5.isPropertySignature(candidate)
3908
4121
  ) ?? propertySymbol.declarations?.[0];
3909
4122
  return {
3910
4123
  declaration,
3911
4124
  type: checker.getTypeOfSymbolAtLocation(propertySymbol, declaration ?? node),
3912
- optional: !!(propertySymbol.flags & ts6.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
4125
+ optional: !!(propertySymbol.flags & ts5.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
3913
4126
  };
3914
4127
  }
3915
4128
  function isLocalTypeParameterName(node, typeParameterName) {
3916
4129
  return node.typeParameters?.some((typeParameter) => typeParameter.name.text === typeParameterName) ?? false;
3917
4130
  }
3918
4131
  function isNullishSemanticType(type) {
3919
- if (type.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined | ts6.TypeFlags.Void | ts6.TypeFlags.Unknown | ts6.TypeFlags.Any)) {
4132
+ if (type.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined | ts5.TypeFlags.Void | ts5.TypeFlags.Unknown | ts5.TypeFlags.Any)) {
3920
4133
  return true;
3921
4134
  }
3922
4135
  return type.isUnion() && type.types.some((member) => isNullishSemanticType(member));
@@ -3926,7 +4139,7 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
3926
4139
  return false;
3927
4140
  }
3928
4141
  seen.add(type);
3929
- if (type.flags & ts6.TypeFlags.StringLike) {
4142
+ if (type.flags & ts5.TypeFlags.StringLike) {
3930
4143
  return true;
3931
4144
  }
3932
4145
  if (type.isUnion()) {
@@ -3939,13 +4152,13 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
3939
4152
  return false;
3940
4153
  }
3941
4154
  function getObjectLikeTypeAliasMembers(typeNode) {
3942
- if (ts6.isParenthesizedTypeNode(typeNode)) {
4155
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3943
4156
  return getObjectLikeTypeAliasMembers(typeNode.type);
3944
4157
  }
3945
- if (ts6.isTypeLiteralNode(typeNode)) {
4158
+ if (ts5.isTypeLiteralNode(typeNode)) {
3946
4159
  return [...typeNode.members];
3947
4160
  }
3948
- if (ts6.isIntersectionTypeNode(typeNode)) {
4161
+ if (ts5.isIntersectionTypeNode(typeNode)) {
3949
4162
  const members = [];
3950
4163
  for (const intersectionMember of typeNode.types) {
3951
4164
  const resolvedMembers = getObjectLikeTypeAliasMembers(intersectionMember);
@@ -4108,7 +4321,7 @@ function resolveLiteralDiscriminatorPropertyValue(boundType, propertyName, check
4108
4321
  }
4109
4322
  if (propertyType.isUnion()) {
4110
4323
  const nonNullMembers = propertyType.types.filter(
4111
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
4324
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4112
4325
  );
4113
4326
  if (nonNullMembers.length > 0 && nonNullMembers.every((member) => member.isStringLiteral())) {
4114
4327
  diagnostics.push(
@@ -4157,13 +4370,13 @@ function resolveNamedDiscriminatorDeclaration(type, checker, seen = /* @__PURE__
4157
4370
  seen.add(type);
4158
4371
  const symbol = type.aliasSymbol ?? type.getSymbol();
4159
4372
  if (symbol !== void 0) {
4160
- const aliased = symbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
4373
+ const aliased = symbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
4161
4374
  const targetSymbol = aliased ?? symbol;
4162
4375
  const declaration = targetSymbol.declarations?.find(
4163
- (candidate) => ts6.isClassDeclaration(candidate) || ts6.isInterfaceDeclaration(candidate) || ts6.isTypeAliasDeclaration(candidate) || ts6.isEnumDeclaration(candidate)
4376
+ (candidate) => ts5.isClassDeclaration(candidate) || ts5.isInterfaceDeclaration(candidate) || ts5.isTypeAliasDeclaration(candidate) || ts5.isEnumDeclaration(candidate)
4164
4377
  );
4165
4378
  if (declaration !== void 0) {
4166
- if (ts6.isTypeAliasDeclaration(declaration) && ts6.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
4379
+ if (ts5.isTypeAliasDeclaration(declaration) && ts5.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
4167
4380
  return resolveNamedDiscriminatorDeclaration(
4168
4381
  checker.getTypeFromTypeNode(declaration.type),
4169
4382
  checker,
@@ -4191,7 +4404,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
4191
4404
  }
4192
4405
  if (boundType.isUnion()) {
4193
4406
  const nonNullMembers = boundType.types.filter(
4194
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
4407
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4195
4408
  );
4196
4409
  if (nonNullMembers.every((member) => member.isStringLiteral())) {
4197
4410
  diagnostics.push(
@@ -4236,7 +4449,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
4236
4449
  return null;
4237
4450
  }
4238
4451
  function getDeclarationName(node) {
4239
- if (ts6.isClassDeclaration(node) || ts6.isInterfaceDeclaration(node) || ts6.isTypeAliasDeclaration(node) || ts6.isEnumDeclaration(node)) {
4452
+ if (ts5.isClassDeclaration(node) || ts5.isInterfaceDeclaration(node) || ts5.isTypeAliasDeclaration(node) || ts5.isEnumDeclaration(node)) {
4240
4453
  return node.name?.text ?? "anonymous";
4241
4454
  }
4242
4455
  return "anonymous";
@@ -4291,11 +4504,11 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
4291
4504
  if (sourceTypeNode === void 0) {
4292
4505
  return [];
4293
4506
  }
4294
- const unwrapParentheses = (typeNode) => ts6.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
4507
+ const unwrapParentheses = (typeNode) => ts5.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
4295
4508
  const directTypeNode = unwrapParentheses(sourceTypeNode);
4296
- const referenceTypeNode = ts6.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
4509
+ const referenceTypeNode = ts5.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
4297
4510
  const resolvedTypeNode = resolveAliasedTypeNode(directTypeNode, checker);
4298
- return ts6.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
4511
+ return ts5.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
4299
4512
  })();
4300
4513
  if (referenceTypeNode?.typeArguments === void 0) {
4301
4514
  return [];
@@ -4303,7 +4516,7 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
4303
4516
  return referenceTypeNode.typeArguments.map((argumentNode) => {
4304
4517
  const argumentType = checker.getTypeFromTypeNode(argumentNode);
4305
4518
  const baseSymbol = argumentType.aliasSymbol ?? argumentType.getSymbol();
4306
- const argumentSymbol = baseSymbol !== void 0 && baseSymbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(baseSymbol) : baseSymbol;
4519
+ const argumentSymbol = baseSymbol !== void 0 && baseSymbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(baseSymbol) : baseSymbol;
4307
4520
  const argumentDecl = argumentSymbol?.declarations?.[0];
4308
4521
  if (argumentDecl !== void 0 && argumentDecl.getSourceFile().fileName !== file) {
4309
4522
  const argumentName = argumentSymbol?.getName() ?? baseSymbol?.getName();
@@ -4366,7 +4579,7 @@ function applyDiscriminatorToObjectProperties(properties, node, subjectType, che
4366
4579
  );
4367
4580
  }
4368
4581
  function analyzeFieldToIR(prop, checker, file, typeRegistry, visiting, diagnostics, hostType, metadataPolicy, extensionRegistry) {
4369
- if (!ts6.isIdentifier(prop.name)) {
4582
+ if (!ts5.isIdentifier(prop.name)) {
4370
4583
  return null;
4371
4584
  }
4372
4585
  const name = prop.name.text;
@@ -4493,7 +4706,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
4493
4706
  const seen = /* @__PURE__ */ new Set();
4494
4707
  const duplicates = /* @__PURE__ */ new Set();
4495
4708
  for (const member of members) {
4496
- if (!ts6.isPropertySignature(member)) {
4709
+ if (!ts5.isPropertySignature(member)) {
4497
4710
  continue;
4498
4711
  }
4499
4712
  const name = getAnalyzableObjectLikePropertyName(member.name);
@@ -4509,7 +4722,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
4509
4722
  return [...duplicates].sort();
4510
4723
  }
4511
4724
  function getAnalyzableObjectLikePropertyName(name) {
4512
- if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
4725
+ if (ts5.isIdentifier(name) || ts5.isStringLiteral(name) || ts5.isNumericLiteral(name)) {
4513
4726
  return name.text;
4514
4727
  }
4515
4728
  return null;
@@ -4604,28 +4817,28 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4604
4817
  if (primitiveAlias) {
4605
4818
  return primitiveAlias;
4606
4819
  }
4607
- if (isIntegerBrandedType(type)) {
4820
+ if (_isIntegerBrandedType(type)) {
4608
4821
  return { kind: "primitive", primitiveKind: "integer" };
4609
4822
  }
4610
- if (type.flags & ts6.TypeFlags.String) {
4823
+ if (type.flags & ts5.TypeFlags.String) {
4611
4824
  return { kind: "primitive", primitiveKind: "string" };
4612
4825
  }
4613
- if (type.flags & ts6.TypeFlags.Number) {
4826
+ if (type.flags & ts5.TypeFlags.Number) {
4614
4827
  return { kind: "primitive", primitiveKind: "number" };
4615
4828
  }
4616
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
4829
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
4617
4830
  return { kind: "primitive", primitiveKind: "bigint" };
4618
4831
  }
4619
- if (type.flags & ts6.TypeFlags.Boolean) {
4832
+ if (type.flags & ts5.TypeFlags.Boolean) {
4620
4833
  return { kind: "primitive", primitiveKind: "boolean" };
4621
4834
  }
4622
- if (type.flags & ts6.TypeFlags.Null) {
4835
+ if (type.flags & ts5.TypeFlags.Null) {
4623
4836
  return { kind: "primitive", primitiveKind: "null" };
4624
4837
  }
4625
- if (type.flags & ts6.TypeFlags.Undefined) {
4838
+ if (type.flags & ts5.TypeFlags.Undefined) {
4626
4839
  return { kind: "primitive", primitiveKind: "null" };
4627
4840
  }
4628
- if (type.flags & ts6.TypeFlags.Void) {
4841
+ if (type.flags & ts5.TypeFlags.Void) {
4629
4842
  return { kind: "primitive", primitiveKind: "null" };
4630
4843
  }
4631
4844
  if (type.isStringLiteral()) {
@@ -4712,10 +4925,10 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4712
4925
  return { kind: "primitive", primitiveKind: "string" };
4713
4926
  }
4714
4927
  function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4715
- if (!(type.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
4928
+ if (!(type.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null)) && !_isIntegerBrandedType(type)) {
4716
4929
  return null;
4717
4930
  }
4718
- const aliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
4931
+ const aliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
4719
4932
  if (!aliasDecl) {
4720
4933
  return null;
4721
4934
  }
@@ -4726,11 +4939,18 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
4726
4939
  ...extractJSDocConstraintNodes(aliasDecl, file, makeParseOptions(extensionRegistry)),
4727
4940
  ...extractTypeAliasConstraintNodes(aliasDecl.type, checker, file, extensionRegistry)
4728
4941
  ];
4729
- const annotations = extractJSDocAnnotationNodes(
4942
+ const localAnnotations = extractJSDocAnnotationNodes(
4730
4943
  aliasDecl,
4731
4944
  file,
4732
4945
  makeParseOptions(extensionRegistry)
4733
4946
  );
4947
+ const inheritedAnnotations = collectInheritedTypeAnnotations(
4948
+ aliasDecl,
4949
+ localAnnotations,
4950
+ checker,
4951
+ extensionRegistry
4952
+ );
4953
+ const annotations = [...localAnnotations, ...inheritedAnnotations];
4734
4954
  const metadata = resolveNodeMetadata(
4735
4955
  metadataPolicy,
4736
4956
  "type",
@@ -4765,8 +4985,8 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
4765
4985
  return { kind: "reference", name: aliasName, typeArguments: [] };
4766
4986
  }
4767
4987
  function getReferencedTypeAliasDeclaration(sourceNode, checker) {
4768
- const typeNode = sourceNode && (ts6.isPropertyDeclaration(sourceNode) || ts6.isPropertySignature(sourceNode) || ts6.isParameter(sourceNode)) ? sourceNode.type : void 0;
4769
- if (!typeNode || !ts6.isTypeReferenceNode(typeNode)) {
4988
+ const typeNode = sourceNode && (ts5.isPropertyDeclaration(sourceNode) || ts5.isPropertySignature(sourceNode) || ts5.isParameter(sourceNode)) ? sourceNode.type : void 0;
4989
+ if (!typeNode || !ts5.isTypeReferenceNode(typeNode)) {
4770
4990
  return void 0;
4771
4991
  }
4772
4992
  return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -4787,7 +5007,7 @@ function resolveNamedTypeWithSourceRecovery(type, sourceNode, checker) {
4787
5007
  return { typeName: refAliasDecl.name.text, namedDecl: refAliasDecl };
4788
5008
  }
4789
5009
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4790
- if (!ts6.isTypeReferenceNode(typeNode)) {
5010
+ if (!ts5.isTypeReferenceNode(typeNode)) {
4791
5011
  return false;
4792
5012
  }
4793
5013
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -4795,10 +5015,10 @@ function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4795
5015
  return false;
4796
5016
  }
4797
5017
  const resolved = checker.getTypeFromTypeNode(aliasDecl.type);
4798
- return !!(resolved.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null));
5018
+ return !!(resolved.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null));
4799
5019
  }
4800
5020
  function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics, visitedAliases = /* @__PURE__ */ new Set()) {
4801
- const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration);
5021
+ const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration);
4802
5022
  if (nestedAliasDecl !== void 0 && !visitedAliases.has(nestedAliasDecl)) {
4803
5023
  visitedAliases.add(nestedAliasDecl);
4804
5024
  return resolveAliasedPrimitiveTarget(
@@ -4813,22 +5033,22 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
4813
5033
  visitedAliases
4814
5034
  );
4815
5035
  }
4816
- if (isIntegerBrandedType(type)) {
5036
+ if (_isIntegerBrandedType(type)) {
4817
5037
  return { kind: "primitive", primitiveKind: "integer" };
4818
5038
  }
4819
- if (type.flags & ts6.TypeFlags.String) {
5039
+ if (type.flags & ts5.TypeFlags.String) {
4820
5040
  return { kind: "primitive", primitiveKind: "string" };
4821
5041
  }
4822
- if (type.flags & ts6.TypeFlags.Number) {
5042
+ if (type.flags & ts5.TypeFlags.Number) {
4823
5043
  return { kind: "primitive", primitiveKind: "number" };
4824
5044
  }
4825
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
5045
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
4826
5046
  return { kind: "primitive", primitiveKind: "bigint" };
4827
5047
  }
4828
- if (type.flags & ts6.TypeFlags.Boolean) {
5048
+ if (type.flags & ts5.TypeFlags.Boolean) {
4829
5049
  return { kind: "primitive", primitiveKind: "boolean" };
4830
5050
  }
4831
- if (type.flags & ts6.TypeFlags.Null) {
5051
+ if (type.flags & ts5.TypeFlags.Null) {
4832
5052
  return { kind: "primitive", primitiveKind: "null" };
4833
5053
  }
4834
5054
  return resolveTypeNode(
@@ -4848,7 +5068,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4848
5068
  let typeName = null;
4849
5069
  let namedDecl;
4850
5070
  if (recovered !== null) {
4851
- const recoveredAliasDecl = ts6.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
5071
+ const recoveredAliasDecl = ts5.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
4852
5072
  if (recoveredAliasDecl !== void 0) {
4853
5073
  const aliasUnderlyingType = checker.getTypeFromTypeNode(recoveredAliasDecl.type);
4854
5074
  const isNonGeneric = recoveredAliasDecl.typeParameters === void 0 || recoveredAliasDecl.typeParameters.length === 0;
@@ -4870,13 +5090,13 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4870
5090
  (memberTypeNode) => !isNullishTypeNode(resolveAliasedTypeNode(memberTypeNode, checker))
4871
5091
  );
4872
5092
  const nonNullTypes = allTypes.filter(
4873
- (memberType) => !(memberType.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
5093
+ (memberType) => !(memberType.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4874
5094
  );
4875
5095
  const nonNullMembers = nonNullTypes.map((memberType, index) => ({
4876
5096
  memberType,
4877
5097
  sourceNode: nonNullSourceNodes.length === nonNullTypes.length ? nonNullSourceNodes[index] : void 0
4878
5098
  }));
4879
- const hasNull = allTypes.some((t) => t.flags & ts6.TypeFlags.Null);
5099
+ const hasNull = allTypes.some((t) => t.flags & ts5.TypeFlags.Null);
4880
5100
  const memberDisplayNames = /* @__PURE__ */ new Map();
4881
5101
  if (namedDecl) {
4882
5102
  for (const [value, label] of extractDisplayNameMetadata(namedDecl).memberDisplayNames) {
@@ -4896,7 +5116,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4896
5116
  if (existing !== void 0 && existing.type !== RESOLVING_TYPE_PLACEHOLDER) {
4897
5117
  return { kind: "reference", name: typeName, typeArguments: [] };
4898
5118
  }
4899
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5119
+ const annotations = namedDecl ? extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) : void 0;
4900
5120
  const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
4901
5121
  metadataPolicy,
4902
5122
  "type",
@@ -4923,7 +5143,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4923
5143
  const displayName = memberDisplayNames.get(String(value));
4924
5144
  return displayName !== void 0 ? { value, displayName } : { value };
4925
5145
  });
4926
- const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts6.TypeFlags.BooleanLiteral);
5146
+ const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts5.TypeFlags.BooleanLiteral);
4927
5147
  if (isBooleanUnion2) {
4928
5148
  const boolNode = { kind: "primitive", primitiveKind: "boolean" };
4929
5149
  const result = hasNull ? {
@@ -5015,7 +5235,7 @@ function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metad
5015
5235
  if (type.getProperties().length > 0) {
5016
5236
  return null;
5017
5237
  }
5018
- const indexInfo = checker.getIndexInfoOfType(type, ts6.IndexKind.String);
5238
+ const indexInfo = checker.getIndexInfoOfType(type, ts5.IndexKind.String);
5019
5239
  if (!indexInfo) {
5020
5240
  return null;
5021
5241
  }
@@ -5063,20 +5283,53 @@ function shouldEmitResolvedObjectProperty(property, declaration) {
5063
5283
  }
5064
5284
  if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
5065
5285
  const name = declaration.name;
5066
- if (ts6.isComputedPropertyName(name) || ts6.isPrivateIdentifier(name)) {
5286
+ if (ts5.isComputedPropertyName(name) || ts5.isPrivateIdentifier(name)) {
5067
5287
  return false;
5068
5288
  }
5069
- if (!ts6.isIdentifier(name) && !ts6.isStringLiteral(name) && !ts6.isNumericLiteral(name)) {
5289
+ if (!ts5.isIdentifier(name) && !ts5.isStringLiteral(name) && !ts5.isNumericLiteral(name)) {
5070
5290
  return false;
5071
5291
  }
5072
5292
  }
5073
5293
  return true;
5074
5294
  }
5295
+ function getPassThroughTypeAliasFromSourceNode(sourceNode, checker, extensionRegistry, resolvedTypeName) {
5296
+ const aliasDecl = getReferencedTypeAliasDeclaration(sourceNode, checker);
5297
+ if (!aliasDecl) return void 0;
5298
+ const aliasName = aliasDecl.name.text;
5299
+ if (aliasName === resolvedTypeName) return void 0;
5300
+ if (!ts5.isTypeReferenceNode(aliasDecl.type)) return void 0;
5301
+ if (!hasInheritableTypeAnnotation(aliasDecl, checker, extensionRegistry)) {
5302
+ return void 0;
5303
+ }
5304
+ return { aliasName, aliasDecl };
5305
+ }
5306
+ function hasInheritableTypeAnnotation(aliasDecl, checker, extensionRegistry) {
5307
+ const file = aliasDecl.getSourceFile().fileName;
5308
+ const local = extractJSDocAnnotationNodes(aliasDecl, file, makeParseOptions(extensionRegistry));
5309
+ for (const annotation of local) {
5310
+ if (!INHERITABLE_TYPE_ANNOTATION_KINDS.has(annotation.annotationKind)) continue;
5311
+ if (!isOverridingInheritableAnnotation(annotation)) continue;
5312
+ return true;
5313
+ }
5314
+ const inherited = collectInheritedTypeAnnotations(aliasDecl, local, checker, extensionRegistry);
5315
+ for (const annotation of inherited) {
5316
+ if (INHERITABLE_TYPE_ANNOTATION_KINDS.has(annotation.annotationKind)) return true;
5317
+ }
5318
+ return false;
5319
+ }
5075
5320
  function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
5076
5321
  const collectedDiagnostics = diagnostics ?? [];
5077
5322
  const typeName = getNamedTypeName(type);
5078
5323
  const namedTypeName = typeName ?? void 0;
5079
5324
  const namedDecl = getNamedTypeDeclaration(type);
5325
+ const passThroughAlias = getPassThroughTypeAliasFromSourceNode(
5326
+ sourceNode,
5327
+ checker,
5328
+ extensionRegistry,
5329
+ namedTypeName
5330
+ );
5331
+ const effectiveTypeName = passThroughAlias?.aliasName ?? namedTypeName;
5332
+ const effectiveNamedDecl = passThroughAlias?.aliasDecl ?? namedDecl;
5080
5333
  const referenceTypeArguments = extractReferenceTypeArguments(
5081
5334
  type,
5082
5335
  checker,
@@ -5088,13 +5341,13 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5088
5341
  extensionRegistry,
5089
5342
  collectedDiagnostics
5090
5343
  );
5091
- const instantiatedTypeName = namedTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
5092
- namedTypeName,
5344
+ const instantiatedTypeName = effectiveTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
5345
+ effectiveTypeName,
5093
5346
  referenceTypeArguments.map((argument) => argument.tsType),
5094
5347
  checker
5095
5348
  ) : void 0;
5096
- const registryTypeName = instantiatedTypeName ?? namedTypeName;
5097
- const shouldRegisterNamedType = registryTypeName !== void 0 && !(registryTypeName === "Record" && namedDecl?.getSourceFile().fileName !== file);
5349
+ const registryTypeName = instantiatedTypeName ?? effectiveTypeName;
5350
+ const shouldRegisterNamedType = registryTypeName !== void 0 && !(registryTypeName === "Record" && effectiveNamedDecl?.getSourceFile().fileName !== file);
5098
5351
  const clearNamedTypeRegistration = () => {
5099
5352
  if (registryTypeName === void 0 || !shouldRegisterNamedType) {
5100
5353
  return;
@@ -5115,7 +5368,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5115
5368
  typeRegistry[registryTypeName] = {
5116
5369
  name: registryTypeName,
5117
5370
  type: RESOLVING_TYPE_PLACEHOLDER,
5118
- provenance: provenanceForDeclaration(namedDecl, file)
5371
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
5119
5372
  };
5120
5373
  }
5121
5374
  visiting.add(type);
@@ -5147,17 +5400,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5147
5400
  clearNamedTypeRegistration();
5148
5401
  return recordNode;
5149
5402
  }
5150
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5151
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
5403
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
5404
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
5152
5405
  metadataPolicy,
5153
5406
  "type",
5154
5407
  registryTypeName,
5155
- namedDecl,
5408
+ effectiveNamedDecl,
5156
5409
  checker,
5157
5410
  extensionRegistry,
5158
5411
  {
5159
5412
  checker,
5160
- declaration: namedDecl,
5413
+ declaration: effectiveNamedDecl,
5161
5414
  subjectType: type
5162
5415
  }
5163
5416
  ) : void 0;
@@ -5166,7 +5419,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5166
5419
  ...metadata !== void 0 && { metadata },
5167
5420
  type: recordNode,
5168
5421
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
5169
- provenance: provenanceForDeclaration(namedDecl, file)
5422
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
5170
5423
  };
5171
5424
  return {
5172
5425
  kind: "reference",
@@ -5192,7 +5445,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5192
5445
  if (!declaration) continue;
5193
5446
  if (!shouldEmitResolvedObjectProperty(prop, declaration)) continue;
5194
5447
  const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);
5195
- const optional = !!(prop.flags & ts6.SymbolFlags.Optional);
5448
+ const optional = !!(prop.flags & ts5.SymbolFlags.Optional);
5196
5449
  const propTypeNode = resolveTypeNode(
5197
5450
  propType,
5198
5451
  checker,
@@ -5205,7 +5458,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5205
5458
  collectedDiagnostics
5206
5459
  );
5207
5460
  const fieldNodeInfo = fieldInfoMap?.get(prop.name);
5208
- const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts6.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
5461
+ const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts5.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
5209
5462
  declaration,
5210
5463
  checker,
5211
5464
  file,
@@ -5215,7 +5468,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5215
5468
  type,
5216
5469
  metadataPolicy,
5217
5470
  extensionRegistry
5218
- ) : ts6.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
5471
+ ) : ts5.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
5219
5472
  declaration,
5220
5473
  checker,
5221
5474
  file,
@@ -5243,9 +5496,9 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5243
5496
  visiting.delete(type);
5244
5497
  const objectNode = {
5245
5498
  kind: "object",
5246
- properties: namedDecl !== void 0 && (ts6.isClassDeclaration(namedDecl) || ts6.isInterfaceDeclaration(namedDecl) || ts6.isTypeAliasDeclaration(namedDecl)) ? applyDiscriminatorToObjectProperties(
5499
+ properties: effectiveNamedDecl !== void 0 && (ts5.isClassDeclaration(effectiveNamedDecl) || ts5.isInterfaceDeclaration(effectiveNamedDecl) || ts5.isTypeAliasDeclaration(effectiveNamedDecl)) ? applyDiscriminatorToObjectProperties(
5247
5500
  properties,
5248
- namedDecl,
5501
+ effectiveNamedDecl,
5249
5502
  type,
5250
5503
  checker,
5251
5504
  file,
@@ -5255,17 +5508,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5255
5508
  additionalProperties: true
5256
5509
  };
5257
5510
  if (registryTypeName !== void 0 && shouldRegisterNamedType) {
5258
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5259
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
5511
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
5512
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
5260
5513
  metadataPolicy,
5261
5514
  "type",
5262
5515
  registryTypeName,
5263
- namedDecl,
5516
+ effectiveNamedDecl,
5264
5517
  checker,
5265
5518
  extensionRegistry,
5266
5519
  {
5267
5520
  checker,
5268
- declaration: namedDecl,
5521
+ declaration: effectiveNamedDecl,
5269
5522
  subjectType: type
5270
5523
  }
5271
5524
  ) : void 0;
@@ -5274,7 +5527,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5274
5527
  ...metadata !== void 0 && { metadata },
5275
5528
  type: objectNode,
5276
5529
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
5277
- provenance: provenanceForDeclaration(namedDecl, file)
5530
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
5278
5531
  };
5279
5532
  return {
5280
5533
  kind: "reference",
@@ -5291,12 +5544,12 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5291
5544
  for (const symbol of symbols) {
5292
5545
  const declarations = symbol.declarations;
5293
5546
  if (!declarations) continue;
5294
- const classDecl = declarations.find(ts6.isClassDeclaration);
5547
+ const classDecl = declarations.find(ts5.isClassDeclaration);
5295
5548
  if (classDecl) {
5296
5549
  const map = /* @__PURE__ */ new Map();
5297
5550
  const hostType = checker.getTypeAtLocation(classDecl);
5298
5551
  for (const member of classDecl.members) {
5299
- if (ts6.isPropertyDeclaration(member) && ts6.isIdentifier(member.name)) {
5552
+ if (ts5.isPropertyDeclaration(member) && ts5.isIdentifier(member.name)) {
5300
5553
  const fieldNode = analyzeFieldToIR(
5301
5554
  member,
5302
5555
  checker,
@@ -5320,7 +5573,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5320
5573
  }
5321
5574
  return map;
5322
5575
  }
5323
- const interfaceDecl = declarations.find(ts6.isInterfaceDeclaration);
5576
+ const interfaceDecl = declarations.find(ts5.isInterfaceDeclaration);
5324
5577
  if (interfaceDecl) {
5325
5578
  return buildFieldNodeInfoMap(
5326
5579
  interfaceDecl.members,
@@ -5334,7 +5587,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5334
5587
  extensionRegistry
5335
5588
  );
5336
5589
  }
5337
- const typeAliasDecl = declarations.find(ts6.isTypeAliasDeclaration);
5590
+ const typeAliasDecl = declarations.find(ts5.isTypeAliasDeclaration);
5338
5591
  const typeAliasMembers = typeAliasDecl === void 0 ? null : getObjectLikeTypeAliasMembers(typeAliasDecl.type);
5339
5592
  if (typeAliasDecl && typeAliasMembers !== null) {
5340
5593
  return buildFieldNodeInfoMap(
@@ -5358,10 +5611,10 @@ function extractArrayElementTypeNode(sourceNode, checker) {
5358
5611
  return void 0;
5359
5612
  }
5360
5613
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
5361
- if (ts6.isArrayTypeNode(resolvedTypeNode)) {
5614
+ if (ts5.isArrayTypeNode(resolvedTypeNode)) {
5362
5615
  return resolvedTypeNode.elementType;
5363
5616
  }
5364
- if (ts6.isTypeReferenceNode(resolvedTypeNode) && ts6.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
5617
+ if (ts5.isTypeReferenceNode(resolvedTypeNode) && ts5.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
5365
5618
  return resolvedTypeNode.typeArguments[0];
5366
5619
  }
5367
5620
  return void 0;
@@ -5372,13 +5625,13 @@ function extractUnionMemberTypeNodes(sourceNode, checker) {
5372
5625
  return [];
5373
5626
  }
5374
5627
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
5375
- return ts6.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
5628
+ return ts5.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
5376
5629
  }
5377
5630
  function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new Set()) {
5378
- if (ts6.isParenthesizedTypeNode(typeNode)) {
5631
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
5379
5632
  return resolveAliasedTypeNode(typeNode.type, checker, visited);
5380
5633
  }
5381
- if (!ts6.isTypeReferenceNode(typeNode) || !ts6.isIdentifier(typeNode.typeName)) {
5634
+ if (!ts5.isTypeReferenceNode(typeNode) || !ts5.isIdentifier(typeNode.typeName)) {
5382
5635
  return typeNode;
5383
5636
  }
5384
5637
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -5389,15 +5642,15 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
5389
5642
  return resolveAliasedTypeNode(aliasDecl.type, checker, visited);
5390
5643
  }
5391
5644
  function isNullishTypeNode(typeNode) {
5392
- if (typeNode.kind === ts6.SyntaxKind.NullKeyword || typeNode.kind === ts6.SyntaxKind.UndefinedKeyword) {
5645
+ if (typeNode.kind === ts5.SyntaxKind.NullKeyword || typeNode.kind === ts5.SyntaxKind.UndefinedKeyword) {
5393
5646
  return true;
5394
5647
  }
5395
- return ts6.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts6.SyntaxKind.NullKeyword || typeNode.literal.kind === ts6.SyntaxKind.UndefinedKeyword);
5648
+ return ts5.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts5.SyntaxKind.NullKeyword || typeNode.literal.kind === ts5.SyntaxKind.UndefinedKeyword);
5396
5649
  }
5397
5650
  function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, metadataPolicy, hostType, diagnostics, extensionRegistry) {
5398
5651
  const map = /* @__PURE__ */ new Map();
5399
5652
  for (const member of members) {
5400
- if (ts6.isPropertySignature(member)) {
5653
+ if (ts5.isPropertySignature(member)) {
5401
5654
  const fieldNode = analyzeInterfacePropertyToIR(
5402
5655
  member,
5403
5656
  checker,
@@ -5422,7 +5675,7 @@ function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, m
5422
5675
  return map;
5423
5676
  }
5424
5677
  function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegistry, depth = 0) {
5425
- if (!ts6.isTypeReferenceNode(typeNode)) return [];
5678
+ if (!ts5.isTypeReferenceNode(typeNode)) return [];
5426
5679
  if (depth >= MAX_ALIAS_CHAIN_DEPTH) {
5427
5680
  const aliasName = typeNode.typeName.getText();
5428
5681
  throw new Error(
@@ -5431,7 +5684,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
5431
5684
  }
5432
5685
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
5433
5686
  if (!aliasDecl) return [];
5434
- if (ts6.isTypeLiteralNode(aliasDecl.type)) return [];
5687
+ if (ts5.isTypeLiteralNode(aliasDecl.type)) return [];
5435
5688
  const aliasFieldType = resolveTypeNode(
5436
5689
  checker.getTypeAtLocation(aliasDecl.type),
5437
5690
  checker,
@@ -5475,14 +5728,14 @@ function getNamedTypeName(type) {
5475
5728
  const symbol = type.getSymbol();
5476
5729
  if (symbol?.declarations) {
5477
5730
  const decl = symbol.declarations[0];
5478
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
5479
- const name = ts6.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
5731
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
5732
+ const name = ts5.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
5480
5733
  if (name) return name;
5481
5734
  }
5482
5735
  }
5483
5736
  const aliasSymbol = type.aliasSymbol;
5484
5737
  if (aliasSymbol?.declarations) {
5485
- const aliasDecl = aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
5738
+ const aliasDecl = aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
5486
5739
  if (aliasDecl) {
5487
5740
  return aliasDecl.name.text;
5488
5741
  }
@@ -5493,24 +5746,24 @@ function getNamedTypeDeclaration(type) {
5493
5746
  const symbol = type.getSymbol();
5494
5747
  if (symbol?.declarations) {
5495
5748
  const decl = symbol.declarations[0];
5496
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
5749
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
5497
5750
  return decl;
5498
5751
  }
5499
5752
  }
5500
5753
  const aliasSymbol = type.aliasSymbol;
5501
5754
  if (aliasSymbol?.declarations) {
5502
- return aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
5755
+ return aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
5503
5756
  }
5504
5757
  return void 0;
5505
5758
  }
5506
5759
  function analyzeMethod(method, checker) {
5507
- if (!ts6.isIdentifier(method.name)) {
5760
+ if (!ts5.isIdentifier(method.name)) {
5508
5761
  return null;
5509
5762
  }
5510
5763
  const name = method.name.text;
5511
5764
  const parameters = [];
5512
5765
  for (const param of method.parameters) {
5513
- if (ts6.isIdentifier(param.name)) {
5766
+ if (ts5.isIdentifier(param.name)) {
5514
5767
  const paramInfo = analyzeParameter(param, checker);
5515
5768
  parameters.push(paramInfo);
5516
5769
  }
@@ -5521,7 +5774,7 @@ function analyzeMethod(method, checker) {
5521
5774
  return { name, parameters, returnTypeNode, returnType };
5522
5775
  }
5523
5776
  function analyzeParameter(param, checker) {
5524
- const name = ts6.isIdentifier(param.name) ? param.name.text : "param";
5777
+ const name = ts5.isIdentifier(param.name) ? param.name.text : "param";
5525
5778
  const typeNode = param.type;
5526
5779
  const type = checker.getTypeAtLocation(param);
5527
5780
  const formSpecExportName = detectFormSpecReference(typeNode);
@@ -5530,20 +5783,20 @@ function analyzeParameter(param, checker) {
5530
5783
  }
5531
5784
  function detectFormSpecReference(typeNode) {
5532
5785
  if (!typeNode) return null;
5533
- if (!ts6.isTypeReferenceNode(typeNode)) return null;
5534
- const typeName = ts6.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts6.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
5786
+ if (!ts5.isTypeReferenceNode(typeNode)) return null;
5787
+ const typeName = ts5.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts5.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
5535
5788
  if (typeName !== "InferSchema" && typeName !== "InferFormSchema") return null;
5536
5789
  const typeArg = typeNode.typeArguments?.[0];
5537
- if (!typeArg || !ts6.isTypeQueryNode(typeArg)) return null;
5538
- if (ts6.isIdentifier(typeArg.exprName)) {
5790
+ if (!typeArg || !ts5.isTypeQueryNode(typeArg)) return null;
5791
+ if (ts5.isIdentifier(typeArg.exprName)) {
5539
5792
  return typeArg.exprName.text;
5540
5793
  }
5541
- if (ts6.isQualifiedName(typeArg.exprName)) {
5794
+ if (ts5.isQualifiedName(typeArg.exprName)) {
5542
5795
  return typeArg.exprName.right.text;
5543
5796
  }
5544
5797
  return null;
5545
5798
  }
5546
- var RESOLVING_TYPE_PLACEHOLDER, MAX_ALIAS_CHAIN_DEPTH;
5799
+ var RESOLVING_TYPE_PLACEHOLDER, DEDUPLICATABLE_DIAGNOSTIC_CODES, INHERITABLE_TYPE_ANNOTATION_KINDS, MAX_ALIAS_CHAIN_DEPTH;
5547
5800
  var init_class_analyzer = __esm({
5548
5801
  "src/analyzer/class-analyzer.ts"() {
5549
5802
  "use strict";
@@ -5558,12 +5811,17 @@ var init_class_analyzer = __esm({
5558
5811
  properties: [],
5559
5812
  additionalProperties: true
5560
5813
  };
5814
+ DEDUPLICATABLE_DIAGNOSTIC_CODES = /* @__PURE__ */ new Set([
5815
+ "SYNTHETIC_SETUP_FAILURE",
5816
+ "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE"
5817
+ ]);
5818
+ INHERITABLE_TYPE_ANNOTATION_KINDS = /* @__PURE__ */ new Set(["format"]);
5561
5819
  MAX_ALIAS_CHAIN_DEPTH = 8;
5562
5820
  }
5563
5821
  });
5564
5822
 
5565
5823
  // src/analyzer/program.ts
5566
- import * as ts7 from "typescript";
5824
+ import * as ts6 from "typescript";
5567
5825
  import * as path from "path";
5568
5826
  function createProgramContextFromProgram(program, filePath) {
5569
5827
  const absolutePath = path.resolve(filePath);
@@ -5580,23 +5838,23 @@ function createProgramContextFromProgram(program, filePath) {
5580
5838
  function createProgramContext(filePath, additionalFiles) {
5581
5839
  const absolutePath = path.resolve(filePath);
5582
5840
  const fileDir = path.dirname(absolutePath);
5583
- const configPath = ts7.findConfigFile(fileDir, ts7.sys.fileExists.bind(ts7.sys), "tsconfig.json");
5841
+ const configPath = ts6.findConfigFile(fileDir, ts6.sys.fileExists.bind(ts6.sys), "tsconfig.json");
5584
5842
  let compilerOptions;
5585
5843
  let fileNames;
5586
5844
  if (configPath) {
5587
- const configFile = ts7.readConfigFile(configPath, ts7.sys.readFile.bind(ts7.sys));
5845
+ const configFile = ts6.readConfigFile(configPath, ts6.sys.readFile.bind(ts6.sys));
5588
5846
  if (configFile.error) {
5589
5847
  throw new Error(
5590
- `Error reading tsconfig.json: ${ts7.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
5848
+ `Error reading tsconfig.json: ${ts6.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
5591
5849
  );
5592
5850
  }
5593
- const parsed = ts7.parseJsonConfigFileContent(
5851
+ const parsed = ts6.parseJsonConfigFileContent(
5594
5852
  configFile.config,
5595
- ts7.sys,
5853
+ ts6.sys,
5596
5854
  path.dirname(configPath)
5597
5855
  );
5598
5856
  if (parsed.errors.length > 0) {
5599
- const errorMessages = parsed.errors.map((e) => ts7.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
5857
+ const errorMessages = parsed.errors.map((e) => ts6.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
5600
5858
  throw new Error(`Error parsing tsconfig.json: ${errorMessages}`);
5601
5859
  }
5602
5860
  compilerOptions = parsed.options;
@@ -5604,9 +5862,9 @@ function createProgramContext(filePath, additionalFiles) {
5604
5862
  fileNames = [.../* @__PURE__ */ new Set([...parsed.fileNames, absolutePath, ...normalizedAdditional])];
5605
5863
  } else {
5606
5864
  compilerOptions = {
5607
- target: ts7.ScriptTarget.ES2022,
5608
- module: ts7.ModuleKind.NodeNext,
5609
- moduleResolution: ts7.ModuleResolutionKind.NodeNext,
5865
+ target: ts6.ScriptTarget.ES2022,
5866
+ module: ts6.ModuleKind.NodeNext,
5867
+ moduleResolution: ts6.ModuleResolutionKind.NodeNext,
5610
5868
  strict: true,
5611
5869
  skipLibCheck: true,
5612
5870
  declaration: true
@@ -5614,7 +5872,7 @@ function createProgramContext(filePath, additionalFiles) {
5614
5872
  const normalizedAdditional = (additionalFiles ?? []).map((f) => path.resolve(f));
5615
5873
  fileNames = [.../* @__PURE__ */ new Set([absolutePath, ...normalizedAdditional])];
5616
5874
  }
5617
- const program = ts7.createProgram(fileNames, compilerOptions);
5875
+ const program = ts6.createProgram(fileNames, compilerOptions);
5618
5876
  const sourceFile = program.getSourceFile(absolutePath);
5619
5877
  if (!sourceFile) {
5620
5878
  throw new Error(`Could not find source file: ${absolutePath}`);
@@ -5633,19 +5891,19 @@ function findNodeByName(sourceFile, name, predicate, getName) {
5633
5891
  result = node;
5634
5892
  return;
5635
5893
  }
5636
- ts7.forEachChild(node, visit);
5894
+ ts6.forEachChild(node, visit);
5637
5895
  }
5638
5896
  visit(sourceFile);
5639
5897
  return result;
5640
5898
  }
5641
5899
  function findClassByName(sourceFile, className) {
5642
- return findNodeByName(sourceFile, className, ts7.isClassDeclaration, (n) => n.name?.text);
5900
+ return findNodeByName(sourceFile, className, ts6.isClassDeclaration, (n) => n.name?.text);
5643
5901
  }
5644
5902
  function findInterfaceByName(sourceFile, interfaceName) {
5645
- return findNodeByName(sourceFile, interfaceName, ts7.isInterfaceDeclaration, (n) => n.name.text);
5903
+ return findNodeByName(sourceFile, interfaceName, ts6.isInterfaceDeclaration, (n) => n.name.text);
5646
5904
  }
5647
5905
  function findTypeAliasByName(sourceFile, aliasName) {
5648
- return findNodeByName(sourceFile, aliasName, ts7.isTypeAliasDeclaration, (n) => n.name.text);
5906
+ return findNodeByName(sourceFile, aliasName, ts6.isTypeAliasDeclaration, (n) => n.name.text);
5649
5907
  }
5650
5908
  function getResolvedObjectRootType(rootType, typeRegistry) {
5651
5909
  if (rootType.kind === "object") {
@@ -5685,22 +5943,22 @@ function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInf
5685
5943
  };
5686
5944
  }
5687
5945
  function containsTypeReferenceInObjectLikeAlias(typeNode) {
5688
- if (ts7.isParenthesizedTypeNode(typeNode)) {
5946
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
5689
5947
  return containsTypeReferenceInObjectLikeAlias(typeNode.type);
5690
5948
  }
5691
- if (ts7.isTypeReferenceNode(typeNode)) {
5949
+ if (ts6.isTypeReferenceNode(typeNode)) {
5692
5950
  return true;
5693
5951
  }
5694
- return ts7.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5952
+ return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5695
5953
  }
5696
5954
  function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5697
- if (ts7.isParenthesizedTypeNode(typeNode)) {
5955
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
5698
5956
  return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
5699
5957
  }
5700
- if (ts7.isTypeLiteralNode(typeNode)) {
5958
+ if (ts6.isTypeLiteralNode(typeNode)) {
5701
5959
  const propertyNames = [];
5702
5960
  for (const member of typeNode.members) {
5703
- if (!ts7.isPropertySignature(member)) {
5961
+ if (!ts6.isPropertySignature(member)) {
5704
5962
  continue;
5705
5963
  }
5706
5964
  const propertyName = getAnalyzableObjectLikePropertyName(member.name);
@@ -5710,13 +5968,13 @@ function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5710
5968
  }
5711
5969
  return propertyNames;
5712
5970
  }
5713
- if (ts7.isTypeReferenceNode(typeNode)) {
5971
+ if (ts6.isTypeReferenceNode(typeNode)) {
5714
5972
  return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
5715
5973
  }
5716
5974
  return null;
5717
5975
  }
5718
5976
  function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
5719
- if (!ts7.isIntersectionTypeNode(typeNode)) {
5977
+ if (!ts6.isIntersectionTypeNode(typeNode)) {
5720
5978
  return [];
5721
5979
  }
5722
5980
  const seen = /* @__PURE__ */ new Set();
@@ -5923,7 +6181,7 @@ var init_program = __esm({
5923
6181
  });
5924
6182
 
5925
6183
  // src/extensions/symbol-registry.ts
5926
- import * as ts8 from "typescript";
6184
+ import * as ts7 from "typescript";
5927
6185
  import * as path2 from "path";
5928
6186
  function buildSymbolMapFromConfig(configPath, program, checker, extensionRegistry) {
5929
6187
  const symbolMap = /* @__PURE__ */ new Map();
@@ -5933,10 +6191,10 @@ function buildSymbolMapFromConfig(configPath, program, checker, extensionRegistr
5933
6191
  return symbolMap;
5934
6192
  }
5935
6193
  function visit(node) {
5936
- if (ts8.isCallExpression(node) && isDefineCustomTypeCall(node, checker)) {
6194
+ if (ts7.isCallExpression(node) && isDefineCustomTypeCall(node, checker)) {
5937
6195
  processDefineCustomTypeCall(node);
5938
6196
  }
5939
- ts8.forEachChild(node, visit);
6197
+ ts7.forEachChild(node, visit);
5940
6198
  }
5941
6199
  function processDefineCustomTypeCall(call) {
5942
6200
  const typeArgNode = call.typeArguments?.[0];
@@ -5973,7 +6231,7 @@ function isDefineCustomTypeCall(node, checker) {
5973
6231
  if (node.typeArguments === void 0 || node.typeArguments.length === 0) return false;
5974
6232
  const callSymbol = checker.getSymbolAtLocation(node.expression);
5975
6233
  if (callSymbol !== void 0) {
5976
- const resolved = callSymbol.flags & ts8.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
6234
+ const resolved = callSymbol.flags & ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
5977
6235
  const decl = resolved.declarations?.[0];
5978
6236
  if (decl !== void 0) {
5979
6237
  const sourceFile = decl.getSourceFile().fileName.replace(/\\/g, "/");
@@ -5981,24 +6239,24 @@ function isDefineCustomTypeCall(node, checker) {
5981
6239
  (sourceFile.includes("@formspec/core") || sourceFile.includes("/packages/core/"));
5982
6240
  }
5983
6241
  }
5984
- return ts8.isIdentifier(node.expression) && node.expression.text === "defineCustomType";
6242
+ return ts7.isIdentifier(node.expression) && node.expression.text === "defineCustomType";
5985
6243
  }
5986
6244
  function extractTypeNameFromCallArg(call) {
5987
6245
  const arg = call.arguments[0];
5988
- if (arg === void 0 || !ts8.isObjectLiteralExpression(arg)) {
6246
+ if (arg === void 0 || !ts7.isObjectLiteralExpression(arg)) {
5989
6247
  return null;
5990
6248
  }
5991
6249
  const typeNameProp = arg.properties.find(
5992
- (p) => ts8.isPropertyAssignment(p) && ts8.isIdentifier(p.name) && p.name.text === "typeName"
6250
+ (p) => ts7.isPropertyAssignment(p) && ts7.isIdentifier(p.name) && p.name.text === "typeName"
5993
6251
  );
5994
- if (typeNameProp === void 0 || !ts8.isStringLiteral(typeNameProp.initializer)) {
6252
+ if (typeNameProp === void 0 || !ts7.isStringLiteral(typeNameProp.initializer)) {
5995
6253
  return null;
5996
6254
  }
5997
6255
  return typeNameProp.initializer.text;
5998
6256
  }
5999
6257
  function extractEnclosingExtensionId(call, checker) {
6000
- for (let node = call.parent; !ts8.isSourceFile(node); node = node.parent) {
6001
- if (ts8.isCallExpression(node) && isDefineExtensionCall(node, checker)) {
6258
+ for (let node = call.parent; !ts7.isSourceFile(node); node = node.parent) {
6259
+ if (ts7.isCallExpression(node) && isDefineExtensionCall(node, checker)) {
6002
6260
  return extractExtensionIdFromCallArg(node);
6003
6261
  }
6004
6262
  }
@@ -6007,24 +6265,24 @@ function extractEnclosingExtensionId(call, checker) {
6007
6265
  function isDefineExtensionCall(node, checker) {
6008
6266
  const callSymbol = checker.getSymbolAtLocation(node.expression);
6009
6267
  if (callSymbol !== void 0) {
6010
- const resolved = callSymbol.flags & ts8.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
6268
+ const resolved = callSymbol.flags & ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
6011
6269
  const decl = resolved.declarations?.[0];
6012
6270
  if (decl !== void 0) {
6013
6271
  const sourceFile = decl.getSourceFile().fileName.replace(/\\/g, "/");
6014
6272
  return resolved.name === "defineExtension" && (sourceFile.includes("@formspec/core") || sourceFile.includes("/packages/core/"));
6015
6273
  }
6016
6274
  }
6017
- return ts8.isIdentifier(node.expression) && node.expression.text === "defineExtension";
6275
+ return ts7.isIdentifier(node.expression) && node.expression.text === "defineExtension";
6018
6276
  }
6019
6277
  function extractExtensionIdFromCallArg(call) {
6020
6278
  const arg = call.arguments[0];
6021
- if (arg === void 0 || !ts8.isObjectLiteralExpression(arg)) {
6279
+ if (arg === void 0 || !ts7.isObjectLiteralExpression(arg)) {
6022
6280
  return null;
6023
6281
  }
6024
6282
  const prop = arg.properties.find(
6025
- (p) => ts8.isPropertyAssignment(p) && ts8.isIdentifier(p.name) && p.name.text === "extensionId"
6283
+ (p) => ts7.isPropertyAssignment(p) && ts7.isIdentifier(p.name) && p.name.text === "extensionId"
6026
6284
  );
6027
- if (prop === void 0 || !ts8.isStringLiteral(prop.initializer)) {
6285
+ if (prop === void 0 || !ts7.isStringLiteral(prop.initializer)) {
6028
6286
  return null;
6029
6287
  }
6030
6288
  return prop.initializer.text;
@@ -6136,7 +6394,7 @@ var init_validate = __esm({
6136
6394
  });
6137
6395
 
6138
6396
  // src/generators/class-schema.ts
6139
- import * as ts9 from "typescript";
6397
+ import * as ts8 from "typescript";
6140
6398
  function generateClassSchemas(analysis, source, options) {
6141
6399
  const result = generateClassSchemasDetailed(analysis, source, options);
6142
6400
  if (!result.ok || result.jsonSchema === void 0 || result.uiSchema === void 0) {
@@ -6306,7 +6564,7 @@ function generateSchemasBatch(options) {
6306
6564
  return options.targets.map((target) => {
6307
6565
  let ctx;
6308
6566
  try {
6309
- const cacheKey = ts9.sys.useCaseSensitiveFileNames ? target.filePath : target.filePath.toLowerCase();
6567
+ const cacheKey = ts8.sys.useCaseSensitiveFileNames ? target.filePath : target.filePath.toLowerCase();
6310
6568
  const cachedContext = contextCache.get(cacheKey);
6311
6569
  if (cachedContext === void 0) {
6312
6570
  const additionalFiles = options.configPath !== void 0 ? [options.configPath] : void 0;
@@ -6365,7 +6623,7 @@ function isMutableRegistry(reg) {
6365
6623
  }
6366
6624
  function resolveStaticOptions(options) {
6367
6625
  const legacyRegistry = options.extensionRegistry;
6368
- const configRegistry = legacyRegistry === void 0 && options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6626
+ const configRegistry = legacyRegistry === void 0 && options.config?.extensions !== void 0 && options.config.extensions.length > 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6369
6627
  return {
6370
6628
  extensionRegistry: legacyRegistry ?? configRegistry,
6371
6629
  // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
@@ -6377,7 +6635,7 @@ function resolveStaticOptions(options) {
6377
6635
  };
6378
6636
  }
6379
6637
  function resolveOptions(options) {
6380
- const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6638
+ const configRegistry = options.config?.extensions !== void 0 && options.config.extensions.length > 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6381
6639
  const legacyRegistry = options.extensionRegistry;
6382
6640
  return {
6383
6641
  // When the caller provides the deprecated extensionRegistry field directly,
@@ -6475,7 +6733,7 @@ var init_class_schema = __esm({
6475
6733
  });
6476
6734
 
6477
6735
  // src/static-build.ts
6478
- import * as ts10 from "typescript";
6736
+ import * as ts9 from "typescript";
6479
6737
  function toStaticBuildContext(context) {
6480
6738
  return context;
6481
6739
  }
@@ -6490,7 +6748,7 @@ function getModuleSymbol(context) {
6490
6748
  return context.checker.getSymbolAtLocation(context.sourceFile) ?? sourceFileWithSymbol.symbol;
6491
6749
  }
6492
6750
  function isSchemaSourceDeclaration(declaration) {
6493
- return ts10.isClassDeclaration(declaration) || ts10.isInterfaceDeclaration(declaration) || ts10.isTypeAliasDeclaration(declaration);
6751
+ return ts9.isClassDeclaration(declaration) || ts9.isInterfaceDeclaration(declaration) || ts9.isTypeAliasDeclaration(declaration);
6494
6752
  }
6495
6753
  function resolveModuleExport(context, exportName = "default") {
6496
6754
  const moduleSymbol = getModuleSymbol(context);
@@ -6501,7 +6759,7 @@ function resolveModuleExport(context, exportName = "default") {
6501
6759
  if (exportSymbol === null) {
6502
6760
  return null;
6503
6761
  }
6504
- return exportSymbol.flags & ts10.SymbolFlags.Alias ? context.checker.getAliasedSymbol(exportSymbol) : exportSymbol;
6762
+ return exportSymbol.flags & ts9.SymbolFlags.Alias ? context.checker.getAliasedSymbol(exportSymbol) : exportSymbol;
6505
6763
  }
6506
6764
  function resolveModuleExportDeclaration(context, exportName = "default") {
6507
6765
  return resolveModuleExport(context, exportName)?.declarations?.find(isSchemaSourceDeclaration) ?? null;
@@ -6514,7 +6772,7 @@ var init_static_build = __esm({
6514
6772
  });
6515
6773
 
6516
6774
  // src/generators/discovered-schema.ts
6517
- import * as ts11 from "typescript";
6775
+ import * as ts10 from "typescript";
6518
6776
  import { analyzeMetadataForNodeWithChecker as analyzeMetadataForNodeWithChecker2 } from "@formspec/analysis/internal";
6519
6777
  import { IR_VERSION as IR_VERSION3 } from "@formspec/core/internals";
6520
6778
  function toDiscoveredTypeSchemas(result, resolvedMetadata) {
@@ -6524,17 +6782,17 @@ function toDiscoveredTypeSchemas(result, resolvedMetadata) {
6524
6782
  };
6525
6783
  }
6526
6784
  function isNamedTypeDeclaration(declaration) {
6527
- return ts11.isClassDeclaration(declaration) || ts11.isInterfaceDeclaration(declaration) || ts11.isTypeAliasDeclaration(declaration);
6785
+ return ts10.isClassDeclaration(declaration) || ts10.isInterfaceDeclaration(declaration) || ts10.isTypeAliasDeclaration(declaration);
6528
6786
  }
6529
6787
  function hasConcreteTypeArguments(type, checker) {
6530
6788
  if ("aliasTypeArguments" in type && Array.isArray(type.aliasTypeArguments) && type.aliasTypeArguments.length > 0) {
6531
6789
  return true;
6532
6790
  }
6533
- if ((type.flags & ts11.TypeFlags.Object) === 0) {
6791
+ if ((type.flags & ts10.TypeFlags.Object) === 0) {
6534
6792
  return false;
6535
6793
  }
6536
6794
  const objectType = type;
6537
- if ((objectType.objectFlags & ts11.ObjectFlags.Reference) === 0) {
6795
+ if ((objectType.objectFlags & ts10.ObjectFlags.Reference) === 0) {
6538
6796
  return false;
6539
6797
  }
6540
6798
  return checker.getTypeArguments(objectType).length > 0;
@@ -6547,13 +6805,13 @@ function getNamedTypeDeclaration2(type) {
6547
6805
  return declaration;
6548
6806
  }
6549
6807
  }
6550
- const aliasDeclaration = type.aliasSymbol?.declarations?.find(ts11.isTypeAliasDeclaration);
6808
+ const aliasDeclaration = type.aliasSymbol?.declarations?.find(ts10.isTypeAliasDeclaration);
6551
6809
  return aliasDeclaration;
6552
6810
  }
6553
6811
  function getFallbackName(sourceNode, fallback = "AnonymousType") {
6554
6812
  if (sourceNode !== void 0 && "name" in sourceNode) {
6555
6813
  const namedNode = sourceNode;
6556
- if (namedNode.name !== void 0 && ts11.isIdentifier(namedNode.name)) {
6814
+ if (namedNode.name !== void 0 && ts10.isIdentifier(namedNode.name)) {
6557
6815
  return namedNode.name.text;
6558
6816
  }
6559
6817
  }
@@ -6775,7 +7033,7 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
6775
7033
  function generateSchemasFromDeclaration(options) {
6776
7034
  const filePath = options.declaration.getSourceFile().fileName;
6777
7035
  const resolved = resolveStaticOptions(options);
6778
- if (ts11.isClassDeclaration(options.declaration)) {
7036
+ if (ts10.isClassDeclaration(options.declaration)) {
6779
7037
  return generateSchemasFromAnalysis(
6780
7038
  analyzeClassToIR(
6781
7039
  options.declaration,
@@ -6789,7 +7047,7 @@ function generateSchemasFromDeclaration(options) {
6789
7047
  resolved
6790
7048
  );
6791
7049
  }
6792
- if (ts11.isInterfaceDeclaration(options.declaration)) {
7050
+ if (ts10.isInterfaceDeclaration(options.declaration)) {
6793
7051
  return generateSchemasFromAnalysis(
6794
7052
  analyzeInterfaceToIR(
6795
7053
  options.declaration,
@@ -6803,7 +7061,7 @@ function generateSchemasFromDeclaration(options) {
6803
7061
  resolved
6804
7062
  );
6805
7063
  }
6806
- if (ts11.isTypeAliasDeclaration(options.declaration)) {
7064
+ if (ts10.isTypeAliasDeclaration(options.declaration)) {
6807
7065
  const analyzedAlias = analyzeTypeAliasToIR(
6808
7066
  options.declaration,
6809
7067
  options.context.checker,
@@ -6862,7 +7120,7 @@ function generateSchemasFromReturnType(options) {
6862
7120
  const returnType = signature !== void 0 ? options.context.checker.getReturnTypeOfSignature(signature) : options.context.checker.getTypeAtLocation(options.declaration);
6863
7121
  const type = unwrapPromiseType(options.context.checker, returnType);
6864
7122
  const sourceNode = type !== returnType ? unwrapPromiseTypeNode(options.declaration.type) ?? options.declaration.type ?? options.declaration : options.declaration.type ?? options.declaration;
6865
- const fallbackName = options.declaration.name !== void 0 && ts11.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
7123
+ const fallbackName = options.declaration.name !== void 0 && ts10.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
6866
7124
  return generateSchemasFromResolvedType({
6867
7125
  ...options,
6868
7126
  type,
@@ -6909,14 +7167,14 @@ function unwrapPromiseTypeNode(typeNode) {
6909
7167
  if (typeNode === void 0) {
6910
7168
  return void 0;
6911
7169
  }
6912
- if (ts11.isParenthesizedTypeNode(typeNode)) {
7170
+ if (ts10.isParenthesizedTypeNode(typeNode)) {
6913
7171
  const unwrapped = unwrapPromiseTypeNode(typeNode.type);
6914
7172
  return unwrapped ?? typeNode;
6915
7173
  }
6916
7174
  return isPromiseTypeReferenceNode(typeNode) ? typeNode.typeArguments[0] : typeNode;
6917
7175
  }
6918
7176
  function isPromiseTypeReferenceNode(typeNode) {
6919
- return ts11.isTypeReferenceNode(typeNode) && ts11.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
7177
+ return ts10.isTypeReferenceNode(typeNode) && ts10.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
6920
7178
  }
6921
7179
  var init_discovered_schema = __esm({
6922
7180
  "src/generators/discovered-schema.ts"() {