@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.cjs CHANGED
@@ -1070,7 +1070,7 @@ function generateJsonSchemaFromIR(ir, options) {
1070
1070
  applyConstraints(ctx.defs[schemaName], typeDef.constraints, ctx);
1071
1071
  }
1072
1072
  if (typeDef.annotations && typeDef.annotations.length > 0) {
1073
- applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx);
1073
+ applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx, typeDef.type);
1074
1074
  }
1075
1075
  }
1076
1076
  const properties = {};
@@ -1143,7 +1143,7 @@ function generateFieldSchema(field, ctx) {
1143
1143
  }
1144
1144
  }
1145
1145
  applyResolvedMetadata(schema, field.metadata);
1146
- applyAnnotations(schema, rootAnnotations, ctx);
1146
+ applyAnnotations(schema, rootAnnotations, ctx, field.type);
1147
1147
  if (itemStringSchema !== void 0) {
1148
1148
  applyAnnotations(itemStringSchema, itemAnnotations, ctx);
1149
1149
  }
@@ -1186,32 +1186,36 @@ function applyPathTargetedConstraints(schema, pathConstraints, ctx, typeNode) {
1186
1186
  return schema;
1187
1187
  }
1188
1188
  if (schema.$ref) {
1189
- const { $ref, ...rest } = schema;
1190
- const refPart = { $ref };
1191
- const overridePart = {
1192
- properties: propertyOverrides,
1193
- ...rest
1189
+ return {
1190
+ ...schema,
1191
+ properties: propertyOverrides
1194
1192
  };
1195
- return { allOf: [refPart, overridePart] };
1196
1193
  }
1197
1194
  if (schema.type === "object" && schema.properties) {
1198
- const missingOverrides = {};
1199
1195
  for (const [target, overrideSchema] of Object.entries(propertyOverrides)) {
1200
- if (schema.properties[target]) {
1201
- mergeSchemaOverride(schema.properties[target], overrideSchema);
1202
- } else {
1203
- missingOverrides[target] = overrideSchema;
1196
+ if (Object.hasOwn(schema.properties, target)) {
1197
+ const existing = schema.properties[target];
1198
+ if (existing) {
1199
+ mergeSchemaOverride(existing, overrideSchema);
1200
+ continue;
1201
+ }
1204
1202
  }
1203
+ Object.defineProperty(schema.properties, target, {
1204
+ value: overrideSchema,
1205
+ writable: true,
1206
+ enumerable: true,
1207
+ configurable: true
1208
+ });
1205
1209
  }
1206
- if (Object.keys(missingOverrides).length === 0) {
1207
- return schema;
1208
- }
1209
- return {
1210
- allOf: [schema, { properties: missingOverrides }]
1211
- };
1210
+ return schema;
1212
1211
  }
1213
1212
  if (schema.allOf) {
1214
- schema.allOf = [...schema.allOf, { properties: propertyOverrides }];
1213
+ const overrideMember = { properties: propertyOverrides };
1214
+ const flattened = tryFlattenAllOfToSiblings(schema, overrideMember);
1215
+ if (flattened !== void 0) {
1216
+ return flattened;
1217
+ }
1218
+ schema.allOf = [...schema.allOf, overrideMember];
1215
1219
  return schema;
1216
1220
  }
1217
1221
  return schema;
@@ -1324,7 +1328,7 @@ function generatePropertySchema(prop, ctx) {
1324
1328
  const schema = generateTypeNode(prop.type, ctx);
1325
1329
  applyConstraints(schema, prop.constraints, ctx);
1326
1330
  applyResolvedMetadata(schema, prop.metadata);
1327
- applyAnnotations(schema, prop.annotations, ctx);
1331
+ applyAnnotations(schema, prop.annotations, ctx, prop.type);
1328
1332
  return schema;
1329
1333
  }
1330
1334
  function generateUnionType(type, ctx) {
@@ -1427,13 +1431,20 @@ function buildPropertyOverrides(pathConstraints, typeNode, ctx) {
1427
1431
  grouped.push(constraint);
1428
1432
  byTarget.set(target, grouped);
1429
1433
  }
1430
- const overrides = {};
1434
+ const overrides = /* @__PURE__ */ Object.create(null);
1431
1435
  for (const [target, constraints] of byTarget) {
1432
- overrides[resolveSerializedPropertyName(target, typeNode, ctx)] = buildPathOverrideSchema(
1436
+ const resolvedName = resolveSerializedPropertyName(target, typeNode, ctx);
1437
+ const schema = buildPathOverrideSchema(
1433
1438
  constraints.map(stripLeadingPathSegment),
1434
1439
  resolveTargetTypeNode(target, typeNode, ctx),
1435
1440
  ctx
1436
1441
  );
1442
+ Object.defineProperty(overrides, resolvedName, {
1443
+ value: schema,
1444
+ writable: true,
1445
+ enumerable: true,
1446
+ configurable: true
1447
+ });
1437
1448
  }
1438
1449
  return overrides;
1439
1450
  }
@@ -1460,6 +1471,34 @@ function buildPathOverrideSchema(constraints, typeNode, ctx) {
1460
1471
  schema.properties = buildPropertyOverrides(nestedConstraints, effectiveType, ctx);
1461
1472
  return schema;
1462
1473
  }
1474
+ function tryFlattenAllOfToSiblings(schema, overrideMember) {
1475
+ if (schema.allOf?.length !== 1) {
1476
+ return void 0;
1477
+ }
1478
+ const [soleMember] = schema.allOf;
1479
+ if (soleMember === void 0) {
1480
+ return void 0;
1481
+ }
1482
+ const { allOf: _allOf, ...outerRest } = schema;
1483
+ const outerKeys = new Set(Object.keys(outerRest));
1484
+ const memberKeys = new Set(Object.keys(soleMember));
1485
+ const overrideKeys = new Set(Object.keys(overrideMember));
1486
+ for (const key of memberKeys) {
1487
+ if (outerKeys.has(key) || overrideKeys.has(key)) {
1488
+ return void 0;
1489
+ }
1490
+ }
1491
+ for (const key of overrideKeys) {
1492
+ if (outerKeys.has(key)) {
1493
+ return void 0;
1494
+ }
1495
+ }
1496
+ return {
1497
+ ...outerRest,
1498
+ ...soleMember,
1499
+ ...overrideMember
1500
+ };
1501
+ }
1463
1502
  function mergeSchemaOverride(target, override) {
1464
1503
  const nullableValueBranch = getNullableUnionValueSchema(target);
1465
1504
  if (nullableValueBranch !== void 0) {
@@ -1467,11 +1506,16 @@ function mergeSchemaOverride(target, override) {
1467
1506
  return;
1468
1507
  }
1469
1508
  if (override.properties !== void 0) {
1470
- const mergedProperties = target.properties ?? {};
1509
+ const mergedProperties = target.properties ?? /* @__PURE__ */ Object.create(null);
1471
1510
  for (const [name, propertyOverride] of Object.entries(override.properties)) {
1472
- const existing = mergedProperties[name];
1511
+ const existing = Object.hasOwn(mergedProperties, name) ? mergedProperties[name] : void 0;
1473
1512
  if (existing === void 0) {
1474
- mergedProperties[name] = propertyOverride;
1513
+ Object.defineProperty(mergedProperties, name, {
1514
+ value: propertyOverride,
1515
+ writable: true,
1516
+ enumerable: true,
1517
+ configurable: true
1518
+ });
1475
1519
  } else {
1476
1520
  mergeSchemaOverride(existing, propertyOverride);
1477
1521
  }
@@ -1489,7 +1533,12 @@ function mergeSchemaOverride(target, override) {
1489
1533
  if (key === "properties" || key === "items") {
1490
1534
  continue;
1491
1535
  }
1492
- target[key] = value;
1536
+ Object.defineProperty(target, key, {
1537
+ value,
1538
+ writable: true,
1539
+ enumerable: true,
1540
+ configurable: true
1541
+ });
1493
1542
  }
1494
1543
  }
1495
1544
  function stripLeadingPathSegment(constraint) {
@@ -1589,7 +1638,7 @@ function applyConstraints(schema, constraints, ctx) {
1589
1638
  }
1590
1639
  }
1591
1640
  }
1592
- function applyAnnotations(schema, annotations, ctx) {
1641
+ function applyAnnotations(schema, annotations, ctx, typeNode) {
1593
1642
  for (const annotation of annotations) {
1594
1643
  switch (annotation.annotationKind) {
1595
1644
  case "displayName":
@@ -1602,7 +1651,7 @@ function applyAnnotations(schema, annotations, ctx) {
1602
1651
  schema[`${ctx.vendorPrefix}-remarks`] = annotation.value;
1603
1652
  break;
1604
1653
  case "defaultValue":
1605
- schema.default = annotation.value;
1654
+ schema.default = coerceDefaultValue(annotation.value, typeNode, schema, ctx);
1606
1655
  break;
1607
1656
  case "format":
1608
1657
  schema.format = annotation.value;
@@ -1627,6 +1676,34 @@ function applyAnnotations(schema, annotations, ctx) {
1627
1676
  }
1628
1677
  }
1629
1678
  }
1679
+ function coerceDefaultValue(value, typeNode, emittedSchema, ctx) {
1680
+ if (typeNode?.kind !== "custom") {
1681
+ return value;
1682
+ }
1683
+ const registration = ctx.extensionRegistry?.findType(typeNode.typeId);
1684
+ if (registration === void 0) {
1685
+ return value;
1686
+ }
1687
+ if (registration.serializeDefault !== void 0) {
1688
+ return registration.serializeDefault(value, typeNode.payload);
1689
+ }
1690
+ const declaredType = emittedSchema["type"];
1691
+ if (declaredType === "string" && typeof value !== "string") {
1692
+ if (typeof value === "number") {
1693
+ if (!Number.isFinite(value)) {
1694
+ return value;
1695
+ }
1696
+ return String(value);
1697
+ }
1698
+ if (typeof value === "boolean") {
1699
+ return String(value);
1700
+ }
1701
+ if (typeof value === "bigint") {
1702
+ return value.toString();
1703
+ }
1704
+ }
1705
+ return value;
1706
+ }
1630
1707
  function generateCustomType(type, ctx) {
1631
1708
  const registration = ctx.extensionRegistry?.findType(type.typeId);
1632
1709
  if (registration === void 0) {
@@ -2087,6 +2164,16 @@ function buildConstraintTagSources(extensions) {
2087
2164
  constraintTags: extension.constraintTags.map((tag) => ({
2088
2165
  tagName: (0, import_internal.normalizeFormSpecTagName)(tag.tagName)
2089
2166
  }))
2167
+ } : {},
2168
+ // Include customTypes so _validateExtensionSetup can check tsTypeNames for
2169
+ // unsupported built-in overrides and invalid identifier patterns.
2170
+ ...extension.types !== void 0 ? {
2171
+ customTypes: extension.types.map((type) => ({
2172
+ // tsTypeNames: deprecated in favour of symbol-based detection, but
2173
+ // still required for name-based validation in _validateExtensionSetup
2174
+ // until the bridge is fully retired (see §synthetic-checker-retirement §4C).
2175
+ tsTypeNames: type.tsTypeNames ?? [type.typeName]
2176
+ }))
2090
2177
  } : {}
2091
2178
  }));
2092
2179
  }
@@ -2096,7 +2183,13 @@ function createExtensionRegistry(extensions) {
2096
2183
  extensionCount: extensions.length,
2097
2184
  extensionIds: extensions.map((e) => e.extensionId)
2098
2185
  });
2099
- const reservedTagSources = buildConstraintTagSources(extensions);
2186
+ const extensionTagSources = buildConstraintTagSources(extensions);
2187
+ const setupDiagnostics = (0, import_internal._validateExtensionSetup)(extensionTagSources);
2188
+ (0, import_internal.logSetupDiagnostics)(registryLog, {
2189
+ diagnosticCount: setupDiagnostics.length,
2190
+ codes: setupDiagnostics.map((d) => d.kind)
2191
+ });
2192
+ const reservedTagSources = extensionTagSources;
2100
2193
  let symbolMap = /* @__PURE__ */ new Map();
2101
2194
  const typeMap = /* @__PURE__ */ new Map();
2102
2195
  const typeNameMap = /* @__PURE__ */ new Map();
@@ -2233,10 +2326,12 @@ function createExtensionRegistry(extensions) {
2233
2326
  constraintTagCount: constraintTagMap.size,
2234
2327
  broadeningCount: builtinBroadeningMap.size,
2235
2328
  annotationCount: annotationMap.size,
2236
- metadataSlotCount: metadataSlotMap.size
2329
+ metadataSlotCount: metadataSlotMap.size,
2330
+ setupDiagnosticCount: setupDiagnostics.length
2237
2331
  });
2238
2332
  return {
2239
2333
  extensions,
2334
+ setupDiagnostics,
2240
2335
  findType: (typeId) => typeMap.get(typeId),
2241
2336
  findTypeByName: (typeName) => typeNameMap.get(typeName),
2242
2337
  findTypeByBrand: (brand) => brandMap.get(brand),
@@ -2337,21 +2432,6 @@ var init_schema2 = __esm({
2337
2432
  });
2338
2433
 
2339
2434
  // src/extensions/ts-type-utils.ts
2340
- function collectBrandIdentifiers(type) {
2341
- if (!type.isIntersection()) {
2342
- return [];
2343
- }
2344
- const brands = [];
2345
- for (const prop of type.getProperties()) {
2346
- const decl = prop.valueDeclaration ?? prop.declarations?.[0];
2347
- if (decl === void 0) continue;
2348
- if (!ts.isPropertySignature(decl) && !ts.isPropertyDeclaration(decl)) continue;
2349
- if (!ts.isComputedPropertyName(decl.name)) continue;
2350
- if (!ts.isIdentifier(decl.name.expression)) continue;
2351
- brands.push(decl.name.expression.text);
2352
- }
2353
- return brands;
2354
- }
2355
2435
  function resolveCanonicalSymbol(type, checker) {
2356
2436
  const raw = type.aliasSymbol ?? type.getSymbol();
2357
2437
  if (raw === void 0) return void 0;
@@ -2443,7 +2523,7 @@ function resolveCustomTypeFromTsType(type, checker, registry, sourceNode) {
2443
2523
  return bySymbol;
2444
2524
  }
2445
2525
  }
2446
- for (const brand of collectBrandIdentifiers(stripped)) {
2526
+ for (const brand of (0, import_internal2._collectBrandIdentifiers)(stripped)) {
2447
2527
  const byBrand = registry.findTypeByBrand(brand);
2448
2528
  if (byBrand !== void 0) {
2449
2529
  return byBrand;
@@ -2465,17 +2545,11 @@ var init_resolve_custom_type = __esm({
2465
2545
  });
2466
2546
 
2467
2547
  // src/analyzer/builtin-brands.ts
2468
- function isIntegerBrandedType(type) {
2469
- if (!type.isIntersection()) return false;
2470
- if (!type.types.some((member) => !!(member.flags & ts3.TypeFlags.Number))) return false;
2471
- return collectBrandIdentifiers(type).includes("__integerBrand");
2472
- }
2473
- var ts3;
2548
+ var import_internal3;
2474
2549
  var init_builtin_brands = __esm({
2475
2550
  "src/analyzer/builtin-brands.ts"() {
2476
2551
  "use strict";
2477
- ts3 = __toESM(require("typescript"), 1);
2478
- init_ts_type_utils();
2552
+ import_internal3 = require("@formspec/analysis/internal");
2479
2553
  }
2480
2554
  });
2481
2555
 
@@ -2499,23 +2573,23 @@ function getExtensionTypeNames(registry) {
2499
2573
  function collectImportedNames(sourceFile) {
2500
2574
  const importedNames = /* @__PURE__ */ new Set();
2501
2575
  for (const statement of sourceFile.statements) {
2502
- if (ts4.isImportDeclaration(statement) && statement.importClause !== void 0) {
2576
+ if (ts3.isImportDeclaration(statement) && statement.importClause !== void 0) {
2503
2577
  const clause = statement.importClause;
2504
2578
  if (clause.name !== void 0) {
2505
2579
  importedNames.add(clause.name.text);
2506
2580
  }
2507
2581
  if (clause.namedBindings !== void 0) {
2508
- if (ts4.isNamedImports(clause.namedBindings)) {
2582
+ if (ts3.isNamedImports(clause.namedBindings)) {
2509
2583
  for (const specifier of clause.namedBindings.elements) {
2510
2584
  importedNames.add(specifier.name.text);
2511
2585
  }
2512
- } else if (ts4.isNamespaceImport(clause.namedBindings)) {
2586
+ } else if (ts3.isNamespaceImport(clause.namedBindings)) {
2513
2587
  importedNames.add(clause.namedBindings.name.text);
2514
2588
  }
2515
2589
  }
2516
2590
  continue;
2517
2591
  }
2518
- if (ts4.isImportEqualsDeclaration(statement)) {
2592
+ if (ts3.isImportEqualsDeclaration(statement)) {
2519
2593
  importedNames.add(statement.name.text);
2520
2594
  }
2521
2595
  }
@@ -2523,13 +2597,13 @@ function collectImportedNames(sourceFile) {
2523
2597
  }
2524
2598
  function isNonReferenceIdentifier(node) {
2525
2599
  const parent = node.parent;
2526
- 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) {
2600
+ 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) {
2527
2601
  return true;
2528
2602
  }
2529
- if ((ts4.isPropertyAssignment(parent) || ts4.isPropertyAccessExpression(parent)) && parent.name === node) {
2603
+ if ((ts3.isPropertyAssignment(parent) || ts3.isPropertyAccessExpression(parent)) && parent.name === node) {
2530
2604
  return true;
2531
2605
  }
2532
- if (ts4.isQualifiedName(parent) && parent.right === node) {
2606
+ if (ts3.isQualifiedName(parent) && parent.right === node) {
2533
2607
  return true;
2534
2608
  }
2535
2609
  return false;
@@ -2541,20 +2615,20 @@ function astReferencesImportedName(root, importedNames) {
2541
2615
  let found = false;
2542
2616
  const visit = (node) => {
2543
2617
  if (found) return;
2544
- if (ts4.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
2618
+ if (ts3.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
2545
2619
  found = true;
2546
2620
  return;
2547
2621
  }
2548
- ts4.forEachChild(node, visit);
2622
+ ts3.forEachChild(node, visit);
2549
2623
  };
2550
2624
  visit(root);
2551
2625
  return found;
2552
2626
  }
2553
2627
  function getObjectMembers(statement) {
2554
- if (ts4.isInterfaceDeclaration(statement)) {
2628
+ if (ts3.isInterfaceDeclaration(statement)) {
2555
2629
  return statement.members;
2556
2630
  }
2557
- if (ts4.isTypeLiteralNode(statement.type)) {
2631
+ if (ts3.isTypeLiteralNode(statement.type)) {
2558
2632
  return statement.type.members;
2559
2633
  }
2560
2634
  return void 0;
@@ -2566,7 +2640,7 @@ function rewriteImportedMemberTypes(statement, sourceFile, importedNames) {
2566
2640
  }
2567
2641
  const replacements = [];
2568
2642
  for (const member of members) {
2569
- if (!ts4.isPropertySignature(member)) {
2643
+ if (!ts3.isPropertySignature(member)) {
2570
2644
  if (astReferencesImportedName(member, importedNames)) {
2571
2645
  return null;
2572
2646
  }
@@ -2598,14 +2672,14 @@ function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
2598
2672
  );
2599
2673
  const result = [];
2600
2674
  for (const statement of sourceFile.statements) {
2601
- if (ts4.isImportDeclaration(statement)) continue;
2602
- if (ts4.isImportEqualsDeclaration(statement)) continue;
2603
- if (ts4.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
2675
+ if (ts3.isImportDeclaration(statement)) continue;
2676
+ if (ts3.isImportEqualsDeclaration(statement)) continue;
2677
+ if (ts3.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
2604
2678
  if (!astReferencesImportedName(statement, importedNamesToSkip)) {
2605
2679
  result.push(statement.getText(sourceFile));
2606
2680
  continue;
2607
2681
  }
2608
- if (ts4.isInterfaceDeclaration(statement) || ts4.isTypeAliasDeclaration(statement)) {
2682
+ if (ts3.isInterfaceDeclaration(statement) || ts3.isTypeAliasDeclaration(statement)) {
2609
2683
  const rewritten = rewriteImportedMemberTypes(statement, sourceFile, importedNamesToSkip);
2610
2684
  if (rewritten !== null) {
2611
2685
  result.push(rewritten);
@@ -2639,7 +2713,7 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
2639
2713
  pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2640
2714
  return;
2641
2715
  }
2642
- const constraintNode = (0, import_internal3.parseConstraintTagValue)(
2716
+ const constraintNode = (0, import_internal4.parseConstraintTagValue)(
2643
2717
  tagName,
2644
2718
  text,
2645
2719
  provenance,
@@ -2692,12 +2766,12 @@ function supportsConstraintCapability(type, checker, capability) {
2692
2766
  if (capability === void 0) {
2693
2767
  return true;
2694
2768
  }
2695
- if ((0, import_internal3.hasTypeSemanticCapability)(type, checker, capability)) {
2769
+ if ((0, import_internal4.hasTypeSemanticCapability)(type, checker, capability)) {
2696
2770
  return true;
2697
2771
  }
2698
2772
  if (capability === "string-like") {
2699
2773
  const itemType = getArrayElementType(type, checker);
2700
- return itemType !== null && (0, import_internal3.hasTypeSemanticCapability)(itemType, checker, capability);
2774
+ return itemType !== null && (0, import_internal4.hasTypeSemanticCapability)(itemType, checker, capability);
2701
2775
  }
2702
2776
  return false;
2703
2777
  }
@@ -2706,7 +2780,7 @@ function stripHintNullishUnion(type) {
2706
2780
  return type;
2707
2781
  }
2708
2782
  const nonNullish = type.types.filter(
2709
- (member) => (member.flags & (ts4.TypeFlags.Null | ts4.TypeFlags.Undefined)) === 0
2783
+ (member) => (member.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined)) === 0
2710
2784
  );
2711
2785
  if (nonNullish.length === 1 && nonNullish[0] !== void 0) {
2712
2786
  return nonNullish[0];
@@ -2722,10 +2796,10 @@ function isUserEmittableHintProperty(property, declaration) {
2722
2796
  }
2723
2797
  if ("name" in declaration && declaration.name !== void 0) {
2724
2798
  const name = declaration.name;
2725
- if (ts4.isComputedPropertyName(name) || ts4.isPrivateIdentifier(name)) {
2799
+ if (ts3.isComputedPropertyName(name) || ts3.isPrivateIdentifier(name)) {
2726
2800
  return false;
2727
2801
  }
2728
- if (!ts4.isIdentifier(name) && !ts4.isStringLiteral(name) && !ts4.isNumericLiteral(name)) {
2802
+ if (!ts3.isIdentifier(name) && !ts3.isStringLiteral(name) && !ts3.isNumericLiteral(name)) {
2729
2803
  return false;
2730
2804
  }
2731
2805
  }
@@ -2741,7 +2815,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
2741
2815
  if (isCallableType(stripped)) {
2742
2816
  return;
2743
2817
  }
2744
- if (!(0, import_internal3.hasTypeSemanticCapability)(stripped, checker, "object-like")) {
2818
+ if (!(0, import_internal4.hasTypeSemanticCapability)(stripped, checker, "object-like")) {
2745
2819
  return;
2746
2820
  }
2747
2821
  for (const property of stripped.getProperties()) {
@@ -2759,7 +2833,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
2759
2833
  continue;
2760
2834
  }
2761
2835
  const strippedPropertyType = stripHintNullishUnion(propertyType);
2762
- if (!isCallableType(strippedPropertyType) && (0, import_internal3.hasTypeSemanticCapability)(strippedPropertyType, checker, "object-like")) {
2836
+ if (!isCallableType(strippedPropertyType) && (0, import_internal4.hasTypeSemanticCapability)(strippedPropertyType, checker, "object-like")) {
2763
2837
  visit(strippedPropertyType, path5, depth + 1);
2764
2838
  }
2765
2839
  }
@@ -2768,7 +2842,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
2768
2842
  return out;
2769
2843
  }
2770
2844
  function buildPathTargetHint(subjectType, checker, capability, tagName, argumentText) {
2771
- if (!(0, import_internal3.hasTypeSemanticCapability)(subjectType, checker, "object-like")) {
2845
+ if (!(0, import_internal4.hasTypeSemanticCapability)(subjectType, checker, "object-like")) {
2772
2846
  return null;
2773
2847
  }
2774
2848
  const candidates = collectObjectSubfieldCandidates(subjectType, checker, capability);
@@ -2879,24 +2953,24 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2879
2953
  if (checker === void 0 || subjectType === void 0) {
2880
2954
  return [];
2881
2955
  }
2882
- const placement = (0, import_internal3.resolveDeclarationPlacement)(node);
2956
+ const placement = (0, import_internal4.resolveDeclarationPlacement)(node);
2883
2957
  if (placement === null) {
2884
2958
  return [];
2885
2959
  }
2886
- const definition = (0, import_internal3.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
2960
+ const definition = (0, import_internal4.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
2887
2961
  if (definition === null) {
2888
2962
  return [];
2889
2963
  }
2890
2964
  const nonNullPlacement = placement;
2891
- const log2 = (0, import_internal4.getBuildLogger)();
2892
- const broadeningLog = (0, import_internal4.getBroadeningLogger)();
2893
- const syntheticLog = (0, import_internal4.getSyntheticLogger)();
2894
- const typedParserLog = (0, import_internal4.getTypedParserLogger)();
2965
+ const log2 = (0, import_internal5.getBuildLogger)();
2966
+ const broadeningLog = (0, import_internal5.getBroadeningLogger)();
2967
+ const syntheticLog = (0, import_internal5.getSyntheticLogger)();
2968
+ const typedParserLog = (0, import_internal5.getTypedParserLogger)();
2895
2969
  const logsEnabled = log2 !== import_core4.noopLogger || broadeningLog !== import_core4.noopLogger;
2896
2970
  const syntheticTraceEnabled = syntheticLog !== import_core4.noopLogger;
2897
2971
  const typedParserTraceEnabled = typedParserLog !== import_core4.noopLogger;
2898
- const logStart = logsEnabled ? (0, import_internal4.nowMicros)() : 0;
2899
- const subjectTypeKind = logsEnabled ? (0, import_internal4.describeTypeKind)(subjectType, checker) : "";
2972
+ const logStart = logsEnabled ? (0, import_internal5.nowMicros)() : 0;
2973
+ const subjectTypeKind = logsEnabled ? (0, import_internal5.describeTypeKind)(subjectType, checker) : "";
2900
2974
  function emit(outcome, result2) {
2901
2975
  if (!logsEnabled) {
2902
2976
  return result2;
@@ -2907,11 +2981,11 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2907
2981
  placement: nonNullPlacement,
2908
2982
  subjectTypeKind,
2909
2983
  roleOutcome: outcome,
2910
- elapsedMicros: (0, import_internal4.elapsedMicros)(logStart)
2984
+ elapsedMicros: (0, import_internal5.elapsedMicros)(logStart)
2911
2985
  };
2912
- (0, import_internal4.logTagApplication)(log2, entry);
2986
+ (0, import_internal5.logTagApplication)(log2, entry);
2913
2987
  if (outcome === "bypass" || outcome === "D1" || outcome === "D2") {
2914
- (0, import_internal4.logTagApplication)(broadeningLog, entry);
2988
+ (0, import_internal5.logTagApplication)(broadeningLog, entry);
2915
2989
  }
2916
2990
  return result2;
2917
2991
  }
@@ -2946,7 +3020,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2946
3020
  )
2947
3021
  ]);
2948
3022
  }
2949
- const resolution = (0, import_internal3.resolvePathTargetType)(subjectType, checker, target.path.segments);
3023
+ const resolution = (0, import_internal4.resolvePathTargetType)(subjectType, checker, target.path.segments);
2950
3024
  if (resolution.kind === "missing-property") {
2951
3025
  return emit("B-reject", [
2952
3026
  makeDiagnostic(
@@ -2971,7 +3045,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2971
3045
  }
2972
3046
  const hasBroadening = (() => {
2973
3047
  if (target === null) {
2974
- if (isIntegerBrandedType((0, import_internal3.stripNullishUnion)(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
3048
+ if ((0, import_internal3._isIntegerBrandedType)((0, import_internal4.stripNullishUnion)(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
2975
3049
  return true;
2976
3050
  }
2977
3051
  return hasBuiltinConstraintBroadening(tagName, options);
@@ -3002,11 +3076,11 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
3002
3076
  ]);
3003
3077
  }
3004
3078
  }
3005
- const effectiveArgumentText = parsedTag !== null ? (0, import_internal3.parseTagSyntax)(tagName, rawText).argumentText : rawText;
3006
3079
  if (hasBroadening) {
3007
3080
  return emit("bypass", []);
3008
3081
  }
3009
- const typedParseResult = (0, import_internal4.parseTagArgument)(tagName, effectiveArgumentText, "build");
3082
+ const effectiveArgumentText = (0, import_internal5.extractEffectiveArgumentText)(tagName, rawText, parsedTag);
3083
+ const typedParseResult = (0, import_internal5.parseTagArgument)(tagName, effectiveArgumentText, "build");
3010
3084
  if (!typedParseResult.ok) {
3011
3085
  if (typedParserTraceEnabled) {
3012
3086
  typedParserLog.trace("typed-parser C-reject", {
@@ -3018,23 +3092,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
3018
3092
  diagnosticCode: typedParseResult.diagnostic.code
3019
3093
  });
3020
3094
  }
3021
- let mappedCode;
3022
- switch (typedParseResult.diagnostic.code) {
3023
- case "MISSING_TAG_ARGUMENT":
3024
- mappedCode = "MISSING_TAG_ARGUMENT";
3025
- break;
3026
- case "INVALID_TAG_ARGUMENT":
3027
- mappedCode = "INVALID_TAG_ARGUMENT";
3028
- break;
3029
- case "UNKNOWN_TAG":
3030
- throw new Error(
3031
- `Unexpected UNKNOWN_TAG from parseTagArgument("${tagName}") \u2014 tag was resolved via getTagDefinition.`
3032
- );
3033
- default: {
3034
- const _exhaustive = typedParseResult.diagnostic.code;
3035
- throw new Error(`Unknown diagnostic code: ${String(_exhaustive)}`);
3036
- }
3037
- }
3095
+ const mappedCode = (0, import_internal5.mapTypedParserDiagnosticCode)(typedParseResult.diagnostic.code, tagName);
3038
3096
  return emit("C-reject", [
3039
3097
  makeDiagnostic(mappedCode, typedParseResult.diagnostic.message, provenance)
3040
3098
  ]);
@@ -3065,7 +3123,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
3065
3123
  subjectTypeText
3066
3124
  });
3067
3125
  }
3068
- const result = (0, import_internal3.checkSyntheticTagApplication)({
3126
+ const result = (0, import_internal4.checkSyntheticTagApplication)({
3069
3127
  tagName,
3070
3128
  placement,
3071
3129
  hostType: hostTypeText,
@@ -3091,13 +3149,13 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
3091
3149
  } : {}
3092
3150
  });
3093
3151
  if (result.diagnostics.length === 0) {
3094
- return emit("C-pass", []);
3152
+ return emit("D-pass", []);
3095
3153
  }
3096
3154
  const setupDiagnostic = result.diagnostics.find((diagnostic) => diagnostic.kind !== "typescript");
3097
3155
  if (setupDiagnostic !== void 0) {
3098
3156
  return emit("C-reject", [
3099
3157
  makeDiagnostic(
3100
- setupDiagnostic.kind === "unsupported-custom-type-override" ? "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" : "SYNTHETIC_SETUP_FAILURE",
3158
+ (0, import_internal5._mapSetupDiagnosticCode)(setupDiagnostic.kind),
3101
3159
  setupDiagnostic.message,
3102
3160
  provenance
3103
3161
  )
@@ -3115,10 +3173,10 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
3115
3173
  function getExtensionTagNames(options) {
3116
3174
  return [
3117
3175
  ...options?.extensionRegistry?.extensions.flatMap(
3118
- (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal3.normalizeFormSpecTagName)(tag.tagName))
3176
+ (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal4.normalizeFormSpecTagName)(tag.tagName))
3119
3177
  ) ?? [],
3120
3178
  ...options?.extensionRegistry?.extensions.flatMap(
3121
- (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal3.normalizeFormSpecTagName)(slot.tagName))
3179
+ (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal4.normalizeFormSpecTagName)(slot.tagName))
3122
3180
  ) ?? []
3123
3181
  ].sort();
3124
3182
  }
@@ -3130,9 +3188,9 @@ function getExtensionRegistryCacheKey(registry) {
3130
3188
  (extension) => JSON.stringify({
3131
3189
  extensionId: extension.extensionId,
3132
3190
  typeNames: extension.types?.map((type) => type.typeName) ?? [],
3133
- constraintTags: extension.constraintTags?.map((tag) => (0, import_internal3.normalizeFormSpecTagName)(tag.tagName)) ?? [],
3191
+ constraintTags: extension.constraintTags?.map((tag) => (0, import_internal4.normalizeFormSpecTagName)(tag.tagName)) ?? [],
3134
3192
  metadataSlots: extension.metadataSlots?.map((slot) => ({
3135
- tagName: (0, import_internal3.normalizeFormSpecTagName)(slot.tagName),
3193
+ tagName: (0, import_internal4.normalizeFormSpecTagName)(slot.tagName),
3136
3194
  declarationKinds: [...slot.declarationKinds].sort(),
3137
3195
  allowBare: slot.allowBare !== false,
3138
3196
  qualifiers: (slot.qualifiers ?? []).map((qualifier) => ({
@@ -3164,6 +3222,16 @@ function parseTSDocTags(node, file = "", options) {
3164
3222
  if (cached !== void 0) {
3165
3223
  return cached;
3166
3224
  }
3225
+ const setupDiags = options?.extensionRegistry?.setupDiagnostics;
3226
+ if (setupDiags !== void 0 && setupDiags.length > 0) {
3227
+ const result2 = {
3228
+ constraints: [],
3229
+ annotations: [],
3230
+ diagnostics: (0, import_internal5._emitSetupDiagnostics)(setupDiags, file)
3231
+ };
3232
+ parseResultCache.set(cacheKey, result2);
3233
+ return result2;
3234
+ }
3167
3235
  const constraints = [];
3168
3236
  const annotations = [];
3169
3237
  const diagnostics = [];
@@ -3175,12 +3243,12 @@ function parseTSDocTags(node, file = "", options) {
3175
3243
  const sourceText = sourceFile.getFullText();
3176
3244
  const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
3177
3245
  const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
3178
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
3246
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
3179
3247
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
3180
3248
  const extensionTagNames = getExtensionTagNames(options);
3181
3249
  if (commentRanges) {
3182
3250
  for (const range of commentRanges) {
3183
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) {
3251
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) {
3184
3252
  continue;
3185
3253
  }
3186
3254
  const commentText = sourceText.substring(range.pos, range.end);
@@ -3188,7 +3256,7 @@ function parseTSDocTags(node, file = "", options) {
3188
3256
  continue;
3189
3257
  }
3190
3258
  const extensions = options?.extensionRegistry?.extensions;
3191
- const unified = (0, import_internal3.parseUnifiedComment)(commentText, {
3259
+ const unified = (0, import_internal4.parseUnifiedComment)(commentText, {
3192
3260
  offset: range.pos,
3193
3261
  extensionTagNames,
3194
3262
  ...extensions !== void 0 ? { extensions } : {}
@@ -3223,13 +3291,13 @@ function parseTSDocTags(node, file = "", options) {
3223
3291
  }
3224
3292
  continue;
3225
3293
  }
3226
- if (import_internal3.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
3294
+ if (import_internal4.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
3227
3295
  const fallback = rawTextFallbacks.get(tagName)?.shift();
3228
- const text2 = (0, import_internal3.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
3296
+ const text2 = (0, import_internal4.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
3229
3297
  if (text2 === "") continue;
3230
3298
  const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
3231
3299
  if (tagName === "defaultValue") {
3232
- annotations.push((0, import_internal3.parseDefaultValueTagValue)(text2, provenance2));
3300
+ annotations.push((0, import_internal4.parseDefaultValueTagValue)(text2, provenance2));
3233
3301
  continue;
3234
3302
  }
3235
3303
  processConstraintTag(
@@ -3311,7 +3379,7 @@ function parseTSDocTags(node, file = "", options) {
3311
3379
  if (text === "") continue;
3312
3380
  const provenance = fallback.provenance;
3313
3381
  if (tagName === "defaultValue") {
3314
- annotations.push((0, import_internal3.parseDefaultValueTagValue)(text, provenance));
3382
+ annotations.push((0, import_internal4.parseDefaultValueTagValue)(text, provenance));
3315
3383
  continue;
3316
3384
  }
3317
3385
  processConstraintTag(
@@ -3337,13 +3405,13 @@ function extractDisplayNameMetadata(node) {
3337
3405
  const memberDisplayNames = /* @__PURE__ */ new Map();
3338
3406
  const sourceFile = node.getSourceFile();
3339
3407
  const sourceText = sourceFile.getFullText();
3340
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
3408
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
3341
3409
  if (commentRanges) {
3342
3410
  for (const range of commentRanges) {
3343
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) continue;
3411
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) continue;
3344
3412
  const commentText = sourceText.substring(range.pos, range.end);
3345
3413
  if (!commentText.startsWith("/**")) continue;
3346
- const unified = (0, import_internal3.parseUnifiedComment)(commentText);
3414
+ const unified = (0, import_internal4.parseUnifiedComment)(commentText);
3347
3415
  for (const tag of unified.tags) {
3348
3416
  if (tag.normalizedTagName !== "displayName") {
3349
3417
  continue;
@@ -3365,9 +3433,9 @@ function extractDisplayNameMetadata(node) {
3365
3433
  }
3366
3434
  function collectRawTextFallbacks(node, file) {
3367
3435
  const fallbacks = /* @__PURE__ */ new Map();
3368
- for (const tag of ts4.getJSDocTags(node)) {
3436
+ for (const tag of ts3.getJSDocTags(node)) {
3369
3437
  const tagName = (0, import_internals4.normalizeConstraintTagName)(tag.tagName.text);
3370
- if (!import_internal3.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
3438
+ if (!import_internal4.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
3371
3439
  const commentText = getTagCommentText(tag)?.trim() ?? "";
3372
3440
  if (commentText === "") continue;
3373
3441
  const entries = fallbacks.get(tagName) ?? [];
@@ -3380,7 +3448,7 @@ function collectRawTextFallbacks(node, file) {
3380
3448
  return fallbacks;
3381
3449
  }
3382
3450
  function isMemberTargetDisplayName(text) {
3383
- return (0, import_internal3.parseTagSyntax)("displayName", text).target !== null;
3451
+ return (0, import_internal4.parseTagSyntax)("displayName", text).target !== null;
3384
3452
  }
3385
3453
  function provenanceForComment(range, sourceFile, file, tagName) {
3386
3454
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(range.pos);
@@ -3420,21 +3488,21 @@ function getTagCommentText(tag) {
3420
3488
  if (typeof tag.comment === "string") {
3421
3489
  return tag.comment;
3422
3490
  }
3423
- return ts4.getTextOfJSDocComment(tag.comment);
3491
+ return ts3.getTextOfJSDocComment(tag.comment);
3424
3492
  }
3425
- var ts4, import_internal3, import_internals4, import_internals5, import_core4, import_internal4, SYNTHETIC_TYPE_FORMAT_FLAGS, MAX_HINT_CANDIDATES, MAX_HINT_DEPTH, parseResultCache;
3493
+ var ts3, import_internal4, import_internals4, import_internals5, import_core4, import_internal5, SYNTHETIC_TYPE_FORMAT_FLAGS, MAX_HINT_CANDIDATES, MAX_HINT_DEPTH, parseResultCache;
3426
3494
  var init_tsdoc_parser = __esm({
3427
3495
  "src/analyzer/tsdoc-parser.ts"() {
3428
3496
  "use strict";
3429
- ts4 = __toESM(require("typescript"), 1);
3430
- import_internal3 = require("@formspec/analysis/internal");
3497
+ ts3 = __toESM(require("typescript"), 1);
3498
+ import_internal4 = require("@formspec/analysis/internal");
3431
3499
  import_internals4 = require("@formspec/core/internals");
3432
3500
  import_internals5 = require("@formspec/core/internals");
3433
3501
  import_core4 = require("@formspec/core");
3434
3502
  init_resolve_custom_type();
3435
3503
  init_builtin_brands();
3436
- import_internal4 = require("@formspec/analysis/internal");
3437
- SYNTHETIC_TYPE_FORMAT_FLAGS = ts4.TypeFormatFlags.NoTruncation | ts4.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
3504
+ import_internal5 = require("@formspec/analysis/internal");
3505
+ SYNTHETIC_TYPE_FORMAT_FLAGS = ts3.TypeFormatFlags.NoTruncation | ts3.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
3438
3506
  MAX_HINT_CANDIDATES = 5;
3439
3507
  MAX_HINT_DEPTH = 3;
3440
3508
  parseResultCache = /* @__PURE__ */ new Map();
@@ -3456,18 +3524,18 @@ function extractJSDocAnnotationNodes(node, file = "", options) {
3456
3524
  function extractDefaultValueAnnotation(initializer, file = "") {
3457
3525
  if (!initializer) return null;
3458
3526
  let value;
3459
- if (ts5.isStringLiteral(initializer)) {
3527
+ if (ts4.isStringLiteral(initializer)) {
3460
3528
  value = initializer.text;
3461
- } else if (ts5.isNumericLiteral(initializer)) {
3529
+ } else if (ts4.isNumericLiteral(initializer)) {
3462
3530
  value = Number(initializer.text);
3463
- } else if (initializer.kind === ts5.SyntaxKind.TrueKeyword) {
3531
+ } else if (initializer.kind === ts4.SyntaxKind.TrueKeyword) {
3464
3532
  value = true;
3465
- } else if (initializer.kind === ts5.SyntaxKind.FalseKeyword) {
3533
+ } else if (initializer.kind === ts4.SyntaxKind.FalseKeyword) {
3466
3534
  value = false;
3467
- } else if (initializer.kind === ts5.SyntaxKind.NullKeyword) {
3535
+ } else if (initializer.kind === ts4.SyntaxKind.NullKeyword) {
3468
3536
  value = null;
3469
- } else if (ts5.isPrefixUnaryExpression(initializer)) {
3470
- if (initializer.operator === ts5.SyntaxKind.MinusToken && ts5.isNumericLiteral(initializer.operand)) {
3537
+ } else if (ts4.isPrefixUnaryExpression(initializer)) {
3538
+ if (initializer.operator === ts4.SyntaxKind.MinusToken && ts4.isNumericLiteral(initializer.operand)) {
3471
3539
  value = -Number(initializer.operand.text);
3472
3540
  }
3473
3541
  }
@@ -3486,39 +3554,39 @@ function extractDefaultValueAnnotation(initializer, file = "") {
3486
3554
  }
3487
3555
  };
3488
3556
  }
3489
- var ts5;
3557
+ var ts4;
3490
3558
  var init_jsdoc_constraints = __esm({
3491
3559
  "src/analyzer/jsdoc-constraints.ts"() {
3492
3560
  "use strict";
3493
- ts5 = __toESM(require("typescript"), 1);
3561
+ ts4 = __toESM(require("typescript"), 1);
3494
3562
  init_tsdoc_parser();
3495
3563
  }
3496
3564
  });
3497
3565
 
3498
3566
  // src/analyzer/class-analyzer.ts
3499
3567
  function isObjectType(type) {
3500
- return !!(type.flags & ts6.TypeFlags.Object);
3568
+ return !!(type.flags & ts5.TypeFlags.Object);
3501
3569
  }
3502
3570
  function isIntersectionType(type) {
3503
- return !!(type.flags & ts6.TypeFlags.Intersection);
3571
+ return !!(type.flags & ts5.TypeFlags.Intersection);
3504
3572
  }
3505
3573
  function isResolvableObjectLikeAliasTypeNode(typeNode) {
3506
- if (ts6.isParenthesizedTypeNode(typeNode)) {
3574
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3507
3575
  return isResolvableObjectLikeAliasTypeNode(typeNode.type);
3508
3576
  }
3509
- if (ts6.isTypeLiteralNode(typeNode) || ts6.isTypeReferenceNode(typeNode)) {
3577
+ if (ts5.isTypeLiteralNode(typeNode) || ts5.isTypeReferenceNode(typeNode)) {
3510
3578
  return true;
3511
3579
  }
3512
- return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
3580
+ return ts5.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
3513
3581
  }
3514
3582
  function isSemanticallyPlainObjectLikeType(type, checker) {
3515
3583
  if (isIntersectionType(type)) {
3516
3584
  return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
3517
3585
  }
3518
- 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);
3586
+ 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);
3519
3587
  }
3520
3588
  function isTypeReference(type) {
3521
- return !!(type.flags & ts6.TypeFlags.Object) && !!(type.objectFlags & ts6.ObjectFlags.Reference);
3589
+ return !!(type.flags & ts5.TypeFlags.Object) && !!(type.objectFlags & ts5.ObjectFlags.Reference);
3522
3590
  }
3523
3591
  function makeParseOptions(extensionRegistry, fieldType, checker, subjectType, hostType) {
3524
3592
  if (extensionRegistry === void 0 && fieldType === void 0 && checker === void 0 && subjectType === void 0 && hostType === void 0) {
@@ -3539,8 +3607,19 @@ function createAnalyzerMetadataPolicy(input, discriminator) {
3539
3607
  discriminator
3540
3608
  };
3541
3609
  }
3610
+ function deduplicateDiagnostics(diagnostics) {
3611
+ if (diagnostics.length <= 1) return diagnostics;
3612
+ const seen = /* @__PURE__ */ new Set();
3613
+ return diagnostics.filter((d) => {
3614
+ if (!DEDUPLICATABLE_DIAGNOSTIC_CODES.has(d.code)) return true;
3615
+ const key = `${d.code}\0${d.message}`;
3616
+ if (seen.has(key)) return false;
3617
+ seen.add(key);
3618
+ return true;
3619
+ });
3620
+ }
3542
3621
  function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node, checker, extensionRegistry, buildContext) {
3543
- const analysis = (0, import_internal5.analyzeMetadataForNodeWithChecker)({
3622
+ const analysis = (0, import_internal6.analyzeMetadataForNodeWithChecker)({
3544
3623
  checker,
3545
3624
  node,
3546
3625
  logicalName,
@@ -3575,10 +3654,120 @@ function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node,
3575
3654
  }
3576
3655
  return resolvedMetadata;
3577
3656
  }
3657
+ function getInheritableAnnotationStringValue(annotation) {
3658
+ if (annotation.annotationKind === "format") return annotation.value;
3659
+ return void 0;
3660
+ }
3661
+ function isOverridingInheritableAnnotation(annotation) {
3662
+ const value = getInheritableAnnotationStringValue(annotation);
3663
+ if (value === void 0) return true;
3664
+ return value.trim().length > 0;
3665
+ }
3666
+ function collectInheritedTypeAnnotations(derivedDecl, existingAnnotations, checker, extensionRegistry) {
3667
+ const existingKinds = new Set(
3668
+ existingAnnotations.filter(isOverridingInheritableAnnotation).map((a) => a.annotationKind)
3669
+ );
3670
+ const needed = /* @__PURE__ */ new Set();
3671
+ for (const kind of INHERITABLE_TYPE_ANNOTATION_KINDS) {
3672
+ if (!existingKinds.has(kind)) needed.add(kind);
3673
+ }
3674
+ if (needed.size === 0) return [];
3675
+ const inherited = [];
3676
+ const seen = /* @__PURE__ */ new Set([derivedDecl]);
3677
+ const queue = [];
3678
+ const resolveSymbolTarget = (sym) => {
3679
+ if ((sym.flags & ts5.SymbolFlags.Alias) === 0) return sym;
3680
+ try {
3681
+ return checker.getAliasedSymbol(sym);
3682
+ } catch {
3683
+ return sym;
3684
+ }
3685
+ };
3686
+ const isObjectShapedTypeAlias = (alias) => {
3687
+ const type = checker.getTypeFromTypeNode(alias.type);
3688
+ if ((type.flags & ts5.TypeFlags.Object) !== 0) return true;
3689
+ if (type.isIntersection()) return true;
3690
+ return false;
3691
+ };
3692
+ const enqueueCandidate = (baseDecl, fromTypeAliasRhs) => {
3693
+ if (seen.has(baseDecl)) return;
3694
+ if (ts5.isClassDeclaration(baseDecl) || ts5.isInterfaceDeclaration(baseDecl)) {
3695
+ seen.add(baseDecl);
3696
+ queue.push(baseDecl);
3697
+ return;
3698
+ }
3699
+ if (ts5.isTypeAliasDeclaration(baseDecl)) {
3700
+ if (!fromTypeAliasRhs && !isObjectShapedTypeAlias(baseDecl)) return;
3701
+ seen.add(baseDecl);
3702
+ queue.push(baseDecl);
3703
+ }
3704
+ };
3705
+ const enqueueBasesOf = (decl) => {
3706
+ if (ts5.isTypeAliasDeclaration(decl)) {
3707
+ const rhs = decl.type;
3708
+ if (!ts5.isTypeReferenceNode(rhs)) return;
3709
+ const sym = checker.getSymbolAtLocation(rhs.typeName);
3710
+ if (!sym) return;
3711
+ const target = resolveSymbolTarget(sym);
3712
+ for (const baseDecl of target.declarations ?? []) {
3713
+ enqueueCandidate(
3714
+ baseDecl,
3715
+ /*fromTypeAliasRhs*/
3716
+ true
3717
+ );
3718
+ }
3719
+ return;
3720
+ }
3721
+ const heritageClauses = decl.heritageClauses;
3722
+ if (!heritageClauses) return;
3723
+ for (const clause of heritageClauses) {
3724
+ if (clause.token !== ts5.SyntaxKind.ExtendsKeyword) continue;
3725
+ for (const typeExpr of clause.types) {
3726
+ const sym = checker.getSymbolAtLocation(typeExpr.expression);
3727
+ if (!sym) continue;
3728
+ const target = resolveSymbolTarget(sym);
3729
+ for (const baseDecl of target.declarations ?? []) {
3730
+ enqueueCandidate(
3731
+ baseDecl,
3732
+ /*fromTypeAliasRhs*/
3733
+ false
3734
+ );
3735
+ }
3736
+ }
3737
+ }
3738
+ };
3739
+ enqueueBasesOf(derivedDecl);
3740
+ for (let queueIndex = 0; queueIndex < queue.length && needed.size > 0; queueIndex++) {
3741
+ const baseDecl = queue[queueIndex];
3742
+ if (baseDecl === void 0) continue;
3743
+ const baseFile = baseDecl.getSourceFile().fileName;
3744
+ const baseAnnotations = extractJSDocAnnotationNodes(
3745
+ baseDecl,
3746
+ baseFile,
3747
+ makeParseOptions(extensionRegistry)
3748
+ );
3749
+ for (const annotation of baseAnnotations) {
3750
+ if (!needed.has(annotation.annotationKind)) continue;
3751
+ if (!isOverridingInheritableAnnotation(annotation)) continue;
3752
+ inherited.push(annotation);
3753
+ needed.delete(annotation.annotationKind);
3754
+ }
3755
+ if (needed.size > 0) {
3756
+ enqueueBasesOf(baseDecl);
3757
+ }
3758
+ }
3759
+ return inherited;
3760
+ }
3761
+ function extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) {
3762
+ const local = extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry));
3763
+ const inherited = collectInheritedTypeAnnotations(namedDecl, local, checker, extensionRegistry);
3764
+ if (inherited.length === 0) return [...local];
3765
+ return [...local, ...inherited];
3766
+ }
3578
3767
  function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRegistry, metadataPolicy) {
3579
3768
  const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
3580
3769
  const declarationType = checker.getTypeAtLocation(declaration);
3581
- const logicalName = ts6.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
3770
+ const logicalName = ts5.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
3582
3771
  const docResult = extractJSDocParseResult(
3583
3772
  declaration,
3584
3773
  file,
@@ -3620,13 +3809,19 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3620
3809
  file,
3621
3810
  makeParseOptions(extensionRegistry, void 0, checker, classType, classType)
3622
3811
  );
3623
- const annotations = [...classDoc.annotations];
3812
+ const inheritedClassAnnotations = collectInheritedTypeAnnotations(
3813
+ classDecl,
3814
+ classDoc.annotations,
3815
+ checker,
3816
+ extensionRegistry
3817
+ );
3818
+ const annotations = [...classDoc.annotations, ...inheritedClassAnnotations];
3624
3819
  diagnostics.push(...classDoc.diagnostics);
3625
3820
  const visiting = /* @__PURE__ */ new Set();
3626
3821
  const instanceMethods = [];
3627
3822
  const staticMethods = [];
3628
3823
  for (const member of classDecl.members) {
3629
- if (ts6.isPropertyDeclaration(member)) {
3824
+ if (ts5.isPropertyDeclaration(member)) {
3630
3825
  const fieldNode = analyzeFieldToIR(
3631
3826
  member,
3632
3827
  checker,
@@ -3642,10 +3837,10 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3642
3837
  fields.push(fieldNode);
3643
3838
  fieldLayouts.push({});
3644
3839
  }
3645
- } else if (ts6.isMethodDeclaration(member)) {
3840
+ } else if (ts5.isMethodDeclaration(member)) {
3646
3841
  const methodInfo = analyzeMethod(member, checker);
3647
3842
  if (methodInfo) {
3648
- const isStatic = member.modifiers?.some((m) => m.kind === ts6.SyntaxKind.StaticKeyword);
3843
+ const isStatic = member.modifiers?.some((m) => m.kind === ts5.SyntaxKind.StaticKeyword);
3649
3844
  if (isStatic) {
3650
3845
  staticMethods.push(methodInfo);
3651
3846
  } else {
@@ -3677,6 +3872,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3677
3872
  hostType: classType
3678
3873
  }
3679
3874
  );
3875
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3680
3876
  return {
3681
3877
  name,
3682
3878
  ...metadata !== void 0 && { metadata },
@@ -3684,7 +3880,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3684
3880
  fieldLayouts,
3685
3881
  typeRegistry,
3686
3882
  ...annotations.length > 0 && { annotations },
3687
- ...diagnostics.length > 0 && { diagnostics },
3883
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3688
3884
  instanceMethods,
3689
3885
  staticMethods
3690
3886
  };
@@ -3704,11 +3900,20 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3704
3900
  file,
3705
3901
  makeParseOptions(extensionRegistry, void 0, checker, interfaceType, interfaceType)
3706
3902
  );
3707
- const annotations = [...interfaceDoc.annotations];
3903
+ const inheritedInterfaceAnnotations = collectInheritedTypeAnnotations(
3904
+ interfaceDecl,
3905
+ interfaceDoc.annotations,
3906
+ checker,
3907
+ extensionRegistry
3908
+ );
3909
+ const annotations = [
3910
+ ...interfaceDoc.annotations,
3911
+ ...inheritedInterfaceAnnotations
3912
+ ];
3708
3913
  diagnostics.push(...interfaceDoc.diagnostics);
3709
3914
  const visiting = /* @__PURE__ */ new Set();
3710
3915
  for (const member of interfaceDecl.members) {
3711
- if (ts6.isPropertySignature(member)) {
3916
+ if (ts5.isPropertySignature(member)) {
3712
3917
  const fieldNode = analyzeInterfacePropertyToIR(
3713
3918
  member,
3714
3919
  checker,
@@ -3749,6 +3954,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3749
3954
  hostType: interfaceType
3750
3955
  }
3751
3956
  );
3957
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3752
3958
  return {
3753
3959
  name,
3754
3960
  ...metadata !== void 0 && { metadata },
@@ -3756,7 +3962,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3756
3962
  fieldLayouts,
3757
3963
  typeRegistry,
3758
3964
  ...annotations.length > 0 && { annotations },
3759
- ...diagnostics.length > 0 && { diagnostics },
3965
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3760
3966
  instanceMethods: [],
3761
3967
  staticMethods: []
3762
3968
  };
@@ -3766,7 +3972,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3766
3972
  if (members === null) {
3767
3973
  const sourceFile = typeAlias.getSourceFile();
3768
3974
  const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
3769
- const kindDesc = ts6.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3975
+ const kindDesc = ts5.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3770
3976
  return {
3771
3977
  ok: false,
3772
3978
  kind: "not-object-like",
@@ -3801,7 +4007,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3801
4007
  diagnostics.push(...typeAliasDoc.diagnostics);
3802
4008
  const visiting = /* @__PURE__ */ new Set();
3803
4009
  for (const member of members) {
3804
- if (ts6.isPropertySignature(member)) {
4010
+ if (ts5.isPropertySignature(member)) {
3805
4011
  const fieldNode = analyzeInterfacePropertyToIR(
3806
4012
  member,
3807
4013
  checker,
@@ -3841,6 +4047,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3841
4047
  hostType: aliasType
3842
4048
  }
3843
4049
  );
4050
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
3844
4051
  return {
3845
4052
  ok: true,
3846
4053
  analysis: {
@@ -3850,7 +4057,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3850
4057
  fieldLayouts: specializedFields.map(() => ({})),
3851
4058
  typeRegistry,
3852
4059
  ...annotations.length > 0 && { annotations },
3853
- ...diagnostics.length > 0 && { diagnostics },
4060
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
3854
4061
  instanceMethods: [],
3855
4062
  staticMethods: []
3856
4063
  }
@@ -3868,20 +4075,20 @@ function makeAnalysisDiagnostic(code, message, primaryLocation, relatedLocations
3868
4075
  function getLeadingParsedTags(node) {
3869
4076
  const sourceFile = node.getSourceFile();
3870
4077
  const sourceText = sourceFile.getFullText();
3871
- const commentRanges = ts6.getLeadingCommentRanges(sourceText, node.getFullStart());
4078
+ const commentRanges = ts5.getLeadingCommentRanges(sourceText, node.getFullStart());
3872
4079
  if (commentRanges === void 0) {
3873
4080
  return [];
3874
4081
  }
3875
4082
  const parsedTags = [];
3876
4083
  for (const range of commentRanges) {
3877
- if (range.kind !== ts6.SyntaxKind.MultiLineCommentTrivia) {
4084
+ if (range.kind !== ts5.SyntaxKind.MultiLineCommentTrivia) {
3878
4085
  continue;
3879
4086
  }
3880
4087
  const commentText = sourceText.slice(range.pos, range.end);
3881
4088
  if (!commentText.startsWith("/**")) {
3882
4089
  continue;
3883
4090
  }
3884
- parsedTags.push(...(0, import_internal5.parseCommentBlock)(commentText, { offset: range.pos }).tags);
4091
+ parsedTags.push(...(0, import_internal6.parseCommentBlock)(commentText, { offset: range.pos }).tags);
3885
4092
  }
3886
4093
  return parsedTags;
3887
4094
  }
@@ -3892,19 +4099,19 @@ function resolveDiscriminatorProperty(node, checker, fieldName) {
3892
4099
  return null;
3893
4100
  }
3894
4101
  const declaration = propertySymbol.valueDeclaration ?? propertySymbol.declarations?.find(
3895
- (candidate) => ts6.isPropertyDeclaration(candidate) || ts6.isPropertySignature(candidate)
4102
+ (candidate) => ts5.isPropertyDeclaration(candidate) || ts5.isPropertySignature(candidate)
3896
4103
  ) ?? propertySymbol.declarations?.[0];
3897
4104
  return {
3898
4105
  declaration,
3899
4106
  type: checker.getTypeOfSymbolAtLocation(propertySymbol, declaration ?? node),
3900
- optional: !!(propertySymbol.flags & ts6.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
4107
+ optional: !!(propertySymbol.flags & ts5.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
3901
4108
  };
3902
4109
  }
3903
4110
  function isLocalTypeParameterName(node, typeParameterName) {
3904
4111
  return node.typeParameters?.some((typeParameter) => typeParameter.name.text === typeParameterName) ?? false;
3905
4112
  }
3906
4113
  function isNullishSemanticType(type) {
3907
- if (type.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined | ts6.TypeFlags.Void | ts6.TypeFlags.Unknown | ts6.TypeFlags.Any)) {
4114
+ if (type.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined | ts5.TypeFlags.Void | ts5.TypeFlags.Unknown | ts5.TypeFlags.Any)) {
3908
4115
  return true;
3909
4116
  }
3910
4117
  return type.isUnion() && type.types.some((member) => isNullishSemanticType(member));
@@ -3914,7 +4121,7 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
3914
4121
  return false;
3915
4122
  }
3916
4123
  seen.add(type);
3917
- if (type.flags & ts6.TypeFlags.StringLike) {
4124
+ if (type.flags & ts5.TypeFlags.StringLike) {
3918
4125
  return true;
3919
4126
  }
3920
4127
  if (type.isUnion()) {
@@ -3927,13 +4134,13 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
3927
4134
  return false;
3928
4135
  }
3929
4136
  function getObjectLikeTypeAliasMembers(typeNode) {
3930
- if (ts6.isParenthesizedTypeNode(typeNode)) {
4137
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3931
4138
  return getObjectLikeTypeAliasMembers(typeNode.type);
3932
4139
  }
3933
- if (ts6.isTypeLiteralNode(typeNode)) {
4140
+ if (ts5.isTypeLiteralNode(typeNode)) {
3934
4141
  return [...typeNode.members];
3935
4142
  }
3936
- if (ts6.isIntersectionTypeNode(typeNode)) {
4143
+ if (ts5.isIntersectionTypeNode(typeNode)) {
3937
4144
  const members = [];
3938
4145
  for (const intersectionMember of typeNode.types) {
3939
4146
  const resolvedMembers = getObjectLikeTypeAliasMembers(intersectionMember);
@@ -4096,7 +4303,7 @@ function resolveLiteralDiscriminatorPropertyValue(boundType, propertyName, check
4096
4303
  }
4097
4304
  if (propertyType.isUnion()) {
4098
4305
  const nonNullMembers = propertyType.types.filter(
4099
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
4306
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4100
4307
  );
4101
4308
  if (nonNullMembers.length > 0 && nonNullMembers.every((member) => member.isStringLiteral())) {
4102
4309
  diagnostics.push(
@@ -4145,13 +4352,13 @@ function resolveNamedDiscriminatorDeclaration(type, checker, seen = /* @__PURE__
4145
4352
  seen.add(type);
4146
4353
  const symbol = type.aliasSymbol ?? type.getSymbol();
4147
4354
  if (symbol !== void 0) {
4148
- const aliased = symbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
4355
+ const aliased = symbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
4149
4356
  const targetSymbol = aliased ?? symbol;
4150
4357
  const declaration = targetSymbol.declarations?.find(
4151
- (candidate) => ts6.isClassDeclaration(candidate) || ts6.isInterfaceDeclaration(candidate) || ts6.isTypeAliasDeclaration(candidate) || ts6.isEnumDeclaration(candidate)
4358
+ (candidate) => ts5.isClassDeclaration(candidate) || ts5.isInterfaceDeclaration(candidate) || ts5.isTypeAliasDeclaration(candidate) || ts5.isEnumDeclaration(candidate)
4152
4359
  );
4153
4360
  if (declaration !== void 0) {
4154
- if (ts6.isTypeAliasDeclaration(declaration) && ts6.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
4361
+ if (ts5.isTypeAliasDeclaration(declaration) && ts5.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
4155
4362
  return resolveNamedDiscriminatorDeclaration(
4156
4363
  checker.getTypeFromTypeNode(declaration.type),
4157
4364
  checker,
@@ -4179,7 +4386,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
4179
4386
  }
4180
4387
  if (boundType.isUnion()) {
4181
4388
  const nonNullMembers = boundType.types.filter(
4182
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
4389
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4183
4390
  );
4184
4391
  if (nonNullMembers.every((member) => member.isStringLiteral())) {
4185
4392
  diagnostics.push(
@@ -4224,7 +4431,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
4224
4431
  return null;
4225
4432
  }
4226
4433
  function getDeclarationName(node) {
4227
- if (ts6.isClassDeclaration(node) || ts6.isInterfaceDeclaration(node) || ts6.isTypeAliasDeclaration(node) || ts6.isEnumDeclaration(node)) {
4434
+ if (ts5.isClassDeclaration(node) || ts5.isInterfaceDeclaration(node) || ts5.isTypeAliasDeclaration(node) || ts5.isEnumDeclaration(node)) {
4228
4435
  return node.name?.text ?? "anonymous";
4229
4436
  }
4230
4437
  return "anonymous";
@@ -4279,11 +4486,11 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
4279
4486
  if (sourceTypeNode === void 0) {
4280
4487
  return [];
4281
4488
  }
4282
- const unwrapParentheses = (typeNode) => ts6.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
4489
+ const unwrapParentheses = (typeNode) => ts5.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
4283
4490
  const directTypeNode = unwrapParentheses(sourceTypeNode);
4284
- const referenceTypeNode = ts6.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
4491
+ const referenceTypeNode = ts5.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
4285
4492
  const resolvedTypeNode = resolveAliasedTypeNode(directTypeNode, checker);
4286
- return ts6.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
4493
+ return ts5.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
4287
4494
  })();
4288
4495
  if (referenceTypeNode?.typeArguments === void 0) {
4289
4496
  return [];
@@ -4291,7 +4498,7 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
4291
4498
  return referenceTypeNode.typeArguments.map((argumentNode) => {
4292
4499
  const argumentType = checker.getTypeFromTypeNode(argumentNode);
4293
4500
  const baseSymbol = argumentType.aliasSymbol ?? argumentType.getSymbol();
4294
- const argumentSymbol = baseSymbol !== void 0 && baseSymbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(baseSymbol) : baseSymbol;
4501
+ const argumentSymbol = baseSymbol !== void 0 && baseSymbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(baseSymbol) : baseSymbol;
4295
4502
  const argumentDecl = argumentSymbol?.declarations?.[0];
4296
4503
  if (argumentDecl !== void 0 && argumentDecl.getSourceFile().fileName !== file) {
4297
4504
  const argumentName = argumentSymbol?.getName() ?? baseSymbol?.getName();
@@ -4354,7 +4561,7 @@ function applyDiscriminatorToObjectProperties(properties, node, subjectType, che
4354
4561
  );
4355
4562
  }
4356
4563
  function analyzeFieldToIR(prop, checker, file, typeRegistry, visiting, diagnostics, hostType, metadataPolicy, extensionRegistry) {
4357
- if (!ts6.isIdentifier(prop.name)) {
4564
+ if (!ts5.isIdentifier(prop.name)) {
4358
4565
  return null;
4359
4566
  }
4360
4567
  const name = prop.name.text;
@@ -4481,7 +4688,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
4481
4688
  const seen = /* @__PURE__ */ new Set();
4482
4689
  const duplicates = /* @__PURE__ */ new Set();
4483
4690
  for (const member of members) {
4484
- if (!ts6.isPropertySignature(member)) {
4691
+ if (!ts5.isPropertySignature(member)) {
4485
4692
  continue;
4486
4693
  }
4487
4694
  const name = getAnalyzableObjectLikePropertyName(member.name);
@@ -4497,7 +4704,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
4497
4704
  return [...duplicates].sort();
4498
4705
  }
4499
4706
  function getAnalyzableObjectLikePropertyName(name) {
4500
- if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
4707
+ if (ts5.isIdentifier(name) || ts5.isStringLiteral(name) || ts5.isNumericLiteral(name)) {
4501
4708
  return name.text;
4502
4709
  }
4503
4710
  return null;
@@ -4592,28 +4799,28 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4592
4799
  if (primitiveAlias) {
4593
4800
  return primitiveAlias;
4594
4801
  }
4595
- if (isIntegerBrandedType(type)) {
4802
+ if ((0, import_internal3._isIntegerBrandedType)(type)) {
4596
4803
  return { kind: "primitive", primitiveKind: "integer" };
4597
4804
  }
4598
- if (type.flags & ts6.TypeFlags.String) {
4805
+ if (type.flags & ts5.TypeFlags.String) {
4599
4806
  return { kind: "primitive", primitiveKind: "string" };
4600
4807
  }
4601
- if (type.flags & ts6.TypeFlags.Number) {
4808
+ if (type.flags & ts5.TypeFlags.Number) {
4602
4809
  return { kind: "primitive", primitiveKind: "number" };
4603
4810
  }
4604
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
4811
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
4605
4812
  return { kind: "primitive", primitiveKind: "bigint" };
4606
4813
  }
4607
- if (type.flags & ts6.TypeFlags.Boolean) {
4814
+ if (type.flags & ts5.TypeFlags.Boolean) {
4608
4815
  return { kind: "primitive", primitiveKind: "boolean" };
4609
4816
  }
4610
- if (type.flags & ts6.TypeFlags.Null) {
4817
+ if (type.flags & ts5.TypeFlags.Null) {
4611
4818
  return { kind: "primitive", primitiveKind: "null" };
4612
4819
  }
4613
- if (type.flags & ts6.TypeFlags.Undefined) {
4820
+ if (type.flags & ts5.TypeFlags.Undefined) {
4614
4821
  return { kind: "primitive", primitiveKind: "null" };
4615
4822
  }
4616
- if (type.flags & ts6.TypeFlags.Void) {
4823
+ if (type.flags & ts5.TypeFlags.Void) {
4617
4824
  return { kind: "primitive", primitiveKind: "null" };
4618
4825
  }
4619
4826
  if (type.isStringLiteral()) {
@@ -4700,10 +4907,10 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4700
4907
  return { kind: "primitive", primitiveKind: "string" };
4701
4908
  }
4702
4909
  function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4703
- if (!(type.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
4910
+ if (!(type.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null)) && !(0, import_internal3._isIntegerBrandedType)(type)) {
4704
4911
  return null;
4705
4912
  }
4706
- const aliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
4913
+ const aliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
4707
4914
  if (!aliasDecl) {
4708
4915
  return null;
4709
4916
  }
@@ -4714,11 +4921,18 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
4714
4921
  ...extractJSDocConstraintNodes(aliasDecl, file, makeParseOptions(extensionRegistry)),
4715
4922
  ...extractTypeAliasConstraintNodes(aliasDecl.type, checker, file, extensionRegistry)
4716
4923
  ];
4717
- const annotations = extractJSDocAnnotationNodes(
4924
+ const localAnnotations = extractJSDocAnnotationNodes(
4718
4925
  aliasDecl,
4719
4926
  file,
4720
4927
  makeParseOptions(extensionRegistry)
4721
4928
  );
4929
+ const inheritedAnnotations = collectInheritedTypeAnnotations(
4930
+ aliasDecl,
4931
+ localAnnotations,
4932
+ checker,
4933
+ extensionRegistry
4934
+ );
4935
+ const annotations = [...localAnnotations, ...inheritedAnnotations];
4722
4936
  const metadata = resolveNodeMetadata(
4723
4937
  metadataPolicy,
4724
4938
  "type",
@@ -4753,8 +4967,8 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
4753
4967
  return { kind: "reference", name: aliasName, typeArguments: [] };
4754
4968
  }
4755
4969
  function getReferencedTypeAliasDeclaration(sourceNode, checker) {
4756
- const typeNode = sourceNode && (ts6.isPropertyDeclaration(sourceNode) || ts6.isPropertySignature(sourceNode) || ts6.isParameter(sourceNode)) ? sourceNode.type : void 0;
4757
- if (!typeNode || !ts6.isTypeReferenceNode(typeNode)) {
4970
+ const typeNode = sourceNode && (ts5.isPropertyDeclaration(sourceNode) || ts5.isPropertySignature(sourceNode) || ts5.isParameter(sourceNode)) ? sourceNode.type : void 0;
4971
+ if (!typeNode || !ts5.isTypeReferenceNode(typeNode)) {
4758
4972
  return void 0;
4759
4973
  }
4760
4974
  return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -4775,7 +4989,7 @@ function resolveNamedTypeWithSourceRecovery(type, sourceNode, checker) {
4775
4989
  return { typeName: refAliasDecl.name.text, namedDecl: refAliasDecl };
4776
4990
  }
4777
4991
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4778
- if (!ts6.isTypeReferenceNode(typeNode)) {
4992
+ if (!ts5.isTypeReferenceNode(typeNode)) {
4779
4993
  return false;
4780
4994
  }
4781
4995
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -4783,10 +4997,10 @@ function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4783
4997
  return false;
4784
4998
  }
4785
4999
  const resolved = checker.getTypeFromTypeNode(aliasDecl.type);
4786
- return !!(resolved.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null));
5000
+ return !!(resolved.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null));
4787
5001
  }
4788
5002
  function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics, visitedAliases = /* @__PURE__ */ new Set()) {
4789
- const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration);
5003
+ const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration);
4790
5004
  if (nestedAliasDecl !== void 0 && !visitedAliases.has(nestedAliasDecl)) {
4791
5005
  visitedAliases.add(nestedAliasDecl);
4792
5006
  return resolveAliasedPrimitiveTarget(
@@ -4801,22 +5015,22 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
4801
5015
  visitedAliases
4802
5016
  );
4803
5017
  }
4804
- if (isIntegerBrandedType(type)) {
5018
+ if ((0, import_internal3._isIntegerBrandedType)(type)) {
4805
5019
  return { kind: "primitive", primitiveKind: "integer" };
4806
5020
  }
4807
- if (type.flags & ts6.TypeFlags.String) {
5021
+ if (type.flags & ts5.TypeFlags.String) {
4808
5022
  return { kind: "primitive", primitiveKind: "string" };
4809
5023
  }
4810
- if (type.flags & ts6.TypeFlags.Number) {
5024
+ if (type.flags & ts5.TypeFlags.Number) {
4811
5025
  return { kind: "primitive", primitiveKind: "number" };
4812
5026
  }
4813
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
5027
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
4814
5028
  return { kind: "primitive", primitiveKind: "bigint" };
4815
5029
  }
4816
- if (type.flags & ts6.TypeFlags.Boolean) {
5030
+ if (type.flags & ts5.TypeFlags.Boolean) {
4817
5031
  return { kind: "primitive", primitiveKind: "boolean" };
4818
5032
  }
4819
- if (type.flags & ts6.TypeFlags.Null) {
5033
+ if (type.flags & ts5.TypeFlags.Null) {
4820
5034
  return { kind: "primitive", primitiveKind: "null" };
4821
5035
  }
4822
5036
  return resolveTypeNode(
@@ -4836,7 +5050,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4836
5050
  let typeName = null;
4837
5051
  let namedDecl;
4838
5052
  if (recovered !== null) {
4839
- const recoveredAliasDecl = ts6.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
5053
+ const recoveredAliasDecl = ts5.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
4840
5054
  if (recoveredAliasDecl !== void 0) {
4841
5055
  const aliasUnderlyingType = checker.getTypeFromTypeNode(recoveredAliasDecl.type);
4842
5056
  const isNonGeneric = recoveredAliasDecl.typeParameters === void 0 || recoveredAliasDecl.typeParameters.length === 0;
@@ -4858,13 +5072,13 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4858
5072
  (memberTypeNode) => !isNullishTypeNode(resolveAliasedTypeNode(memberTypeNode, checker))
4859
5073
  );
4860
5074
  const nonNullTypes = allTypes.filter(
4861
- (memberType) => !(memberType.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
5075
+ (memberType) => !(memberType.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4862
5076
  );
4863
5077
  const nonNullMembers = nonNullTypes.map((memberType, index) => ({
4864
5078
  memberType,
4865
5079
  sourceNode: nonNullSourceNodes.length === nonNullTypes.length ? nonNullSourceNodes[index] : void 0
4866
5080
  }));
4867
- const hasNull = allTypes.some((t) => t.flags & ts6.TypeFlags.Null);
5081
+ const hasNull = allTypes.some((t) => t.flags & ts5.TypeFlags.Null);
4868
5082
  const memberDisplayNames = /* @__PURE__ */ new Map();
4869
5083
  if (namedDecl) {
4870
5084
  for (const [value, label] of extractDisplayNameMetadata(namedDecl).memberDisplayNames) {
@@ -4884,7 +5098,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4884
5098
  if (existing !== void 0 && existing.type !== RESOLVING_TYPE_PLACEHOLDER) {
4885
5099
  return { kind: "reference", name: typeName, typeArguments: [] };
4886
5100
  }
4887
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5101
+ const annotations = namedDecl ? extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) : void 0;
4888
5102
  const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
4889
5103
  metadataPolicy,
4890
5104
  "type",
@@ -4911,7 +5125,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4911
5125
  const displayName = memberDisplayNames.get(String(value));
4912
5126
  return displayName !== void 0 ? { value, displayName } : { value };
4913
5127
  });
4914
- const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts6.TypeFlags.BooleanLiteral);
5128
+ const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts5.TypeFlags.BooleanLiteral);
4915
5129
  if (isBooleanUnion2) {
4916
5130
  const boolNode = { kind: "primitive", primitiveKind: "boolean" };
4917
5131
  const result = hasNull ? {
@@ -5003,7 +5217,7 @@ function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metad
5003
5217
  if (type.getProperties().length > 0) {
5004
5218
  return null;
5005
5219
  }
5006
- const indexInfo = checker.getIndexInfoOfType(type, ts6.IndexKind.String);
5220
+ const indexInfo = checker.getIndexInfoOfType(type, ts5.IndexKind.String);
5007
5221
  if (!indexInfo) {
5008
5222
  return null;
5009
5223
  }
@@ -5051,20 +5265,53 @@ function shouldEmitResolvedObjectProperty(property, declaration) {
5051
5265
  }
5052
5266
  if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
5053
5267
  const name = declaration.name;
5054
- if (ts6.isComputedPropertyName(name) || ts6.isPrivateIdentifier(name)) {
5268
+ if (ts5.isComputedPropertyName(name) || ts5.isPrivateIdentifier(name)) {
5055
5269
  return false;
5056
5270
  }
5057
- if (!ts6.isIdentifier(name) && !ts6.isStringLiteral(name) && !ts6.isNumericLiteral(name)) {
5271
+ if (!ts5.isIdentifier(name) && !ts5.isStringLiteral(name) && !ts5.isNumericLiteral(name)) {
5058
5272
  return false;
5059
5273
  }
5060
5274
  }
5061
5275
  return true;
5062
5276
  }
5277
+ function getPassThroughTypeAliasFromSourceNode(sourceNode, checker, extensionRegistry, resolvedTypeName) {
5278
+ const aliasDecl = getReferencedTypeAliasDeclaration(sourceNode, checker);
5279
+ if (!aliasDecl) return void 0;
5280
+ const aliasName = aliasDecl.name.text;
5281
+ if (aliasName === resolvedTypeName) return void 0;
5282
+ if (!ts5.isTypeReferenceNode(aliasDecl.type)) return void 0;
5283
+ if (!hasInheritableTypeAnnotation(aliasDecl, checker, extensionRegistry)) {
5284
+ return void 0;
5285
+ }
5286
+ return { aliasName, aliasDecl };
5287
+ }
5288
+ function hasInheritableTypeAnnotation(aliasDecl, checker, extensionRegistry) {
5289
+ const file = aliasDecl.getSourceFile().fileName;
5290
+ const local = extractJSDocAnnotationNodes(aliasDecl, file, makeParseOptions(extensionRegistry));
5291
+ for (const annotation of local) {
5292
+ if (!INHERITABLE_TYPE_ANNOTATION_KINDS.has(annotation.annotationKind)) continue;
5293
+ if (!isOverridingInheritableAnnotation(annotation)) continue;
5294
+ return true;
5295
+ }
5296
+ const inherited = collectInheritedTypeAnnotations(aliasDecl, local, checker, extensionRegistry);
5297
+ for (const annotation of inherited) {
5298
+ if (INHERITABLE_TYPE_ANNOTATION_KINDS.has(annotation.annotationKind)) return true;
5299
+ }
5300
+ return false;
5301
+ }
5063
5302
  function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
5064
5303
  const collectedDiagnostics = diagnostics ?? [];
5065
5304
  const typeName = getNamedTypeName(type);
5066
5305
  const namedTypeName = typeName ?? void 0;
5067
5306
  const namedDecl = getNamedTypeDeclaration(type);
5307
+ const passThroughAlias = getPassThroughTypeAliasFromSourceNode(
5308
+ sourceNode,
5309
+ checker,
5310
+ extensionRegistry,
5311
+ namedTypeName
5312
+ );
5313
+ const effectiveTypeName = passThroughAlias?.aliasName ?? namedTypeName;
5314
+ const effectiveNamedDecl = passThroughAlias?.aliasDecl ?? namedDecl;
5068
5315
  const referenceTypeArguments = extractReferenceTypeArguments(
5069
5316
  type,
5070
5317
  checker,
@@ -5076,13 +5323,13 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5076
5323
  extensionRegistry,
5077
5324
  collectedDiagnostics
5078
5325
  );
5079
- const instantiatedTypeName = namedTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
5080
- namedTypeName,
5326
+ const instantiatedTypeName = effectiveTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
5327
+ effectiveTypeName,
5081
5328
  referenceTypeArguments.map((argument) => argument.tsType),
5082
5329
  checker
5083
5330
  ) : void 0;
5084
- const registryTypeName = instantiatedTypeName ?? namedTypeName;
5085
- const shouldRegisterNamedType = registryTypeName !== void 0 && !(registryTypeName === "Record" && namedDecl?.getSourceFile().fileName !== file);
5331
+ const registryTypeName = instantiatedTypeName ?? effectiveTypeName;
5332
+ const shouldRegisterNamedType = registryTypeName !== void 0 && !(registryTypeName === "Record" && effectiveNamedDecl?.getSourceFile().fileName !== file);
5086
5333
  const clearNamedTypeRegistration = () => {
5087
5334
  if (registryTypeName === void 0 || !shouldRegisterNamedType) {
5088
5335
  return;
@@ -5103,7 +5350,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5103
5350
  typeRegistry[registryTypeName] = {
5104
5351
  name: registryTypeName,
5105
5352
  type: RESOLVING_TYPE_PLACEHOLDER,
5106
- provenance: provenanceForDeclaration(namedDecl, file)
5353
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
5107
5354
  };
5108
5355
  }
5109
5356
  visiting.add(type);
@@ -5135,17 +5382,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5135
5382
  clearNamedTypeRegistration();
5136
5383
  return recordNode;
5137
5384
  }
5138
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5139
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
5385
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
5386
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
5140
5387
  metadataPolicy,
5141
5388
  "type",
5142
5389
  registryTypeName,
5143
- namedDecl,
5390
+ effectiveNamedDecl,
5144
5391
  checker,
5145
5392
  extensionRegistry,
5146
5393
  {
5147
5394
  checker,
5148
- declaration: namedDecl,
5395
+ declaration: effectiveNamedDecl,
5149
5396
  subjectType: type
5150
5397
  }
5151
5398
  ) : void 0;
@@ -5154,7 +5401,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5154
5401
  ...metadata !== void 0 && { metadata },
5155
5402
  type: recordNode,
5156
5403
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
5157
- provenance: provenanceForDeclaration(namedDecl, file)
5404
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
5158
5405
  };
5159
5406
  return {
5160
5407
  kind: "reference",
@@ -5180,7 +5427,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5180
5427
  if (!declaration) continue;
5181
5428
  if (!shouldEmitResolvedObjectProperty(prop, declaration)) continue;
5182
5429
  const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);
5183
- const optional = !!(prop.flags & ts6.SymbolFlags.Optional);
5430
+ const optional = !!(prop.flags & ts5.SymbolFlags.Optional);
5184
5431
  const propTypeNode = resolveTypeNode(
5185
5432
  propType,
5186
5433
  checker,
@@ -5193,7 +5440,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5193
5440
  collectedDiagnostics
5194
5441
  );
5195
5442
  const fieldNodeInfo = fieldInfoMap?.get(prop.name);
5196
- const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts6.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
5443
+ const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts5.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
5197
5444
  declaration,
5198
5445
  checker,
5199
5446
  file,
@@ -5203,7 +5450,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5203
5450
  type,
5204
5451
  metadataPolicy,
5205
5452
  extensionRegistry
5206
- ) : ts6.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
5453
+ ) : ts5.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
5207
5454
  declaration,
5208
5455
  checker,
5209
5456
  file,
@@ -5231,9 +5478,9 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5231
5478
  visiting.delete(type);
5232
5479
  const objectNode = {
5233
5480
  kind: "object",
5234
- properties: namedDecl !== void 0 && (ts6.isClassDeclaration(namedDecl) || ts6.isInterfaceDeclaration(namedDecl) || ts6.isTypeAliasDeclaration(namedDecl)) ? applyDiscriminatorToObjectProperties(
5481
+ properties: effectiveNamedDecl !== void 0 && (ts5.isClassDeclaration(effectiveNamedDecl) || ts5.isInterfaceDeclaration(effectiveNamedDecl) || ts5.isTypeAliasDeclaration(effectiveNamedDecl)) ? applyDiscriminatorToObjectProperties(
5235
5482
  properties,
5236
- namedDecl,
5483
+ effectiveNamedDecl,
5237
5484
  type,
5238
5485
  checker,
5239
5486
  file,
@@ -5243,17 +5490,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5243
5490
  additionalProperties: true
5244
5491
  };
5245
5492
  if (registryTypeName !== void 0 && shouldRegisterNamedType) {
5246
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
5247
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
5493
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
5494
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
5248
5495
  metadataPolicy,
5249
5496
  "type",
5250
5497
  registryTypeName,
5251
- namedDecl,
5498
+ effectiveNamedDecl,
5252
5499
  checker,
5253
5500
  extensionRegistry,
5254
5501
  {
5255
5502
  checker,
5256
- declaration: namedDecl,
5503
+ declaration: effectiveNamedDecl,
5257
5504
  subjectType: type
5258
5505
  }
5259
5506
  ) : void 0;
@@ -5262,7 +5509,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
5262
5509
  ...metadata !== void 0 && { metadata },
5263
5510
  type: objectNode,
5264
5511
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
5265
- provenance: provenanceForDeclaration(namedDecl, file)
5512
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
5266
5513
  };
5267
5514
  return {
5268
5515
  kind: "reference",
@@ -5279,12 +5526,12 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5279
5526
  for (const symbol of symbols) {
5280
5527
  const declarations = symbol.declarations;
5281
5528
  if (!declarations) continue;
5282
- const classDecl = declarations.find(ts6.isClassDeclaration);
5529
+ const classDecl = declarations.find(ts5.isClassDeclaration);
5283
5530
  if (classDecl) {
5284
5531
  const map = /* @__PURE__ */ new Map();
5285
5532
  const hostType = checker.getTypeAtLocation(classDecl);
5286
5533
  for (const member of classDecl.members) {
5287
- if (ts6.isPropertyDeclaration(member) && ts6.isIdentifier(member.name)) {
5534
+ if (ts5.isPropertyDeclaration(member) && ts5.isIdentifier(member.name)) {
5288
5535
  const fieldNode = analyzeFieldToIR(
5289
5536
  member,
5290
5537
  checker,
@@ -5308,7 +5555,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5308
5555
  }
5309
5556
  return map;
5310
5557
  }
5311
- const interfaceDecl = declarations.find(ts6.isInterfaceDeclaration);
5558
+ const interfaceDecl = declarations.find(ts5.isInterfaceDeclaration);
5312
5559
  if (interfaceDecl) {
5313
5560
  return buildFieldNodeInfoMap(
5314
5561
  interfaceDecl.members,
@@ -5322,7 +5569,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5322
5569
  extensionRegistry
5323
5570
  );
5324
5571
  }
5325
- const typeAliasDecl = declarations.find(ts6.isTypeAliasDeclaration);
5572
+ const typeAliasDecl = declarations.find(ts5.isTypeAliasDeclaration);
5326
5573
  const typeAliasMembers = typeAliasDecl === void 0 ? null : getObjectLikeTypeAliasMembers(typeAliasDecl.type);
5327
5574
  if (typeAliasDecl && typeAliasMembers !== null) {
5328
5575
  return buildFieldNodeInfoMap(
@@ -5346,10 +5593,10 @@ function extractArrayElementTypeNode(sourceNode, checker) {
5346
5593
  return void 0;
5347
5594
  }
5348
5595
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
5349
- if (ts6.isArrayTypeNode(resolvedTypeNode)) {
5596
+ if (ts5.isArrayTypeNode(resolvedTypeNode)) {
5350
5597
  return resolvedTypeNode.elementType;
5351
5598
  }
5352
- if (ts6.isTypeReferenceNode(resolvedTypeNode) && ts6.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
5599
+ if (ts5.isTypeReferenceNode(resolvedTypeNode) && ts5.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
5353
5600
  return resolvedTypeNode.typeArguments[0];
5354
5601
  }
5355
5602
  return void 0;
@@ -5360,13 +5607,13 @@ function extractUnionMemberTypeNodes(sourceNode, checker) {
5360
5607
  return [];
5361
5608
  }
5362
5609
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
5363
- return ts6.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
5610
+ return ts5.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
5364
5611
  }
5365
5612
  function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new Set()) {
5366
- if (ts6.isParenthesizedTypeNode(typeNode)) {
5613
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
5367
5614
  return resolveAliasedTypeNode(typeNode.type, checker, visited);
5368
5615
  }
5369
- if (!ts6.isTypeReferenceNode(typeNode) || !ts6.isIdentifier(typeNode.typeName)) {
5616
+ if (!ts5.isTypeReferenceNode(typeNode) || !ts5.isIdentifier(typeNode.typeName)) {
5370
5617
  return typeNode;
5371
5618
  }
5372
5619
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -5377,15 +5624,15 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
5377
5624
  return resolveAliasedTypeNode(aliasDecl.type, checker, visited);
5378
5625
  }
5379
5626
  function isNullishTypeNode(typeNode) {
5380
- if (typeNode.kind === ts6.SyntaxKind.NullKeyword || typeNode.kind === ts6.SyntaxKind.UndefinedKeyword) {
5627
+ if (typeNode.kind === ts5.SyntaxKind.NullKeyword || typeNode.kind === ts5.SyntaxKind.UndefinedKeyword) {
5381
5628
  return true;
5382
5629
  }
5383
- return ts6.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts6.SyntaxKind.NullKeyword || typeNode.literal.kind === ts6.SyntaxKind.UndefinedKeyword);
5630
+ return ts5.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts5.SyntaxKind.NullKeyword || typeNode.literal.kind === ts5.SyntaxKind.UndefinedKeyword);
5384
5631
  }
5385
5632
  function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, metadataPolicy, hostType, diagnostics, extensionRegistry) {
5386
5633
  const map = /* @__PURE__ */ new Map();
5387
5634
  for (const member of members) {
5388
- if (ts6.isPropertySignature(member)) {
5635
+ if (ts5.isPropertySignature(member)) {
5389
5636
  const fieldNode = analyzeInterfacePropertyToIR(
5390
5637
  member,
5391
5638
  checker,
@@ -5410,7 +5657,7 @@ function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, m
5410
5657
  return map;
5411
5658
  }
5412
5659
  function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegistry, depth = 0) {
5413
- if (!ts6.isTypeReferenceNode(typeNode)) return [];
5660
+ if (!ts5.isTypeReferenceNode(typeNode)) return [];
5414
5661
  if (depth >= MAX_ALIAS_CHAIN_DEPTH) {
5415
5662
  const aliasName = typeNode.typeName.getText();
5416
5663
  throw new Error(
@@ -5419,7 +5666,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
5419
5666
  }
5420
5667
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
5421
5668
  if (!aliasDecl) return [];
5422
- if (ts6.isTypeLiteralNode(aliasDecl.type)) return [];
5669
+ if (ts5.isTypeLiteralNode(aliasDecl.type)) return [];
5423
5670
  const aliasFieldType = resolveTypeNode(
5424
5671
  checker.getTypeAtLocation(aliasDecl.type),
5425
5672
  checker,
@@ -5463,14 +5710,14 @@ function getNamedTypeName(type) {
5463
5710
  const symbol = type.getSymbol();
5464
5711
  if (symbol?.declarations) {
5465
5712
  const decl = symbol.declarations[0];
5466
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
5467
- const name = ts6.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
5713
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
5714
+ const name = ts5.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
5468
5715
  if (name) return name;
5469
5716
  }
5470
5717
  }
5471
5718
  const aliasSymbol = type.aliasSymbol;
5472
5719
  if (aliasSymbol?.declarations) {
5473
- const aliasDecl = aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
5720
+ const aliasDecl = aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
5474
5721
  if (aliasDecl) {
5475
5722
  return aliasDecl.name.text;
5476
5723
  }
@@ -5481,24 +5728,24 @@ function getNamedTypeDeclaration(type) {
5481
5728
  const symbol = type.getSymbol();
5482
5729
  if (symbol?.declarations) {
5483
5730
  const decl = symbol.declarations[0];
5484
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
5731
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
5485
5732
  return decl;
5486
5733
  }
5487
5734
  }
5488
5735
  const aliasSymbol = type.aliasSymbol;
5489
5736
  if (aliasSymbol?.declarations) {
5490
- return aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
5737
+ return aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
5491
5738
  }
5492
5739
  return void 0;
5493
5740
  }
5494
5741
  function analyzeMethod(method, checker) {
5495
- if (!ts6.isIdentifier(method.name)) {
5742
+ if (!ts5.isIdentifier(method.name)) {
5496
5743
  return null;
5497
5744
  }
5498
5745
  const name = method.name.text;
5499
5746
  const parameters = [];
5500
5747
  for (const param of method.parameters) {
5501
- if (ts6.isIdentifier(param.name)) {
5748
+ if (ts5.isIdentifier(param.name)) {
5502
5749
  const paramInfo = analyzeParameter(param, checker);
5503
5750
  parameters.push(paramInfo);
5504
5751
  }
@@ -5509,7 +5756,7 @@ function analyzeMethod(method, checker) {
5509
5756
  return { name, parameters, returnTypeNode, returnType };
5510
5757
  }
5511
5758
  function analyzeParameter(param, checker) {
5512
- const name = ts6.isIdentifier(param.name) ? param.name.text : "param";
5759
+ const name = ts5.isIdentifier(param.name) ? param.name.text : "param";
5513
5760
  const typeNode = param.type;
5514
5761
  const type = checker.getTypeAtLocation(param);
5515
5762
  const formSpecExportName = detectFormSpecReference(typeNode);
@@ -5518,25 +5765,25 @@ function analyzeParameter(param, checker) {
5518
5765
  }
5519
5766
  function detectFormSpecReference(typeNode) {
5520
5767
  if (!typeNode) return null;
5521
- if (!ts6.isTypeReferenceNode(typeNode)) return null;
5522
- const typeName = ts6.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts6.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
5768
+ if (!ts5.isTypeReferenceNode(typeNode)) return null;
5769
+ const typeName = ts5.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts5.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
5523
5770
  if (typeName !== "InferSchema" && typeName !== "InferFormSchema") return null;
5524
5771
  const typeArg = typeNode.typeArguments?.[0];
5525
- if (!typeArg || !ts6.isTypeQueryNode(typeArg)) return null;
5526
- if (ts6.isIdentifier(typeArg.exprName)) {
5772
+ if (!typeArg || !ts5.isTypeQueryNode(typeArg)) return null;
5773
+ if (ts5.isIdentifier(typeArg.exprName)) {
5527
5774
  return typeArg.exprName.text;
5528
5775
  }
5529
- if (ts6.isQualifiedName(typeArg.exprName)) {
5776
+ if (ts5.isQualifiedName(typeArg.exprName)) {
5530
5777
  return typeArg.exprName.right.text;
5531
5778
  }
5532
5779
  return null;
5533
5780
  }
5534
- var ts6, import_internal5, RESOLVING_TYPE_PLACEHOLDER, MAX_ALIAS_CHAIN_DEPTH;
5781
+ var ts5, import_internal6, RESOLVING_TYPE_PLACEHOLDER, DEDUPLICATABLE_DIAGNOSTIC_CODES, INHERITABLE_TYPE_ANNOTATION_KINDS, MAX_ALIAS_CHAIN_DEPTH;
5535
5782
  var init_class_analyzer = __esm({
5536
5783
  "src/analyzer/class-analyzer.ts"() {
5537
5784
  "use strict";
5538
- ts6 = __toESM(require("typescript"), 1);
5539
- import_internal5 = require("@formspec/analysis/internal");
5785
+ ts5 = __toESM(require("typescript"), 1);
5786
+ import_internal6 = require("@formspec/analysis/internal");
5540
5787
  init_jsdoc_constraints();
5541
5788
  init_tsdoc_parser();
5542
5789
  init_resolve_custom_type();
@@ -5548,6 +5795,11 @@ var init_class_analyzer = __esm({
5548
5795
  properties: [],
5549
5796
  additionalProperties: true
5550
5797
  };
5798
+ DEDUPLICATABLE_DIAGNOSTIC_CODES = /* @__PURE__ */ new Set([
5799
+ "SYNTHETIC_SETUP_FAILURE",
5800
+ "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE"
5801
+ ]);
5802
+ INHERITABLE_TYPE_ANNOTATION_KINDS = /* @__PURE__ */ new Set(["format"]);
5551
5803
  MAX_ALIAS_CHAIN_DEPTH = 8;
5552
5804
  }
5553
5805
  });
@@ -5568,23 +5820,23 @@ function createProgramContextFromProgram(program, filePath) {
5568
5820
  function createProgramContext(filePath, additionalFiles) {
5569
5821
  const absolutePath = path.resolve(filePath);
5570
5822
  const fileDir = path.dirname(absolutePath);
5571
- const configPath = ts7.findConfigFile(fileDir, ts7.sys.fileExists.bind(ts7.sys), "tsconfig.json");
5823
+ const configPath = ts6.findConfigFile(fileDir, ts6.sys.fileExists.bind(ts6.sys), "tsconfig.json");
5572
5824
  let compilerOptions;
5573
5825
  let fileNames;
5574
5826
  if (configPath) {
5575
- const configFile = ts7.readConfigFile(configPath, ts7.sys.readFile.bind(ts7.sys));
5827
+ const configFile = ts6.readConfigFile(configPath, ts6.sys.readFile.bind(ts6.sys));
5576
5828
  if (configFile.error) {
5577
5829
  throw new Error(
5578
- `Error reading tsconfig.json: ${ts7.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
5830
+ `Error reading tsconfig.json: ${ts6.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
5579
5831
  );
5580
5832
  }
5581
- const parsed = ts7.parseJsonConfigFileContent(
5833
+ const parsed = ts6.parseJsonConfigFileContent(
5582
5834
  configFile.config,
5583
- ts7.sys,
5835
+ ts6.sys,
5584
5836
  path.dirname(configPath)
5585
5837
  );
5586
5838
  if (parsed.errors.length > 0) {
5587
- const errorMessages = parsed.errors.map((e) => ts7.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
5839
+ const errorMessages = parsed.errors.map((e) => ts6.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
5588
5840
  throw new Error(`Error parsing tsconfig.json: ${errorMessages}`);
5589
5841
  }
5590
5842
  compilerOptions = parsed.options;
@@ -5592,9 +5844,9 @@ function createProgramContext(filePath, additionalFiles) {
5592
5844
  fileNames = [.../* @__PURE__ */ new Set([...parsed.fileNames, absolutePath, ...normalizedAdditional])];
5593
5845
  } else {
5594
5846
  compilerOptions = {
5595
- target: ts7.ScriptTarget.ES2022,
5596
- module: ts7.ModuleKind.NodeNext,
5597
- moduleResolution: ts7.ModuleResolutionKind.NodeNext,
5847
+ target: ts6.ScriptTarget.ES2022,
5848
+ module: ts6.ModuleKind.NodeNext,
5849
+ moduleResolution: ts6.ModuleResolutionKind.NodeNext,
5598
5850
  strict: true,
5599
5851
  skipLibCheck: true,
5600
5852
  declaration: true
@@ -5602,7 +5854,7 @@ function createProgramContext(filePath, additionalFiles) {
5602
5854
  const normalizedAdditional = (additionalFiles ?? []).map((f) => path.resolve(f));
5603
5855
  fileNames = [.../* @__PURE__ */ new Set([absolutePath, ...normalizedAdditional])];
5604
5856
  }
5605
- const program = ts7.createProgram(fileNames, compilerOptions);
5857
+ const program = ts6.createProgram(fileNames, compilerOptions);
5606
5858
  const sourceFile = program.getSourceFile(absolutePath);
5607
5859
  if (!sourceFile) {
5608
5860
  throw new Error(`Could not find source file: ${absolutePath}`);
@@ -5621,19 +5873,19 @@ function findNodeByName(sourceFile, name, predicate, getName) {
5621
5873
  result = node;
5622
5874
  return;
5623
5875
  }
5624
- ts7.forEachChild(node, visit);
5876
+ ts6.forEachChild(node, visit);
5625
5877
  }
5626
5878
  visit(sourceFile);
5627
5879
  return result;
5628
5880
  }
5629
5881
  function findClassByName(sourceFile, className) {
5630
- return findNodeByName(sourceFile, className, ts7.isClassDeclaration, (n) => n.name?.text);
5882
+ return findNodeByName(sourceFile, className, ts6.isClassDeclaration, (n) => n.name?.text);
5631
5883
  }
5632
5884
  function findInterfaceByName(sourceFile, interfaceName) {
5633
- return findNodeByName(sourceFile, interfaceName, ts7.isInterfaceDeclaration, (n) => n.name.text);
5885
+ return findNodeByName(sourceFile, interfaceName, ts6.isInterfaceDeclaration, (n) => n.name.text);
5634
5886
  }
5635
5887
  function findTypeAliasByName(sourceFile, aliasName) {
5636
- return findNodeByName(sourceFile, aliasName, ts7.isTypeAliasDeclaration, (n) => n.name.text);
5888
+ return findNodeByName(sourceFile, aliasName, ts6.isTypeAliasDeclaration, (n) => n.name.text);
5637
5889
  }
5638
5890
  function getResolvedObjectRootType(rootType, typeRegistry) {
5639
5891
  if (rootType.kind === "object") {
@@ -5673,22 +5925,22 @@ function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInf
5673
5925
  };
5674
5926
  }
5675
5927
  function containsTypeReferenceInObjectLikeAlias(typeNode) {
5676
- if (ts7.isParenthesizedTypeNode(typeNode)) {
5928
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
5677
5929
  return containsTypeReferenceInObjectLikeAlias(typeNode.type);
5678
5930
  }
5679
- if (ts7.isTypeReferenceNode(typeNode)) {
5931
+ if (ts6.isTypeReferenceNode(typeNode)) {
5680
5932
  return true;
5681
5933
  }
5682
- return ts7.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5934
+ return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5683
5935
  }
5684
5936
  function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5685
- if (ts7.isParenthesizedTypeNode(typeNode)) {
5937
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
5686
5938
  return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
5687
5939
  }
5688
- if (ts7.isTypeLiteralNode(typeNode)) {
5940
+ if (ts6.isTypeLiteralNode(typeNode)) {
5689
5941
  const propertyNames = [];
5690
5942
  for (const member of typeNode.members) {
5691
- if (!ts7.isPropertySignature(member)) {
5943
+ if (!ts6.isPropertySignature(member)) {
5692
5944
  continue;
5693
5945
  }
5694
5946
  const propertyName = getAnalyzableObjectLikePropertyName(member.name);
@@ -5698,13 +5950,13 @@ function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5698
5950
  }
5699
5951
  return propertyNames;
5700
5952
  }
5701
- if (ts7.isTypeReferenceNode(typeNode)) {
5953
+ if (ts6.isTypeReferenceNode(typeNode)) {
5702
5954
  return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
5703
5955
  }
5704
5956
  return null;
5705
5957
  }
5706
5958
  function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
5707
- if (!ts7.isIntersectionTypeNode(typeNode)) {
5959
+ if (!ts6.isIntersectionTypeNode(typeNode)) {
5708
5960
  return [];
5709
5961
  }
5710
5962
  const seen = /* @__PURE__ */ new Set();
@@ -5903,11 +6155,11 @@ function makeFileProvenance(filePath) {
5903
6155
  column: 0
5904
6156
  };
5905
6157
  }
5906
- var ts7, path;
6158
+ var ts6, path;
5907
6159
  var init_program = __esm({
5908
6160
  "src/analyzer/program.ts"() {
5909
6161
  "use strict";
5910
- ts7 = __toESM(require("typescript"), 1);
6162
+ ts6 = __toESM(require("typescript"), 1);
5911
6163
  path = __toESM(require("path"), 1);
5912
6164
  init_class_analyzer();
5913
6165
  }
@@ -5922,10 +6174,10 @@ function buildSymbolMapFromConfig(configPath, program, checker, extensionRegistr
5922
6174
  return symbolMap;
5923
6175
  }
5924
6176
  function visit(node) {
5925
- if (ts8.isCallExpression(node) && isDefineCustomTypeCall(node, checker)) {
6177
+ if (ts7.isCallExpression(node) && isDefineCustomTypeCall(node, checker)) {
5926
6178
  processDefineCustomTypeCall(node);
5927
6179
  }
5928
- ts8.forEachChild(node, visit);
6180
+ ts7.forEachChild(node, visit);
5929
6181
  }
5930
6182
  function processDefineCustomTypeCall(call) {
5931
6183
  const typeArgNode = call.typeArguments?.[0];
@@ -5962,7 +6214,7 @@ function isDefineCustomTypeCall(node, checker) {
5962
6214
  if (node.typeArguments === void 0 || node.typeArguments.length === 0) return false;
5963
6215
  const callSymbol = checker.getSymbolAtLocation(node.expression);
5964
6216
  if (callSymbol !== void 0) {
5965
- const resolved = callSymbol.flags & ts8.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
6217
+ const resolved = callSymbol.flags & ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
5966
6218
  const decl = resolved.declarations?.[0];
5967
6219
  if (decl !== void 0) {
5968
6220
  const sourceFile = decl.getSourceFile().fileName.replace(/\\/g, "/");
@@ -5970,24 +6222,24 @@ function isDefineCustomTypeCall(node, checker) {
5970
6222
  (sourceFile.includes("@formspec/core") || sourceFile.includes("/packages/core/"));
5971
6223
  }
5972
6224
  }
5973
- return ts8.isIdentifier(node.expression) && node.expression.text === "defineCustomType";
6225
+ return ts7.isIdentifier(node.expression) && node.expression.text === "defineCustomType";
5974
6226
  }
5975
6227
  function extractTypeNameFromCallArg(call) {
5976
6228
  const arg = call.arguments[0];
5977
- if (arg === void 0 || !ts8.isObjectLiteralExpression(arg)) {
6229
+ if (arg === void 0 || !ts7.isObjectLiteralExpression(arg)) {
5978
6230
  return null;
5979
6231
  }
5980
6232
  const typeNameProp = arg.properties.find(
5981
- (p) => ts8.isPropertyAssignment(p) && ts8.isIdentifier(p.name) && p.name.text === "typeName"
6233
+ (p) => ts7.isPropertyAssignment(p) && ts7.isIdentifier(p.name) && p.name.text === "typeName"
5982
6234
  );
5983
- if (typeNameProp === void 0 || !ts8.isStringLiteral(typeNameProp.initializer)) {
6235
+ if (typeNameProp === void 0 || !ts7.isStringLiteral(typeNameProp.initializer)) {
5984
6236
  return null;
5985
6237
  }
5986
6238
  return typeNameProp.initializer.text;
5987
6239
  }
5988
6240
  function extractEnclosingExtensionId(call, checker) {
5989
- for (let node = call.parent; !ts8.isSourceFile(node); node = node.parent) {
5990
- if (ts8.isCallExpression(node) && isDefineExtensionCall(node, checker)) {
6241
+ for (let node = call.parent; !ts7.isSourceFile(node); node = node.parent) {
6242
+ if (ts7.isCallExpression(node) && isDefineExtensionCall(node, checker)) {
5991
6243
  return extractExtensionIdFromCallArg(node);
5992
6244
  }
5993
6245
  }
@@ -5996,24 +6248,24 @@ function extractEnclosingExtensionId(call, checker) {
5996
6248
  function isDefineExtensionCall(node, checker) {
5997
6249
  const callSymbol = checker.getSymbolAtLocation(node.expression);
5998
6250
  if (callSymbol !== void 0) {
5999
- const resolved = callSymbol.flags & ts8.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
6251
+ const resolved = callSymbol.flags & ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
6000
6252
  const decl = resolved.declarations?.[0];
6001
6253
  if (decl !== void 0) {
6002
6254
  const sourceFile = decl.getSourceFile().fileName.replace(/\\/g, "/");
6003
6255
  return resolved.name === "defineExtension" && (sourceFile.includes("@formspec/core") || sourceFile.includes("/packages/core/"));
6004
6256
  }
6005
6257
  }
6006
- return ts8.isIdentifier(node.expression) && node.expression.text === "defineExtension";
6258
+ return ts7.isIdentifier(node.expression) && node.expression.text === "defineExtension";
6007
6259
  }
6008
6260
  function extractExtensionIdFromCallArg(call) {
6009
6261
  const arg = call.arguments[0];
6010
- if (arg === void 0 || !ts8.isObjectLiteralExpression(arg)) {
6262
+ if (arg === void 0 || !ts7.isObjectLiteralExpression(arg)) {
6011
6263
  return null;
6012
6264
  }
6013
6265
  const prop = arg.properties.find(
6014
- (p) => ts8.isPropertyAssignment(p) && ts8.isIdentifier(p.name) && p.name.text === "extensionId"
6266
+ (p) => ts7.isPropertyAssignment(p) && ts7.isIdentifier(p.name) && p.name.text === "extensionId"
6015
6267
  );
6016
- if (prop === void 0 || !ts8.isStringLiteral(prop.initializer)) {
6268
+ if (prop === void 0 || !ts7.isStringLiteral(prop.initializer)) {
6017
6269
  return null;
6018
6270
  }
6019
6271
  return prop.initializer.text;
@@ -6031,11 +6283,11 @@ function findRegistrationByTypeName(registry, typeName) {
6031
6283
  }
6032
6284
  return void 0;
6033
6285
  }
6034
- var ts8, path2;
6286
+ var ts7, path2;
6035
6287
  var init_symbol_registry = __esm({
6036
6288
  "src/extensions/symbol-registry.ts"() {
6037
6289
  "use strict";
6038
- ts8 = __toESM(require("typescript"), 1);
6290
+ ts7 = __toESM(require("typescript"), 1);
6039
6291
  path2 = __toESM(require("path"), 1);
6040
6292
  init_ts_type_utils();
6041
6293
  }
@@ -6043,7 +6295,7 @@ var init_symbol_registry = __esm({
6043
6295
 
6044
6296
  // src/validate/constraint-validator.ts
6045
6297
  function validateFieldNode(ctx, field) {
6046
- const analysis = (0, import_internal6.analyzeConstraintTargets)(
6298
+ const analysis = (0, import_internal7.analyzeConstraintTargets)(
6047
6299
  field.name,
6048
6300
  field.type,
6049
6301
  field.constraints,
@@ -6061,7 +6313,7 @@ function validateFieldNode(ctx, field) {
6061
6313
  }
6062
6314
  function validateObjectProperty(ctx, parentName, property) {
6063
6315
  const qualifiedName = `${parentName}.${property.name}`;
6064
- const analysis = (0, import_internal6.analyzeConstraintTargets)(
6316
+ const analysis = (0, import_internal7.analyzeConstraintTargets)(
6065
6317
  qualifiedName,
6066
6318
  property.type,
6067
6319
  property.constraints,
@@ -6112,11 +6364,11 @@ function validateIR(ir, options) {
6112
6364
  valid: ctx.diagnostics.every((diagnostic) => diagnostic.severity !== "error")
6113
6365
  };
6114
6366
  }
6115
- var import_internal6;
6367
+ var import_internal7;
6116
6368
  var init_constraint_validator = __esm({
6117
6369
  "src/validate/constraint-validator.ts"() {
6118
6370
  "use strict";
6119
- import_internal6 = require("@formspec/analysis/internal");
6371
+ import_internal7 = require("@formspec/analysis/internal");
6120
6372
  }
6121
6373
  });
6122
6374
 
@@ -6298,7 +6550,7 @@ function generateSchemasBatch(options) {
6298
6550
  return options.targets.map((target) => {
6299
6551
  let ctx;
6300
6552
  try {
6301
- const cacheKey = ts9.sys.useCaseSensitiveFileNames ? target.filePath : target.filePath.toLowerCase();
6553
+ const cacheKey = ts8.sys.useCaseSensitiveFileNames ? target.filePath : target.filePath.toLowerCase();
6302
6554
  const cachedContext = contextCache.get(cacheKey);
6303
6555
  if (cachedContext === void 0) {
6304
6556
  const additionalFiles = options.configPath !== void 0 ? [options.configPath] : void 0;
@@ -6357,7 +6609,7 @@ function isMutableRegistry(reg) {
6357
6609
  }
6358
6610
  function resolveStaticOptions(options) {
6359
6611
  const legacyRegistry = options.extensionRegistry;
6360
- const configRegistry = legacyRegistry === void 0 && options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6612
+ const configRegistry = legacyRegistry === void 0 && options.config?.extensions !== void 0 && options.config.extensions.length > 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6361
6613
  return {
6362
6614
  extensionRegistry: legacyRegistry ?? configRegistry,
6363
6615
  // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
@@ -6369,7 +6621,7 @@ function resolveStaticOptions(options) {
6369
6621
  };
6370
6622
  }
6371
6623
  function resolveOptions(options) {
6372
- const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6624
+ const configRegistry = options.config?.extensions !== void 0 && options.config.extensions.length > 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6373
6625
  const legacyRegistry = options.extensionRegistry;
6374
6626
  return {
6375
6627
  // When the caller provides the deprecated extensionRegistry field directly,
@@ -6452,11 +6704,11 @@ function createProgramContextFailureDiagnostic(filePath, error) {
6452
6704
  relatedLocations: []
6453
6705
  };
6454
6706
  }
6455
- var ts9;
6707
+ var ts8;
6456
6708
  var init_class_schema = __esm({
6457
6709
  "src/generators/class-schema.ts"() {
6458
6710
  "use strict";
6459
- ts9 = __toESM(require("typescript"), 1);
6711
+ ts8 = __toESM(require("typescript"), 1);
6460
6712
  init_program();
6461
6713
  init_class_analyzer();
6462
6714
  init_canonicalize();
@@ -6483,7 +6735,7 @@ function getModuleSymbol(context) {
6483
6735
  return context.checker.getSymbolAtLocation(context.sourceFile) ?? sourceFileWithSymbol.symbol;
6484
6736
  }
6485
6737
  function isSchemaSourceDeclaration(declaration) {
6486
- return ts10.isClassDeclaration(declaration) || ts10.isInterfaceDeclaration(declaration) || ts10.isTypeAliasDeclaration(declaration);
6738
+ return ts9.isClassDeclaration(declaration) || ts9.isInterfaceDeclaration(declaration) || ts9.isTypeAliasDeclaration(declaration);
6487
6739
  }
6488
6740
  function resolveModuleExport(context, exportName = "default") {
6489
6741
  const moduleSymbol = getModuleSymbol(context);
@@ -6494,16 +6746,16 @@ function resolveModuleExport(context, exportName = "default") {
6494
6746
  if (exportSymbol === null) {
6495
6747
  return null;
6496
6748
  }
6497
- return exportSymbol.flags & ts10.SymbolFlags.Alias ? context.checker.getAliasedSymbol(exportSymbol) : exportSymbol;
6749
+ return exportSymbol.flags & ts9.SymbolFlags.Alias ? context.checker.getAliasedSymbol(exportSymbol) : exportSymbol;
6498
6750
  }
6499
6751
  function resolveModuleExportDeclaration(context, exportName = "default") {
6500
6752
  return resolveModuleExport(context, exportName)?.declarations?.find(isSchemaSourceDeclaration) ?? null;
6501
6753
  }
6502
- var ts10;
6754
+ var ts9;
6503
6755
  var init_static_build = __esm({
6504
6756
  "src/static-build.ts"() {
6505
6757
  "use strict";
6506
- ts10 = __toESM(require("typescript"), 1);
6758
+ ts9 = __toESM(require("typescript"), 1);
6507
6759
  init_program();
6508
6760
  }
6509
6761
  });
@@ -6516,17 +6768,17 @@ function toDiscoveredTypeSchemas(result, resolvedMetadata) {
6516
6768
  };
6517
6769
  }
6518
6770
  function isNamedTypeDeclaration(declaration) {
6519
- return ts11.isClassDeclaration(declaration) || ts11.isInterfaceDeclaration(declaration) || ts11.isTypeAliasDeclaration(declaration);
6771
+ return ts10.isClassDeclaration(declaration) || ts10.isInterfaceDeclaration(declaration) || ts10.isTypeAliasDeclaration(declaration);
6520
6772
  }
6521
6773
  function hasConcreteTypeArguments(type, checker) {
6522
6774
  if ("aliasTypeArguments" in type && Array.isArray(type.aliasTypeArguments) && type.aliasTypeArguments.length > 0) {
6523
6775
  return true;
6524
6776
  }
6525
- if ((type.flags & ts11.TypeFlags.Object) === 0) {
6777
+ if ((type.flags & ts10.TypeFlags.Object) === 0) {
6526
6778
  return false;
6527
6779
  }
6528
6780
  const objectType = type;
6529
- if ((objectType.objectFlags & ts11.ObjectFlags.Reference) === 0) {
6781
+ if ((objectType.objectFlags & ts10.ObjectFlags.Reference) === 0) {
6530
6782
  return false;
6531
6783
  }
6532
6784
  return checker.getTypeArguments(objectType).length > 0;
@@ -6539,13 +6791,13 @@ function getNamedTypeDeclaration2(type) {
6539
6791
  return declaration;
6540
6792
  }
6541
6793
  }
6542
- const aliasDeclaration = type.aliasSymbol?.declarations?.find(ts11.isTypeAliasDeclaration);
6794
+ const aliasDeclaration = type.aliasSymbol?.declarations?.find(ts10.isTypeAliasDeclaration);
6543
6795
  return aliasDeclaration;
6544
6796
  }
6545
6797
  function getFallbackName(sourceNode, fallback = "AnonymousType") {
6546
6798
  if (sourceNode !== void 0 && "name" in sourceNode) {
6547
6799
  const namedNode = sourceNode;
6548
- if (namedNode.name !== void 0 && ts11.isIdentifier(namedNode.name)) {
6800
+ if (namedNode.name !== void 0 && ts10.isIdentifier(namedNode.name)) {
6549
6801
  return namedNode.name.text;
6550
6802
  }
6551
6803
  }
@@ -6767,7 +7019,7 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
6767
7019
  function generateSchemasFromDeclaration(options) {
6768
7020
  const filePath = options.declaration.getSourceFile().fileName;
6769
7021
  const resolved = resolveStaticOptions(options);
6770
- if (ts11.isClassDeclaration(options.declaration)) {
7022
+ if (ts10.isClassDeclaration(options.declaration)) {
6771
7023
  return generateSchemasFromAnalysis(
6772
7024
  analyzeClassToIR(
6773
7025
  options.declaration,
@@ -6781,7 +7033,7 @@ function generateSchemasFromDeclaration(options) {
6781
7033
  resolved
6782
7034
  );
6783
7035
  }
6784
- if (ts11.isInterfaceDeclaration(options.declaration)) {
7036
+ if (ts10.isInterfaceDeclaration(options.declaration)) {
6785
7037
  return generateSchemasFromAnalysis(
6786
7038
  analyzeInterfaceToIR(
6787
7039
  options.declaration,
@@ -6795,7 +7047,7 @@ function generateSchemasFromDeclaration(options) {
6795
7047
  resolved
6796
7048
  );
6797
7049
  }
6798
- if (ts11.isTypeAliasDeclaration(options.declaration)) {
7050
+ if (ts10.isTypeAliasDeclaration(options.declaration)) {
6799
7051
  const analyzedAlias = analyzeTypeAliasToIR(
6800
7052
  options.declaration,
6801
7053
  options.context.checker,
@@ -6854,7 +7106,7 @@ function generateSchemasFromReturnType(options) {
6854
7106
  const returnType = signature !== void 0 ? options.context.checker.getReturnTypeOfSignature(signature) : options.context.checker.getTypeAtLocation(options.declaration);
6855
7107
  const type = unwrapPromiseType(options.context.checker, returnType);
6856
7108
  const sourceNode = type !== returnType ? unwrapPromiseTypeNode(options.declaration.type) ?? options.declaration.type ?? options.declaration : options.declaration.type ?? options.declaration;
6857
- const fallbackName = options.declaration.name !== void 0 && ts11.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
7109
+ const fallbackName = options.declaration.name !== void 0 && ts10.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
6858
7110
  return generateSchemasFromResolvedType({
6859
7111
  ...options,
6860
7112
  type,
@@ -6864,7 +7116,7 @@ function generateSchemasFromReturnType(options) {
6864
7116
  }
6865
7117
  function resolveDeclarationMetadata(options) {
6866
7118
  const resolved = resolveStaticOptions(options);
6867
- const analysis = (0, import_internal7.analyzeMetadataForNodeWithChecker)({
7119
+ const analysis = (0, import_internal8.analyzeMetadataForNodeWithChecker)({
6868
7120
  checker: options.context.checker,
6869
7121
  node: options.declaration,
6870
7122
  metadata: resolved.metadata,
@@ -6901,21 +7153,21 @@ function unwrapPromiseTypeNode(typeNode) {
6901
7153
  if (typeNode === void 0) {
6902
7154
  return void 0;
6903
7155
  }
6904
- if (ts11.isParenthesizedTypeNode(typeNode)) {
7156
+ if (ts10.isParenthesizedTypeNode(typeNode)) {
6905
7157
  const unwrapped = unwrapPromiseTypeNode(typeNode.type);
6906
7158
  return unwrapped ?? typeNode;
6907
7159
  }
6908
7160
  return isPromiseTypeReferenceNode(typeNode) ? typeNode.typeArguments[0] : typeNode;
6909
7161
  }
6910
7162
  function isPromiseTypeReferenceNode(typeNode) {
6911
- return ts11.isTypeReferenceNode(typeNode) && ts11.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
7163
+ return ts10.isTypeReferenceNode(typeNode) && ts10.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
6912
7164
  }
6913
- var ts11, import_internal7, import_internals6;
7165
+ var ts10, import_internal8, import_internals6;
6914
7166
  var init_discovered_schema = __esm({
6915
7167
  "src/generators/discovered-schema.ts"() {
6916
7168
  "use strict";
6917
- ts11 = __toESM(require("typescript"), 1);
6918
- import_internal7 = require("@formspec/analysis/internal");
7169
+ ts10 = __toESM(require("typescript"), 1);
7170
+ import_internal8 = require("@formspec/analysis/internal");
6919
7171
  init_class_analyzer();
6920
7172
  init_class_schema();
6921
7173
  init_ir_generator();