@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.
@@ -847,19 +847,19 @@ function wrapInConditional(field, layout, provenance) {
847
847
  }
848
848
 
849
849
  // src/analyzer/program.ts
850
- var ts7 = __toESM(require("typescript"), 1);
850
+ var ts6 = __toESM(require("typescript"), 1);
851
851
  var path = __toESM(require("path"), 1);
852
852
 
853
853
  // src/analyzer/class-analyzer.ts
854
- var ts6 = __toESM(require("typescript"), 1);
855
- var import_internal4 = require("@formspec/analysis/internal");
854
+ var ts5 = __toESM(require("typescript"), 1);
855
+ var import_internal5 = require("@formspec/analysis/internal");
856
856
 
857
857
  // src/analyzer/jsdoc-constraints.ts
858
- var ts5 = __toESM(require("typescript"), 1);
858
+ var ts4 = __toESM(require("typescript"), 1);
859
859
 
860
860
  // src/analyzer/tsdoc-parser.ts
861
- var ts4 = __toESM(require("typescript"), 1);
862
- var import_internal2 = require("@formspec/analysis/internal");
861
+ var ts3 = __toESM(require("typescript"), 1);
862
+ var import_internal3 = require("@formspec/analysis/internal");
863
863
  var import_internals3 = require("@formspec/core/internals");
864
864
  var import_internals4 = require("@formspec/core/internals");
865
865
  var import_core = require("@formspec/core");
@@ -870,21 +870,6 @@ var import_internal = require("@formspec/analysis/internal");
870
870
 
871
871
  // src/extensions/ts-type-utils.ts
872
872
  var ts = __toESM(require("typescript"), 1);
873
- function collectBrandIdentifiers(type) {
874
- if (!type.isIntersection()) {
875
- return [];
876
- }
877
- const brands = [];
878
- for (const prop of type.getProperties()) {
879
- const decl = prop.valueDeclaration ?? prop.declarations?.[0];
880
- if (decl === void 0) continue;
881
- if (!ts.isPropertySignature(decl) && !ts.isPropertyDeclaration(decl)) continue;
882
- if (!ts.isComputedPropertyName(decl.name)) continue;
883
- if (!ts.isIdentifier(decl.name.expression)) continue;
884
- brands.push(decl.name.expression.text);
885
- }
886
- return brands;
887
- }
888
873
  function resolveCanonicalSymbol(type, checker) {
889
874
  const raw = type.aliasSymbol ?? type.getSymbol();
890
875
  if (raw === void 0) return void 0;
@@ -969,7 +954,7 @@ function resolveCustomTypeFromTsType(type, checker, registry, sourceNode) {
969
954
  return bySymbol;
970
955
  }
971
956
  }
972
- for (const brand of collectBrandIdentifiers(stripped)) {
957
+ for (const brand of (0, import_internal._collectBrandIdentifiers)(stripped)) {
973
958
  const byBrand = registry.findTypeByBrand(brand);
974
959
  if (byBrand !== void 0) {
975
960
  return byBrand;
@@ -982,22 +967,17 @@ function customTypeIdFromLookup(result) {
982
967
  }
983
968
 
984
969
  // src/analyzer/builtin-brands.ts
985
- var ts3 = __toESM(require("typescript"), 1);
986
- function isIntegerBrandedType(type) {
987
- if (!type.isIntersection()) return false;
988
- if (!type.types.some((member) => !!(member.flags & ts3.TypeFlags.Number))) return false;
989
- return collectBrandIdentifiers(type).includes("__integerBrand");
990
- }
970
+ var import_internal2 = require("@formspec/analysis/internal");
991
971
 
992
972
  // src/analyzer/tsdoc-parser.ts
993
- var import_internal3 = require("@formspec/analysis/internal");
973
+ var import_internal4 = require("@formspec/analysis/internal");
994
974
  function sharedTagValueOptions(options) {
995
975
  return {
996
976
  ...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
997
977
  ...options?.fieldType !== void 0 ? { fieldType: options.fieldType } : {}
998
978
  };
999
979
  }
1000
- var SYNTHETIC_TYPE_FORMAT_FLAGS = ts4.TypeFormatFlags.NoTruncation | ts4.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
980
+ var SYNTHETIC_TYPE_FORMAT_FLAGS = ts3.TypeFormatFlags.NoTruncation | ts3.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
1001
981
  function getExtensionTypeNames(registry) {
1002
982
  if (registry === void 0) {
1003
983
  return /* @__PURE__ */ new Set();
@@ -1011,23 +991,23 @@ function getExtensionTypeNames(registry) {
1011
991
  function collectImportedNames(sourceFile) {
1012
992
  const importedNames = /* @__PURE__ */ new Set();
1013
993
  for (const statement of sourceFile.statements) {
1014
- if (ts4.isImportDeclaration(statement) && statement.importClause !== void 0) {
994
+ if (ts3.isImportDeclaration(statement) && statement.importClause !== void 0) {
1015
995
  const clause = statement.importClause;
1016
996
  if (clause.name !== void 0) {
1017
997
  importedNames.add(clause.name.text);
1018
998
  }
1019
999
  if (clause.namedBindings !== void 0) {
1020
- if (ts4.isNamedImports(clause.namedBindings)) {
1000
+ if (ts3.isNamedImports(clause.namedBindings)) {
1021
1001
  for (const specifier of clause.namedBindings.elements) {
1022
1002
  importedNames.add(specifier.name.text);
1023
1003
  }
1024
- } else if (ts4.isNamespaceImport(clause.namedBindings)) {
1004
+ } else if (ts3.isNamespaceImport(clause.namedBindings)) {
1025
1005
  importedNames.add(clause.namedBindings.name.text);
1026
1006
  }
1027
1007
  }
1028
1008
  continue;
1029
1009
  }
1030
- if (ts4.isImportEqualsDeclaration(statement)) {
1010
+ if (ts3.isImportEqualsDeclaration(statement)) {
1031
1011
  importedNames.add(statement.name.text);
1032
1012
  }
1033
1013
  }
@@ -1035,13 +1015,13 @@ function collectImportedNames(sourceFile) {
1035
1015
  }
1036
1016
  function isNonReferenceIdentifier(node) {
1037
1017
  const parent = node.parent;
1038
- 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) {
1018
+ 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) {
1039
1019
  return true;
1040
1020
  }
1041
- if ((ts4.isPropertyAssignment(parent) || ts4.isPropertyAccessExpression(parent)) && parent.name === node) {
1021
+ if ((ts3.isPropertyAssignment(parent) || ts3.isPropertyAccessExpression(parent)) && parent.name === node) {
1042
1022
  return true;
1043
1023
  }
1044
- if (ts4.isQualifiedName(parent) && parent.right === node) {
1024
+ if (ts3.isQualifiedName(parent) && parent.right === node) {
1045
1025
  return true;
1046
1026
  }
1047
1027
  return false;
@@ -1053,20 +1033,20 @@ function astReferencesImportedName(root, importedNames) {
1053
1033
  let found = false;
1054
1034
  const visit = (node) => {
1055
1035
  if (found) return;
1056
- if (ts4.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
1036
+ if (ts3.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
1057
1037
  found = true;
1058
1038
  return;
1059
1039
  }
1060
- ts4.forEachChild(node, visit);
1040
+ ts3.forEachChild(node, visit);
1061
1041
  };
1062
1042
  visit(root);
1063
1043
  return found;
1064
1044
  }
1065
1045
  function getObjectMembers(statement) {
1066
- if (ts4.isInterfaceDeclaration(statement)) {
1046
+ if (ts3.isInterfaceDeclaration(statement)) {
1067
1047
  return statement.members;
1068
1048
  }
1069
- if (ts4.isTypeLiteralNode(statement.type)) {
1049
+ if (ts3.isTypeLiteralNode(statement.type)) {
1070
1050
  return statement.type.members;
1071
1051
  }
1072
1052
  return void 0;
@@ -1078,7 +1058,7 @@ function rewriteImportedMemberTypes(statement, sourceFile, importedNames) {
1078
1058
  }
1079
1059
  const replacements = [];
1080
1060
  for (const member of members) {
1081
- if (!ts4.isPropertySignature(member)) {
1061
+ if (!ts3.isPropertySignature(member)) {
1082
1062
  if (astReferencesImportedName(member, importedNames)) {
1083
1063
  return null;
1084
1064
  }
@@ -1110,14 +1090,14 @@ function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
1110
1090
  );
1111
1091
  const result = [];
1112
1092
  for (const statement of sourceFile.statements) {
1113
- if (ts4.isImportDeclaration(statement)) continue;
1114
- if (ts4.isImportEqualsDeclaration(statement)) continue;
1115
- if (ts4.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
1093
+ if (ts3.isImportDeclaration(statement)) continue;
1094
+ if (ts3.isImportEqualsDeclaration(statement)) continue;
1095
+ if (ts3.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0) continue;
1116
1096
  if (!astReferencesImportedName(statement, importedNamesToSkip)) {
1117
1097
  result.push(statement.getText(sourceFile));
1118
1098
  continue;
1119
1099
  }
1120
- if (ts4.isInterfaceDeclaration(statement) || ts4.isTypeAliasDeclaration(statement)) {
1100
+ if (ts3.isInterfaceDeclaration(statement) || ts3.isTypeAliasDeclaration(statement)) {
1121
1101
  const rewritten = rewriteImportedMemberTypes(statement, sourceFile, importedNamesToSkip);
1122
1102
  if (rewritten !== null) {
1123
1103
  result.push(rewritten);
@@ -1151,7 +1131,7 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
1151
1131
  pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
1152
1132
  return;
1153
1133
  }
1154
- const constraintNode = (0, import_internal2.parseConstraintTagValue)(
1134
+ const constraintNode = (0, import_internal3.parseConstraintTagValue)(
1155
1135
  tagName,
1156
1136
  text,
1157
1137
  provenance,
@@ -1204,12 +1184,12 @@ function supportsConstraintCapability(type, checker, capability) {
1204
1184
  if (capability === void 0) {
1205
1185
  return true;
1206
1186
  }
1207
- if ((0, import_internal2.hasTypeSemanticCapability)(type, checker, capability)) {
1187
+ if ((0, import_internal3.hasTypeSemanticCapability)(type, checker, capability)) {
1208
1188
  return true;
1209
1189
  }
1210
1190
  if (capability === "string-like") {
1211
1191
  const itemType = getArrayElementType(type, checker);
1212
- return itemType !== null && (0, import_internal2.hasTypeSemanticCapability)(itemType, checker, capability);
1192
+ return itemType !== null && (0, import_internal3.hasTypeSemanticCapability)(itemType, checker, capability);
1213
1193
  }
1214
1194
  return false;
1215
1195
  }
@@ -1220,7 +1200,7 @@ function stripHintNullishUnion(type) {
1220
1200
  return type;
1221
1201
  }
1222
1202
  const nonNullish = type.types.filter(
1223
- (member) => (member.flags & (ts4.TypeFlags.Null | ts4.TypeFlags.Undefined)) === 0
1203
+ (member) => (member.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined)) === 0
1224
1204
  );
1225
1205
  if (nonNullish.length === 1 && nonNullish[0] !== void 0) {
1226
1206
  return nonNullish[0];
@@ -1236,10 +1216,10 @@ function isUserEmittableHintProperty(property, declaration) {
1236
1216
  }
1237
1217
  if ("name" in declaration && declaration.name !== void 0) {
1238
1218
  const name = declaration.name;
1239
- if (ts4.isComputedPropertyName(name) || ts4.isPrivateIdentifier(name)) {
1219
+ if (ts3.isComputedPropertyName(name) || ts3.isPrivateIdentifier(name)) {
1240
1220
  return false;
1241
1221
  }
1242
- if (!ts4.isIdentifier(name) && !ts4.isStringLiteral(name) && !ts4.isNumericLiteral(name)) {
1222
+ if (!ts3.isIdentifier(name) && !ts3.isStringLiteral(name) && !ts3.isNumericLiteral(name)) {
1243
1223
  return false;
1244
1224
  }
1245
1225
  }
@@ -1255,7 +1235,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
1255
1235
  if (isCallableType(stripped)) {
1256
1236
  return;
1257
1237
  }
1258
- if (!(0, import_internal2.hasTypeSemanticCapability)(stripped, checker, "object-like")) {
1238
+ if (!(0, import_internal3.hasTypeSemanticCapability)(stripped, checker, "object-like")) {
1259
1239
  return;
1260
1240
  }
1261
1241
  for (const property of stripped.getProperties()) {
@@ -1273,7 +1253,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
1273
1253
  continue;
1274
1254
  }
1275
1255
  const strippedPropertyType = stripHintNullishUnion(propertyType);
1276
- if (!isCallableType(strippedPropertyType) && (0, import_internal2.hasTypeSemanticCapability)(strippedPropertyType, checker, "object-like")) {
1256
+ if (!isCallableType(strippedPropertyType) && (0, import_internal3.hasTypeSemanticCapability)(strippedPropertyType, checker, "object-like")) {
1277
1257
  visit(strippedPropertyType, path3, depth + 1);
1278
1258
  }
1279
1259
  }
@@ -1282,7 +1262,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
1282
1262
  return out;
1283
1263
  }
1284
1264
  function buildPathTargetHint(subjectType, checker, capability, tagName, argumentText) {
1285
- if (!(0, import_internal2.hasTypeSemanticCapability)(subjectType, checker, "object-like")) {
1265
+ if (!(0, import_internal3.hasTypeSemanticCapability)(subjectType, checker, "object-like")) {
1286
1266
  return null;
1287
1267
  }
1288
1268
  const candidates = collectObjectSubfieldCandidates(subjectType, checker, capability);
@@ -1393,24 +1373,24 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1393
1373
  if (checker === void 0 || subjectType === void 0) {
1394
1374
  return [];
1395
1375
  }
1396
- const placement = (0, import_internal2.resolveDeclarationPlacement)(node);
1376
+ const placement = (0, import_internal3.resolveDeclarationPlacement)(node);
1397
1377
  if (placement === null) {
1398
1378
  return [];
1399
1379
  }
1400
- const definition = (0, import_internal2.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
1380
+ const definition = (0, import_internal3.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
1401
1381
  if (definition === null) {
1402
1382
  return [];
1403
1383
  }
1404
1384
  const nonNullPlacement = placement;
1405
- const log = (0, import_internal3.getBuildLogger)();
1406
- const broadeningLog = (0, import_internal3.getBroadeningLogger)();
1407
- const syntheticLog = (0, import_internal3.getSyntheticLogger)();
1408
- const typedParserLog = (0, import_internal3.getTypedParserLogger)();
1385
+ const log = (0, import_internal4.getBuildLogger)();
1386
+ const broadeningLog = (0, import_internal4.getBroadeningLogger)();
1387
+ const syntheticLog = (0, import_internal4.getSyntheticLogger)();
1388
+ const typedParserLog = (0, import_internal4.getTypedParserLogger)();
1409
1389
  const logsEnabled = log !== import_core.noopLogger || broadeningLog !== import_core.noopLogger;
1410
1390
  const syntheticTraceEnabled = syntheticLog !== import_core.noopLogger;
1411
1391
  const typedParserTraceEnabled = typedParserLog !== import_core.noopLogger;
1412
- const logStart = logsEnabled ? (0, import_internal3.nowMicros)() : 0;
1413
- const subjectTypeKind = logsEnabled ? (0, import_internal3.describeTypeKind)(subjectType, checker) : "";
1392
+ const logStart = logsEnabled ? (0, import_internal4.nowMicros)() : 0;
1393
+ const subjectTypeKind = logsEnabled ? (0, import_internal4.describeTypeKind)(subjectType, checker) : "";
1414
1394
  function emit(outcome, result2) {
1415
1395
  if (!logsEnabled) {
1416
1396
  return result2;
@@ -1421,11 +1401,11 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1421
1401
  placement: nonNullPlacement,
1422
1402
  subjectTypeKind,
1423
1403
  roleOutcome: outcome,
1424
- elapsedMicros: (0, import_internal3.elapsedMicros)(logStart)
1404
+ elapsedMicros: (0, import_internal4.elapsedMicros)(logStart)
1425
1405
  };
1426
- (0, import_internal3.logTagApplication)(log, entry);
1406
+ (0, import_internal4.logTagApplication)(log, entry);
1427
1407
  if (outcome === "bypass" || outcome === "D1" || outcome === "D2") {
1428
- (0, import_internal3.logTagApplication)(broadeningLog, entry);
1408
+ (0, import_internal4.logTagApplication)(broadeningLog, entry);
1429
1409
  }
1430
1410
  return result2;
1431
1411
  }
@@ -1460,7 +1440,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1460
1440
  )
1461
1441
  ]);
1462
1442
  }
1463
- const resolution = (0, import_internal2.resolvePathTargetType)(subjectType, checker, target.path.segments);
1443
+ const resolution = (0, import_internal3.resolvePathTargetType)(subjectType, checker, target.path.segments);
1464
1444
  if (resolution.kind === "missing-property") {
1465
1445
  return emit("B-reject", [
1466
1446
  makeDiagnostic(
@@ -1485,7 +1465,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1485
1465
  }
1486
1466
  const hasBroadening = (() => {
1487
1467
  if (target === null) {
1488
- if (isIntegerBrandedType((0, import_internal2.stripNullishUnion)(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
1468
+ if ((0, import_internal2._isIntegerBrandedType)((0, import_internal3.stripNullishUnion)(subjectType)) && definition.capabilities.includes("numeric-comparable")) {
1489
1469
  return true;
1490
1470
  }
1491
1471
  return hasBuiltinConstraintBroadening(tagName, options);
@@ -1516,11 +1496,11 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1516
1496
  ]);
1517
1497
  }
1518
1498
  }
1519
- const effectiveArgumentText = parsedTag !== null ? (0, import_internal2.parseTagSyntax)(tagName, rawText).argumentText : rawText;
1520
1499
  if (hasBroadening) {
1521
1500
  return emit("bypass", []);
1522
1501
  }
1523
- const typedParseResult = (0, import_internal3.parseTagArgument)(tagName, effectiveArgumentText, "build");
1502
+ const effectiveArgumentText = (0, import_internal4.extractEffectiveArgumentText)(tagName, rawText, parsedTag);
1503
+ const typedParseResult = (0, import_internal4.parseTagArgument)(tagName, effectiveArgumentText, "build");
1524
1504
  if (!typedParseResult.ok) {
1525
1505
  if (typedParserTraceEnabled) {
1526
1506
  typedParserLog.trace("typed-parser C-reject", {
@@ -1532,23 +1512,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1532
1512
  diagnosticCode: typedParseResult.diagnostic.code
1533
1513
  });
1534
1514
  }
1535
- let mappedCode;
1536
- switch (typedParseResult.diagnostic.code) {
1537
- case "MISSING_TAG_ARGUMENT":
1538
- mappedCode = "MISSING_TAG_ARGUMENT";
1539
- break;
1540
- case "INVALID_TAG_ARGUMENT":
1541
- mappedCode = "INVALID_TAG_ARGUMENT";
1542
- break;
1543
- case "UNKNOWN_TAG":
1544
- throw new Error(
1545
- `Unexpected UNKNOWN_TAG from parseTagArgument("${tagName}") \u2014 tag was resolved via getTagDefinition.`
1546
- );
1547
- default: {
1548
- const _exhaustive = typedParseResult.diagnostic.code;
1549
- throw new Error(`Unknown diagnostic code: ${String(_exhaustive)}`);
1550
- }
1551
- }
1515
+ const mappedCode = (0, import_internal4.mapTypedParserDiagnosticCode)(typedParseResult.diagnostic.code, tagName);
1552
1516
  return emit("C-reject", [
1553
1517
  makeDiagnostic(mappedCode, typedParseResult.diagnostic.message, provenance)
1554
1518
  ]);
@@ -1579,7 +1543,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1579
1543
  subjectTypeText
1580
1544
  });
1581
1545
  }
1582
- const result = (0, import_internal2.checkSyntheticTagApplication)({
1546
+ const result = (0, import_internal3.checkSyntheticTagApplication)({
1583
1547
  tagName,
1584
1548
  placement,
1585
1549
  hostType: hostTypeText,
@@ -1605,13 +1569,13 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1605
1569
  } : {}
1606
1570
  });
1607
1571
  if (result.diagnostics.length === 0) {
1608
- return emit("C-pass", []);
1572
+ return emit("D-pass", []);
1609
1573
  }
1610
1574
  const setupDiagnostic = result.diagnostics.find((diagnostic) => diagnostic.kind !== "typescript");
1611
1575
  if (setupDiagnostic !== void 0) {
1612
1576
  return emit("C-reject", [
1613
1577
  makeDiagnostic(
1614
- setupDiagnostic.kind === "unsupported-custom-type-override" ? "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" : "SYNTHETIC_SETUP_FAILURE",
1578
+ (0, import_internal4._mapSetupDiagnosticCode)(setupDiagnostic.kind),
1615
1579
  setupDiagnostic.message,
1616
1580
  provenance
1617
1581
  )
@@ -1630,10 +1594,10 @@ var parseResultCache = /* @__PURE__ */ new Map();
1630
1594
  function getExtensionTagNames(options) {
1631
1595
  return [
1632
1596
  ...options?.extensionRegistry?.extensions.flatMap(
1633
- (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName))
1597
+ (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal3.normalizeFormSpecTagName)(tag.tagName))
1634
1598
  ) ?? [],
1635
1599
  ...options?.extensionRegistry?.extensions.flatMap(
1636
- (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal2.normalizeFormSpecTagName)(slot.tagName))
1600
+ (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal3.normalizeFormSpecTagName)(slot.tagName))
1637
1601
  ) ?? []
1638
1602
  ].sort();
1639
1603
  }
@@ -1645,9 +1609,9 @@ function getExtensionRegistryCacheKey(registry) {
1645
1609
  (extension) => JSON.stringify({
1646
1610
  extensionId: extension.extensionId,
1647
1611
  typeNames: extension.types?.map((type) => type.typeName) ?? [],
1648
- constraintTags: extension.constraintTags?.map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName)) ?? [],
1612
+ constraintTags: extension.constraintTags?.map((tag) => (0, import_internal3.normalizeFormSpecTagName)(tag.tagName)) ?? [],
1649
1613
  metadataSlots: extension.metadataSlots?.map((slot) => ({
1650
- tagName: (0, import_internal2.normalizeFormSpecTagName)(slot.tagName),
1614
+ tagName: (0, import_internal3.normalizeFormSpecTagName)(slot.tagName),
1651
1615
  declarationKinds: [...slot.declarationKinds].sort(),
1652
1616
  allowBare: slot.allowBare !== false,
1653
1617
  qualifiers: (slot.qualifiers ?? []).map((qualifier) => ({
@@ -1679,6 +1643,16 @@ function parseTSDocTags(node, file = "", options) {
1679
1643
  if (cached !== void 0) {
1680
1644
  return cached;
1681
1645
  }
1646
+ const setupDiags = options?.extensionRegistry?.setupDiagnostics;
1647
+ if (setupDiags !== void 0 && setupDiags.length > 0) {
1648
+ const result2 = {
1649
+ constraints: [],
1650
+ annotations: [],
1651
+ diagnostics: (0, import_internal4._emitSetupDiagnostics)(setupDiags, file)
1652
+ };
1653
+ parseResultCache.set(cacheKey, result2);
1654
+ return result2;
1655
+ }
1682
1656
  const constraints = [];
1683
1657
  const annotations = [];
1684
1658
  const diagnostics = [];
@@ -1690,12 +1664,12 @@ function parseTSDocTags(node, file = "", options) {
1690
1664
  const sourceText = sourceFile.getFullText();
1691
1665
  const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
1692
1666
  const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
1693
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
1667
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
1694
1668
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
1695
1669
  const extensionTagNames = getExtensionTagNames(options);
1696
1670
  if (commentRanges) {
1697
1671
  for (const range of commentRanges) {
1698
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) {
1672
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) {
1699
1673
  continue;
1700
1674
  }
1701
1675
  const commentText = sourceText.substring(range.pos, range.end);
@@ -1703,7 +1677,7 @@ function parseTSDocTags(node, file = "", options) {
1703
1677
  continue;
1704
1678
  }
1705
1679
  const extensions = options?.extensionRegistry?.extensions;
1706
- const unified = (0, import_internal2.parseUnifiedComment)(commentText, {
1680
+ const unified = (0, import_internal3.parseUnifiedComment)(commentText, {
1707
1681
  offset: range.pos,
1708
1682
  extensionTagNames,
1709
1683
  ...extensions !== void 0 ? { extensions } : {}
@@ -1738,13 +1712,13 @@ function parseTSDocTags(node, file = "", options) {
1738
1712
  }
1739
1713
  continue;
1740
1714
  }
1741
- if (import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
1715
+ if (import_internal3.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
1742
1716
  const fallback = rawTextFallbacks.get(tagName)?.shift();
1743
- const text2 = (0, import_internal2.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
1717
+ const text2 = (0, import_internal3.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
1744
1718
  if (text2 === "") continue;
1745
1719
  const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
1746
1720
  if (tagName === "defaultValue") {
1747
- annotations.push((0, import_internal2.parseDefaultValueTagValue)(text2, provenance2));
1721
+ annotations.push((0, import_internal3.parseDefaultValueTagValue)(text2, provenance2));
1748
1722
  continue;
1749
1723
  }
1750
1724
  processConstraintTag(
@@ -1826,7 +1800,7 @@ function parseTSDocTags(node, file = "", options) {
1826
1800
  if (text === "") continue;
1827
1801
  const provenance = fallback.provenance;
1828
1802
  if (tagName === "defaultValue") {
1829
- annotations.push((0, import_internal2.parseDefaultValueTagValue)(text, provenance));
1803
+ annotations.push((0, import_internal3.parseDefaultValueTagValue)(text, provenance));
1830
1804
  continue;
1831
1805
  }
1832
1806
  processConstraintTag(
@@ -1852,13 +1826,13 @@ function extractDisplayNameMetadata(node) {
1852
1826
  const memberDisplayNames = /* @__PURE__ */ new Map();
1853
1827
  const sourceFile = node.getSourceFile();
1854
1828
  const sourceText = sourceFile.getFullText();
1855
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
1829
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
1856
1830
  if (commentRanges) {
1857
1831
  for (const range of commentRanges) {
1858
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) continue;
1832
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) continue;
1859
1833
  const commentText = sourceText.substring(range.pos, range.end);
1860
1834
  if (!commentText.startsWith("/**")) continue;
1861
- const unified = (0, import_internal2.parseUnifiedComment)(commentText);
1835
+ const unified = (0, import_internal3.parseUnifiedComment)(commentText);
1862
1836
  for (const tag of unified.tags) {
1863
1837
  if (tag.normalizedTagName !== "displayName") {
1864
1838
  continue;
@@ -1880,9 +1854,9 @@ function extractDisplayNameMetadata(node) {
1880
1854
  }
1881
1855
  function collectRawTextFallbacks(node, file) {
1882
1856
  const fallbacks = /* @__PURE__ */ new Map();
1883
- for (const tag of ts4.getJSDocTags(node)) {
1857
+ for (const tag of ts3.getJSDocTags(node)) {
1884
1858
  const tagName = (0, import_internals3.normalizeConstraintTagName)(tag.tagName.text);
1885
- if (!import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
1859
+ if (!import_internal3.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
1886
1860
  const commentText = getTagCommentText(tag)?.trim() ?? "";
1887
1861
  if (commentText === "") continue;
1888
1862
  const entries = fallbacks.get(tagName) ?? [];
@@ -1895,7 +1869,7 @@ function collectRawTextFallbacks(node, file) {
1895
1869
  return fallbacks;
1896
1870
  }
1897
1871
  function isMemberTargetDisplayName(text) {
1898
- return (0, import_internal2.parseTagSyntax)("displayName", text).target !== null;
1872
+ return (0, import_internal3.parseTagSyntax)("displayName", text).target !== null;
1899
1873
  }
1900
1874
  function provenanceForComment(range, sourceFile, file, tagName) {
1901
1875
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(range.pos);
@@ -1935,7 +1909,7 @@ function getTagCommentText(tag) {
1935
1909
  if (typeof tag.comment === "string") {
1936
1910
  return tag.comment;
1937
1911
  }
1938
- return ts4.getTextOfJSDocComment(tag.comment);
1912
+ return ts3.getTextOfJSDocComment(tag.comment);
1939
1913
  }
1940
1914
 
1941
1915
  // src/analyzer/jsdoc-constraints.ts
@@ -1953,18 +1927,18 @@ function extractJSDocAnnotationNodes(node, file = "", options) {
1953
1927
  function extractDefaultValueAnnotation(initializer, file = "") {
1954
1928
  if (!initializer) return null;
1955
1929
  let value;
1956
- if (ts5.isStringLiteral(initializer)) {
1930
+ if (ts4.isStringLiteral(initializer)) {
1957
1931
  value = initializer.text;
1958
- } else if (ts5.isNumericLiteral(initializer)) {
1932
+ } else if (ts4.isNumericLiteral(initializer)) {
1959
1933
  value = Number(initializer.text);
1960
- } else if (initializer.kind === ts5.SyntaxKind.TrueKeyword) {
1934
+ } else if (initializer.kind === ts4.SyntaxKind.TrueKeyword) {
1961
1935
  value = true;
1962
- } else if (initializer.kind === ts5.SyntaxKind.FalseKeyword) {
1936
+ } else if (initializer.kind === ts4.SyntaxKind.FalseKeyword) {
1963
1937
  value = false;
1964
- } else if (initializer.kind === ts5.SyntaxKind.NullKeyword) {
1938
+ } else if (initializer.kind === ts4.SyntaxKind.NullKeyword) {
1965
1939
  value = null;
1966
- } else if (ts5.isPrefixUnaryExpression(initializer)) {
1967
- if (initializer.operator === ts5.SyntaxKind.MinusToken && ts5.isNumericLiteral(initializer.operand)) {
1940
+ } else if (ts4.isPrefixUnaryExpression(initializer)) {
1941
+ if (initializer.operator === ts4.SyntaxKind.MinusToken && ts4.isNumericLiteral(initializer.operand)) {
1968
1942
  value = -Number(initializer.operand.text);
1969
1943
  }
1970
1944
  }
@@ -1986,28 +1960,28 @@ function extractDefaultValueAnnotation(initializer, file = "") {
1986
1960
 
1987
1961
  // src/analyzer/class-analyzer.ts
1988
1962
  function isObjectType(type) {
1989
- return !!(type.flags & ts6.TypeFlags.Object);
1963
+ return !!(type.flags & ts5.TypeFlags.Object);
1990
1964
  }
1991
1965
  function isIntersectionType(type) {
1992
- return !!(type.flags & ts6.TypeFlags.Intersection);
1966
+ return !!(type.flags & ts5.TypeFlags.Intersection);
1993
1967
  }
1994
1968
  function isResolvableObjectLikeAliasTypeNode(typeNode) {
1995
- if (ts6.isParenthesizedTypeNode(typeNode)) {
1969
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
1996
1970
  return isResolvableObjectLikeAliasTypeNode(typeNode.type);
1997
1971
  }
1998
- if (ts6.isTypeLiteralNode(typeNode) || ts6.isTypeReferenceNode(typeNode)) {
1972
+ if (ts5.isTypeLiteralNode(typeNode) || ts5.isTypeReferenceNode(typeNode)) {
1999
1973
  return true;
2000
1974
  }
2001
- return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
1975
+ return ts5.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
2002
1976
  }
2003
1977
  function isSemanticallyPlainObjectLikeType(type, checker) {
2004
1978
  if (isIntersectionType(type)) {
2005
1979
  return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
2006
1980
  }
2007
- 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);
1981
+ 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);
2008
1982
  }
2009
1983
  function isTypeReference(type) {
2010
- return !!(type.flags & ts6.TypeFlags.Object) && !!(type.objectFlags & ts6.ObjectFlags.Reference);
1984
+ return !!(type.flags & ts5.TypeFlags.Object) && !!(type.objectFlags & ts5.ObjectFlags.Reference);
2011
1985
  }
2012
1986
  var RESOLVING_TYPE_PLACEHOLDER = {
2013
1987
  kind: "object",
@@ -2033,8 +2007,23 @@ function createAnalyzerMetadataPolicy(input, discriminator) {
2033
2007
  discriminator
2034
2008
  };
2035
2009
  }
2010
+ var DEDUPLICATABLE_DIAGNOSTIC_CODES = /* @__PURE__ */ new Set([
2011
+ "SYNTHETIC_SETUP_FAILURE",
2012
+ "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE"
2013
+ ]);
2014
+ function deduplicateDiagnostics(diagnostics) {
2015
+ if (diagnostics.length <= 1) return diagnostics;
2016
+ const seen = /* @__PURE__ */ new Set();
2017
+ return diagnostics.filter((d) => {
2018
+ if (!DEDUPLICATABLE_DIAGNOSTIC_CODES.has(d.code)) return true;
2019
+ const key = `${d.code}\0${d.message}`;
2020
+ if (seen.has(key)) return false;
2021
+ seen.add(key);
2022
+ return true;
2023
+ });
2024
+ }
2036
2025
  function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node, checker, extensionRegistry, buildContext) {
2037
- const analysis = (0, import_internal4.analyzeMetadataForNodeWithChecker)({
2026
+ const analysis = (0, import_internal5.analyzeMetadataForNodeWithChecker)({
2038
2027
  checker,
2039
2028
  node,
2040
2029
  logicalName,
@@ -2069,10 +2058,121 @@ function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node,
2069
2058
  }
2070
2059
  return resolvedMetadata;
2071
2060
  }
2061
+ var INHERITABLE_TYPE_ANNOTATION_KINDS = /* @__PURE__ */ new Set(["format"]);
2062
+ function getInheritableAnnotationStringValue(annotation) {
2063
+ if (annotation.annotationKind === "format") return annotation.value;
2064
+ return void 0;
2065
+ }
2066
+ function isOverridingInheritableAnnotation(annotation) {
2067
+ const value = getInheritableAnnotationStringValue(annotation);
2068
+ if (value === void 0) return true;
2069
+ return value.trim().length > 0;
2070
+ }
2071
+ function collectInheritedTypeAnnotations(derivedDecl, existingAnnotations, checker, extensionRegistry) {
2072
+ const existingKinds = new Set(
2073
+ existingAnnotations.filter(isOverridingInheritableAnnotation).map((a) => a.annotationKind)
2074
+ );
2075
+ const needed = /* @__PURE__ */ new Set();
2076
+ for (const kind of INHERITABLE_TYPE_ANNOTATION_KINDS) {
2077
+ if (!existingKinds.has(kind)) needed.add(kind);
2078
+ }
2079
+ if (needed.size === 0) return [];
2080
+ const inherited = [];
2081
+ const seen = /* @__PURE__ */ new Set([derivedDecl]);
2082
+ const queue = [];
2083
+ const resolveSymbolTarget = (sym) => {
2084
+ if ((sym.flags & ts5.SymbolFlags.Alias) === 0) return sym;
2085
+ try {
2086
+ return checker.getAliasedSymbol(sym);
2087
+ } catch {
2088
+ return sym;
2089
+ }
2090
+ };
2091
+ const isObjectShapedTypeAlias = (alias) => {
2092
+ const type = checker.getTypeFromTypeNode(alias.type);
2093
+ if ((type.flags & ts5.TypeFlags.Object) !== 0) return true;
2094
+ if (type.isIntersection()) return true;
2095
+ return false;
2096
+ };
2097
+ const enqueueCandidate = (baseDecl, fromTypeAliasRhs) => {
2098
+ if (seen.has(baseDecl)) return;
2099
+ if (ts5.isClassDeclaration(baseDecl) || ts5.isInterfaceDeclaration(baseDecl)) {
2100
+ seen.add(baseDecl);
2101
+ queue.push(baseDecl);
2102
+ return;
2103
+ }
2104
+ if (ts5.isTypeAliasDeclaration(baseDecl)) {
2105
+ if (!fromTypeAliasRhs && !isObjectShapedTypeAlias(baseDecl)) return;
2106
+ seen.add(baseDecl);
2107
+ queue.push(baseDecl);
2108
+ }
2109
+ };
2110
+ const enqueueBasesOf = (decl) => {
2111
+ if (ts5.isTypeAliasDeclaration(decl)) {
2112
+ const rhs = decl.type;
2113
+ if (!ts5.isTypeReferenceNode(rhs)) return;
2114
+ const sym = checker.getSymbolAtLocation(rhs.typeName);
2115
+ if (!sym) return;
2116
+ const target = resolveSymbolTarget(sym);
2117
+ for (const baseDecl of target.declarations ?? []) {
2118
+ enqueueCandidate(
2119
+ baseDecl,
2120
+ /*fromTypeAliasRhs*/
2121
+ true
2122
+ );
2123
+ }
2124
+ return;
2125
+ }
2126
+ const heritageClauses = decl.heritageClauses;
2127
+ if (!heritageClauses) return;
2128
+ for (const clause of heritageClauses) {
2129
+ if (clause.token !== ts5.SyntaxKind.ExtendsKeyword) continue;
2130
+ for (const typeExpr of clause.types) {
2131
+ const sym = checker.getSymbolAtLocation(typeExpr.expression);
2132
+ if (!sym) continue;
2133
+ const target = resolveSymbolTarget(sym);
2134
+ for (const baseDecl of target.declarations ?? []) {
2135
+ enqueueCandidate(
2136
+ baseDecl,
2137
+ /*fromTypeAliasRhs*/
2138
+ false
2139
+ );
2140
+ }
2141
+ }
2142
+ }
2143
+ };
2144
+ enqueueBasesOf(derivedDecl);
2145
+ for (let queueIndex = 0; queueIndex < queue.length && needed.size > 0; queueIndex++) {
2146
+ const baseDecl = queue[queueIndex];
2147
+ if (baseDecl === void 0) continue;
2148
+ const baseFile = baseDecl.getSourceFile().fileName;
2149
+ const baseAnnotations = extractJSDocAnnotationNodes(
2150
+ baseDecl,
2151
+ baseFile,
2152
+ makeParseOptions(extensionRegistry)
2153
+ );
2154
+ for (const annotation of baseAnnotations) {
2155
+ if (!needed.has(annotation.annotationKind)) continue;
2156
+ if (!isOverridingInheritableAnnotation(annotation)) continue;
2157
+ inherited.push(annotation);
2158
+ needed.delete(annotation.annotationKind);
2159
+ }
2160
+ if (needed.size > 0) {
2161
+ enqueueBasesOf(baseDecl);
2162
+ }
2163
+ }
2164
+ return inherited;
2165
+ }
2166
+ function extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) {
2167
+ const local = extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry));
2168
+ const inherited = collectInheritedTypeAnnotations(namedDecl, local, checker, extensionRegistry);
2169
+ if (inherited.length === 0) return [...local];
2170
+ return [...local, ...inherited];
2171
+ }
2072
2172
  function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRegistry, metadataPolicy) {
2073
2173
  const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
2074
2174
  const declarationType = checker.getTypeAtLocation(declaration);
2075
- const logicalName = ts6.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
2175
+ const logicalName = ts5.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
2076
2176
  const docResult = extractJSDocParseResult(
2077
2177
  declaration,
2078
2178
  file,
@@ -2114,13 +2214,19 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2114
2214
  file,
2115
2215
  makeParseOptions(extensionRegistry, void 0, checker, classType, classType)
2116
2216
  );
2117
- const annotations = [...classDoc.annotations];
2217
+ const inheritedClassAnnotations = collectInheritedTypeAnnotations(
2218
+ classDecl,
2219
+ classDoc.annotations,
2220
+ checker,
2221
+ extensionRegistry
2222
+ );
2223
+ const annotations = [...classDoc.annotations, ...inheritedClassAnnotations];
2118
2224
  diagnostics.push(...classDoc.diagnostics);
2119
2225
  const visiting = /* @__PURE__ */ new Set();
2120
2226
  const instanceMethods = [];
2121
2227
  const staticMethods = [];
2122
2228
  for (const member of classDecl.members) {
2123
- if (ts6.isPropertyDeclaration(member)) {
2229
+ if (ts5.isPropertyDeclaration(member)) {
2124
2230
  const fieldNode = analyzeFieldToIR(
2125
2231
  member,
2126
2232
  checker,
@@ -2136,10 +2242,10 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2136
2242
  fields.push(fieldNode);
2137
2243
  fieldLayouts.push({});
2138
2244
  }
2139
- } else if (ts6.isMethodDeclaration(member)) {
2245
+ } else if (ts5.isMethodDeclaration(member)) {
2140
2246
  const methodInfo = analyzeMethod(member, checker);
2141
2247
  if (methodInfo) {
2142
- const isStatic = member.modifiers?.some((m) => m.kind === ts6.SyntaxKind.StaticKeyword);
2248
+ const isStatic = member.modifiers?.some((m) => m.kind === ts5.SyntaxKind.StaticKeyword);
2143
2249
  if (isStatic) {
2144
2250
  staticMethods.push(methodInfo);
2145
2251
  } else {
@@ -2171,6 +2277,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2171
2277
  hostType: classType
2172
2278
  }
2173
2279
  );
2280
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
2174
2281
  return {
2175
2282
  name,
2176
2283
  ...metadata !== void 0 && { metadata },
@@ -2178,7 +2285,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2178
2285
  fieldLayouts,
2179
2286
  typeRegistry,
2180
2287
  ...annotations.length > 0 && { annotations },
2181
- ...diagnostics.length > 0 && { diagnostics },
2288
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
2182
2289
  instanceMethods,
2183
2290
  staticMethods
2184
2291
  };
@@ -2198,11 +2305,20 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
2198
2305
  file,
2199
2306
  makeParseOptions(extensionRegistry, void 0, checker, interfaceType, interfaceType)
2200
2307
  );
2201
- const annotations = [...interfaceDoc.annotations];
2308
+ const inheritedInterfaceAnnotations = collectInheritedTypeAnnotations(
2309
+ interfaceDecl,
2310
+ interfaceDoc.annotations,
2311
+ checker,
2312
+ extensionRegistry
2313
+ );
2314
+ const annotations = [
2315
+ ...interfaceDoc.annotations,
2316
+ ...inheritedInterfaceAnnotations
2317
+ ];
2202
2318
  diagnostics.push(...interfaceDoc.diagnostics);
2203
2319
  const visiting = /* @__PURE__ */ new Set();
2204
2320
  for (const member of interfaceDecl.members) {
2205
- if (ts6.isPropertySignature(member)) {
2321
+ if (ts5.isPropertySignature(member)) {
2206
2322
  const fieldNode = analyzeInterfacePropertyToIR(
2207
2323
  member,
2208
2324
  checker,
@@ -2243,6 +2359,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
2243
2359
  hostType: interfaceType
2244
2360
  }
2245
2361
  );
2362
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
2246
2363
  return {
2247
2364
  name,
2248
2365
  ...metadata !== void 0 && { metadata },
@@ -2250,7 +2367,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
2250
2367
  fieldLayouts,
2251
2368
  typeRegistry,
2252
2369
  ...annotations.length > 0 && { annotations },
2253
- ...diagnostics.length > 0 && { diagnostics },
2370
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
2254
2371
  instanceMethods: [],
2255
2372
  staticMethods: []
2256
2373
  };
@@ -2260,7 +2377,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
2260
2377
  if (members === null) {
2261
2378
  const sourceFile = typeAlias.getSourceFile();
2262
2379
  const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
2263
- const kindDesc = ts6.SyntaxKind[typeAlias.type.kind] ?? "unknown";
2380
+ const kindDesc = ts5.SyntaxKind[typeAlias.type.kind] ?? "unknown";
2264
2381
  return {
2265
2382
  ok: false,
2266
2383
  kind: "not-object-like",
@@ -2295,7 +2412,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
2295
2412
  diagnostics.push(...typeAliasDoc.diagnostics);
2296
2413
  const visiting = /* @__PURE__ */ new Set();
2297
2414
  for (const member of members) {
2298
- if (ts6.isPropertySignature(member)) {
2415
+ if (ts5.isPropertySignature(member)) {
2299
2416
  const fieldNode = analyzeInterfacePropertyToIR(
2300
2417
  member,
2301
2418
  checker,
@@ -2335,6 +2452,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
2335
2452
  hostType: aliasType
2336
2453
  }
2337
2454
  );
2455
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
2338
2456
  return {
2339
2457
  ok: true,
2340
2458
  analysis: {
@@ -2344,7 +2462,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
2344
2462
  fieldLayouts: specializedFields.map(() => ({})),
2345
2463
  typeRegistry,
2346
2464
  ...annotations.length > 0 && { annotations },
2347
- ...diagnostics.length > 0 && { diagnostics },
2465
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
2348
2466
  instanceMethods: [],
2349
2467
  staticMethods: []
2350
2468
  }
@@ -2362,20 +2480,20 @@ function makeAnalysisDiagnostic(code, message, primaryLocation, relatedLocations
2362
2480
  function getLeadingParsedTags(node) {
2363
2481
  const sourceFile = node.getSourceFile();
2364
2482
  const sourceText = sourceFile.getFullText();
2365
- const commentRanges = ts6.getLeadingCommentRanges(sourceText, node.getFullStart());
2483
+ const commentRanges = ts5.getLeadingCommentRanges(sourceText, node.getFullStart());
2366
2484
  if (commentRanges === void 0) {
2367
2485
  return [];
2368
2486
  }
2369
2487
  const parsedTags = [];
2370
2488
  for (const range of commentRanges) {
2371
- if (range.kind !== ts6.SyntaxKind.MultiLineCommentTrivia) {
2489
+ if (range.kind !== ts5.SyntaxKind.MultiLineCommentTrivia) {
2372
2490
  continue;
2373
2491
  }
2374
2492
  const commentText = sourceText.slice(range.pos, range.end);
2375
2493
  if (!commentText.startsWith("/**")) {
2376
2494
  continue;
2377
2495
  }
2378
- parsedTags.push(...(0, import_internal4.parseCommentBlock)(commentText, { offset: range.pos }).tags);
2496
+ parsedTags.push(...(0, import_internal5.parseCommentBlock)(commentText, { offset: range.pos }).tags);
2379
2497
  }
2380
2498
  return parsedTags;
2381
2499
  }
@@ -2386,19 +2504,19 @@ function resolveDiscriminatorProperty(node, checker, fieldName) {
2386
2504
  return null;
2387
2505
  }
2388
2506
  const declaration = propertySymbol.valueDeclaration ?? propertySymbol.declarations?.find(
2389
- (candidate) => ts6.isPropertyDeclaration(candidate) || ts6.isPropertySignature(candidate)
2507
+ (candidate) => ts5.isPropertyDeclaration(candidate) || ts5.isPropertySignature(candidate)
2390
2508
  ) ?? propertySymbol.declarations?.[0];
2391
2509
  return {
2392
2510
  declaration,
2393
2511
  type: checker.getTypeOfSymbolAtLocation(propertySymbol, declaration ?? node),
2394
- optional: !!(propertySymbol.flags & ts6.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
2512
+ optional: !!(propertySymbol.flags & ts5.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
2395
2513
  };
2396
2514
  }
2397
2515
  function isLocalTypeParameterName(node, typeParameterName) {
2398
2516
  return node.typeParameters?.some((typeParameter) => typeParameter.name.text === typeParameterName) ?? false;
2399
2517
  }
2400
2518
  function isNullishSemanticType(type) {
2401
- if (type.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined | ts6.TypeFlags.Void | ts6.TypeFlags.Unknown | ts6.TypeFlags.Any)) {
2519
+ if (type.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined | ts5.TypeFlags.Void | ts5.TypeFlags.Unknown | ts5.TypeFlags.Any)) {
2402
2520
  return true;
2403
2521
  }
2404
2522
  return type.isUnion() && type.types.some((member) => isNullishSemanticType(member));
@@ -2408,7 +2526,7 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
2408
2526
  return false;
2409
2527
  }
2410
2528
  seen.add(type);
2411
- if (type.flags & ts6.TypeFlags.StringLike) {
2529
+ if (type.flags & ts5.TypeFlags.StringLike) {
2412
2530
  return true;
2413
2531
  }
2414
2532
  if (type.isUnion()) {
@@ -2421,13 +2539,13 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
2421
2539
  return false;
2422
2540
  }
2423
2541
  function getObjectLikeTypeAliasMembers(typeNode) {
2424
- if (ts6.isParenthesizedTypeNode(typeNode)) {
2542
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
2425
2543
  return getObjectLikeTypeAliasMembers(typeNode.type);
2426
2544
  }
2427
- if (ts6.isTypeLiteralNode(typeNode)) {
2545
+ if (ts5.isTypeLiteralNode(typeNode)) {
2428
2546
  return [...typeNode.members];
2429
2547
  }
2430
- if (ts6.isIntersectionTypeNode(typeNode)) {
2548
+ if (ts5.isIntersectionTypeNode(typeNode)) {
2431
2549
  const members = [];
2432
2550
  for (const intersectionMember of typeNode.types) {
2433
2551
  const resolvedMembers = getObjectLikeTypeAliasMembers(intersectionMember);
@@ -2590,7 +2708,7 @@ function resolveLiteralDiscriminatorPropertyValue(boundType, propertyName, check
2590
2708
  }
2591
2709
  if (propertyType.isUnion()) {
2592
2710
  const nonNullMembers = propertyType.types.filter(
2593
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
2711
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
2594
2712
  );
2595
2713
  if (nonNullMembers.length > 0 && nonNullMembers.every((member) => member.isStringLiteral())) {
2596
2714
  diagnostics.push(
@@ -2639,13 +2757,13 @@ function resolveNamedDiscriminatorDeclaration(type, checker, seen = /* @__PURE__
2639
2757
  seen.add(type);
2640
2758
  const symbol = type.aliasSymbol ?? type.getSymbol();
2641
2759
  if (symbol !== void 0) {
2642
- const aliased = symbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
2760
+ const aliased = symbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
2643
2761
  const targetSymbol = aliased ?? symbol;
2644
2762
  const declaration = targetSymbol.declarations?.find(
2645
- (candidate) => ts6.isClassDeclaration(candidate) || ts6.isInterfaceDeclaration(candidate) || ts6.isTypeAliasDeclaration(candidate) || ts6.isEnumDeclaration(candidate)
2763
+ (candidate) => ts5.isClassDeclaration(candidate) || ts5.isInterfaceDeclaration(candidate) || ts5.isTypeAliasDeclaration(candidate) || ts5.isEnumDeclaration(candidate)
2646
2764
  );
2647
2765
  if (declaration !== void 0) {
2648
- if (ts6.isTypeAliasDeclaration(declaration) && ts6.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
2766
+ if (ts5.isTypeAliasDeclaration(declaration) && ts5.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
2649
2767
  return resolveNamedDiscriminatorDeclaration(
2650
2768
  checker.getTypeFromTypeNode(declaration.type),
2651
2769
  checker,
@@ -2673,7 +2791,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
2673
2791
  }
2674
2792
  if (boundType.isUnion()) {
2675
2793
  const nonNullMembers = boundType.types.filter(
2676
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
2794
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
2677
2795
  );
2678
2796
  if (nonNullMembers.every((member) => member.isStringLiteral())) {
2679
2797
  diagnostics.push(
@@ -2718,7 +2836,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
2718
2836
  return null;
2719
2837
  }
2720
2838
  function getDeclarationName(node) {
2721
- if (ts6.isClassDeclaration(node) || ts6.isInterfaceDeclaration(node) || ts6.isTypeAliasDeclaration(node) || ts6.isEnumDeclaration(node)) {
2839
+ if (ts5.isClassDeclaration(node) || ts5.isInterfaceDeclaration(node) || ts5.isTypeAliasDeclaration(node) || ts5.isEnumDeclaration(node)) {
2722
2840
  return node.name?.text ?? "anonymous";
2723
2841
  }
2724
2842
  return "anonymous";
@@ -2773,11 +2891,11 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
2773
2891
  if (sourceTypeNode === void 0) {
2774
2892
  return [];
2775
2893
  }
2776
- const unwrapParentheses = (typeNode) => ts6.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
2894
+ const unwrapParentheses = (typeNode) => ts5.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
2777
2895
  const directTypeNode = unwrapParentheses(sourceTypeNode);
2778
- const referenceTypeNode = ts6.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
2896
+ const referenceTypeNode = ts5.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
2779
2897
  const resolvedTypeNode = resolveAliasedTypeNode(directTypeNode, checker);
2780
- return ts6.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
2898
+ return ts5.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
2781
2899
  })();
2782
2900
  if (referenceTypeNode?.typeArguments === void 0) {
2783
2901
  return [];
@@ -2785,7 +2903,7 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
2785
2903
  return referenceTypeNode.typeArguments.map((argumentNode) => {
2786
2904
  const argumentType = checker.getTypeFromTypeNode(argumentNode);
2787
2905
  const baseSymbol = argumentType.aliasSymbol ?? argumentType.getSymbol();
2788
- const argumentSymbol = baseSymbol !== void 0 && baseSymbol.flags & ts6.SymbolFlags.Alias ? checker.getAliasedSymbol(baseSymbol) : baseSymbol;
2906
+ const argumentSymbol = baseSymbol !== void 0 && baseSymbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(baseSymbol) : baseSymbol;
2789
2907
  const argumentDecl = argumentSymbol?.declarations?.[0];
2790
2908
  if (argumentDecl !== void 0 && argumentDecl.getSourceFile().fileName !== file) {
2791
2909
  const argumentName = argumentSymbol?.getName() ?? baseSymbol?.getName();
@@ -2848,7 +2966,7 @@ function applyDiscriminatorToObjectProperties(properties, node, subjectType, che
2848
2966
  );
2849
2967
  }
2850
2968
  function analyzeFieldToIR(prop, checker, file, typeRegistry, visiting, diagnostics, hostType, metadataPolicy, extensionRegistry) {
2851
- if (!ts6.isIdentifier(prop.name)) {
2969
+ if (!ts5.isIdentifier(prop.name)) {
2852
2970
  return null;
2853
2971
  }
2854
2972
  const name = prop.name.text;
@@ -2975,7 +3093,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
2975
3093
  const seen = /* @__PURE__ */ new Set();
2976
3094
  const duplicates = /* @__PURE__ */ new Set();
2977
3095
  for (const member of members) {
2978
- if (!ts6.isPropertySignature(member)) {
3096
+ if (!ts5.isPropertySignature(member)) {
2979
3097
  continue;
2980
3098
  }
2981
3099
  const name = getAnalyzableObjectLikePropertyName(member.name);
@@ -2991,7 +3109,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
2991
3109
  return [...duplicates].sort();
2992
3110
  }
2993
3111
  function getAnalyzableObjectLikePropertyName(name) {
2994
- if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
3112
+ if (ts5.isIdentifier(name) || ts5.isStringLiteral(name) || ts5.isNumericLiteral(name)) {
2995
3113
  return name.text;
2996
3114
  }
2997
3115
  return null;
@@ -3086,28 +3204,28 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
3086
3204
  if (primitiveAlias) {
3087
3205
  return primitiveAlias;
3088
3206
  }
3089
- if (isIntegerBrandedType(type)) {
3207
+ if ((0, import_internal2._isIntegerBrandedType)(type)) {
3090
3208
  return { kind: "primitive", primitiveKind: "integer" };
3091
3209
  }
3092
- if (type.flags & ts6.TypeFlags.String) {
3210
+ if (type.flags & ts5.TypeFlags.String) {
3093
3211
  return { kind: "primitive", primitiveKind: "string" };
3094
3212
  }
3095
- if (type.flags & ts6.TypeFlags.Number) {
3213
+ if (type.flags & ts5.TypeFlags.Number) {
3096
3214
  return { kind: "primitive", primitiveKind: "number" };
3097
3215
  }
3098
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
3216
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
3099
3217
  return { kind: "primitive", primitiveKind: "bigint" };
3100
3218
  }
3101
- if (type.flags & ts6.TypeFlags.Boolean) {
3219
+ if (type.flags & ts5.TypeFlags.Boolean) {
3102
3220
  return { kind: "primitive", primitiveKind: "boolean" };
3103
3221
  }
3104
- if (type.flags & ts6.TypeFlags.Null) {
3222
+ if (type.flags & ts5.TypeFlags.Null) {
3105
3223
  return { kind: "primitive", primitiveKind: "null" };
3106
3224
  }
3107
- if (type.flags & ts6.TypeFlags.Undefined) {
3225
+ if (type.flags & ts5.TypeFlags.Undefined) {
3108
3226
  return { kind: "primitive", primitiveKind: "null" };
3109
3227
  }
3110
- if (type.flags & ts6.TypeFlags.Void) {
3228
+ if (type.flags & ts5.TypeFlags.Void) {
3111
3229
  return { kind: "primitive", primitiveKind: "null" };
3112
3230
  }
3113
3231
  if (type.isStringLiteral()) {
@@ -3194,10 +3312,10 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
3194
3312
  return { kind: "primitive", primitiveKind: "string" };
3195
3313
  }
3196
3314
  function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3197
- if (!(type.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
3315
+ if (!(type.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null)) && !(0, import_internal2._isIntegerBrandedType)(type)) {
3198
3316
  return null;
3199
3317
  }
3200
- const aliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
3318
+ const aliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
3201
3319
  if (!aliasDecl) {
3202
3320
  return null;
3203
3321
  }
@@ -3208,11 +3326,18 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
3208
3326
  ...extractJSDocConstraintNodes(aliasDecl, file, makeParseOptions(extensionRegistry)),
3209
3327
  ...extractTypeAliasConstraintNodes(aliasDecl.type, checker, file, extensionRegistry)
3210
3328
  ];
3211
- const annotations = extractJSDocAnnotationNodes(
3329
+ const localAnnotations = extractJSDocAnnotationNodes(
3212
3330
  aliasDecl,
3213
3331
  file,
3214
3332
  makeParseOptions(extensionRegistry)
3215
3333
  );
3334
+ const inheritedAnnotations = collectInheritedTypeAnnotations(
3335
+ aliasDecl,
3336
+ localAnnotations,
3337
+ checker,
3338
+ extensionRegistry
3339
+ );
3340
+ const annotations = [...localAnnotations, ...inheritedAnnotations];
3216
3341
  const metadata = resolveNodeMetadata(
3217
3342
  metadataPolicy,
3218
3343
  "type",
@@ -3247,8 +3372,8 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
3247
3372
  return { kind: "reference", name: aliasName, typeArguments: [] };
3248
3373
  }
3249
3374
  function getReferencedTypeAliasDeclaration(sourceNode, checker) {
3250
- const typeNode = sourceNode && (ts6.isPropertyDeclaration(sourceNode) || ts6.isPropertySignature(sourceNode) || ts6.isParameter(sourceNode)) ? sourceNode.type : void 0;
3251
- if (!typeNode || !ts6.isTypeReferenceNode(typeNode)) {
3375
+ const typeNode = sourceNode && (ts5.isPropertyDeclaration(sourceNode) || ts5.isPropertySignature(sourceNode) || ts5.isParameter(sourceNode)) ? sourceNode.type : void 0;
3376
+ if (!typeNode || !ts5.isTypeReferenceNode(typeNode)) {
3252
3377
  return void 0;
3253
3378
  }
3254
3379
  return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -3269,7 +3394,7 @@ function resolveNamedTypeWithSourceRecovery(type, sourceNode, checker) {
3269
3394
  return { typeName: refAliasDecl.name.text, namedDecl: refAliasDecl };
3270
3395
  }
3271
3396
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
3272
- if (!ts6.isTypeReferenceNode(typeNode)) {
3397
+ if (!ts5.isTypeReferenceNode(typeNode)) {
3273
3398
  return false;
3274
3399
  }
3275
3400
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -3277,10 +3402,10 @@ function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
3277
3402
  return false;
3278
3403
  }
3279
3404
  const resolved = checker.getTypeFromTypeNode(aliasDecl.type);
3280
- return !!(resolved.flags & (ts6.TypeFlags.String | ts6.TypeFlags.Number | ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral | ts6.TypeFlags.Boolean | ts6.TypeFlags.Null));
3405
+ return !!(resolved.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null));
3281
3406
  }
3282
3407
  function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics, visitedAliases = /* @__PURE__ */ new Set()) {
3283
- const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration);
3408
+ const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration);
3284
3409
  if (nestedAliasDecl !== void 0 && !visitedAliases.has(nestedAliasDecl)) {
3285
3410
  visitedAliases.add(nestedAliasDecl);
3286
3411
  return resolveAliasedPrimitiveTarget(
@@ -3295,22 +3420,22 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
3295
3420
  visitedAliases
3296
3421
  );
3297
3422
  }
3298
- if (isIntegerBrandedType(type)) {
3423
+ if ((0, import_internal2._isIntegerBrandedType)(type)) {
3299
3424
  return { kind: "primitive", primitiveKind: "integer" };
3300
3425
  }
3301
- if (type.flags & ts6.TypeFlags.String) {
3426
+ if (type.flags & ts5.TypeFlags.String) {
3302
3427
  return { kind: "primitive", primitiveKind: "string" };
3303
3428
  }
3304
- if (type.flags & ts6.TypeFlags.Number) {
3429
+ if (type.flags & ts5.TypeFlags.Number) {
3305
3430
  return { kind: "primitive", primitiveKind: "number" };
3306
3431
  }
3307
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
3432
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
3308
3433
  return { kind: "primitive", primitiveKind: "bigint" };
3309
3434
  }
3310
- if (type.flags & ts6.TypeFlags.Boolean) {
3435
+ if (type.flags & ts5.TypeFlags.Boolean) {
3311
3436
  return { kind: "primitive", primitiveKind: "boolean" };
3312
3437
  }
3313
- if (type.flags & ts6.TypeFlags.Null) {
3438
+ if (type.flags & ts5.TypeFlags.Null) {
3314
3439
  return { kind: "primitive", primitiveKind: "null" };
3315
3440
  }
3316
3441
  return resolveTypeNode(
@@ -3330,7 +3455,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
3330
3455
  let typeName = null;
3331
3456
  let namedDecl;
3332
3457
  if (recovered !== null) {
3333
- const recoveredAliasDecl = ts6.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
3458
+ const recoveredAliasDecl = ts5.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
3334
3459
  if (recoveredAliasDecl !== void 0) {
3335
3460
  const aliasUnderlyingType = checker.getTypeFromTypeNode(recoveredAliasDecl.type);
3336
3461
  const isNonGeneric = recoveredAliasDecl.typeParameters === void 0 || recoveredAliasDecl.typeParameters.length === 0;
@@ -3352,13 +3477,13 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
3352
3477
  (memberTypeNode) => !isNullishTypeNode(resolveAliasedTypeNode(memberTypeNode, checker))
3353
3478
  );
3354
3479
  const nonNullTypes = allTypes.filter(
3355
- (memberType) => !(memberType.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
3480
+ (memberType) => !(memberType.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
3356
3481
  );
3357
3482
  const nonNullMembers = nonNullTypes.map((memberType, index) => ({
3358
3483
  memberType,
3359
3484
  sourceNode: nonNullSourceNodes.length === nonNullTypes.length ? nonNullSourceNodes[index] : void 0
3360
3485
  }));
3361
- const hasNull = allTypes.some((t) => t.flags & ts6.TypeFlags.Null);
3486
+ const hasNull = allTypes.some((t) => t.flags & ts5.TypeFlags.Null);
3362
3487
  const memberDisplayNames = /* @__PURE__ */ new Map();
3363
3488
  if (namedDecl) {
3364
3489
  for (const [value, label] of extractDisplayNameMetadata(namedDecl).memberDisplayNames) {
@@ -3378,7 +3503,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
3378
3503
  if (existing !== void 0 && existing.type !== RESOLVING_TYPE_PLACEHOLDER) {
3379
3504
  return { kind: "reference", name: typeName, typeArguments: [] };
3380
3505
  }
3381
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
3506
+ const annotations = namedDecl ? extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) : void 0;
3382
3507
  const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
3383
3508
  metadataPolicy,
3384
3509
  "type",
@@ -3405,7 +3530,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
3405
3530
  const displayName = memberDisplayNames.get(String(value));
3406
3531
  return displayName !== void 0 ? { value, displayName } : { value };
3407
3532
  });
3408
- const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts6.TypeFlags.BooleanLiteral);
3533
+ const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts5.TypeFlags.BooleanLiteral);
3409
3534
  if (isBooleanUnion2) {
3410
3535
  const boolNode = { kind: "primitive", primitiveKind: "boolean" };
3411
3536
  const result = hasNull ? {
@@ -3497,7 +3622,7 @@ function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metad
3497
3622
  if (type.getProperties().length > 0) {
3498
3623
  return null;
3499
3624
  }
3500
- const indexInfo = checker.getIndexInfoOfType(type, ts6.IndexKind.String);
3625
+ const indexInfo = checker.getIndexInfoOfType(type, ts5.IndexKind.String);
3501
3626
  if (!indexInfo) {
3502
3627
  return null;
3503
3628
  }
@@ -3545,20 +3670,53 @@ function shouldEmitResolvedObjectProperty(property, declaration) {
3545
3670
  }
3546
3671
  if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
3547
3672
  const name = declaration.name;
3548
- if (ts6.isComputedPropertyName(name) || ts6.isPrivateIdentifier(name)) {
3673
+ if (ts5.isComputedPropertyName(name) || ts5.isPrivateIdentifier(name)) {
3549
3674
  return false;
3550
3675
  }
3551
- if (!ts6.isIdentifier(name) && !ts6.isStringLiteral(name) && !ts6.isNumericLiteral(name)) {
3676
+ if (!ts5.isIdentifier(name) && !ts5.isStringLiteral(name) && !ts5.isNumericLiteral(name)) {
3552
3677
  return false;
3553
3678
  }
3554
3679
  }
3555
3680
  return true;
3556
3681
  }
3682
+ function getPassThroughTypeAliasFromSourceNode(sourceNode, checker, extensionRegistry, resolvedTypeName) {
3683
+ const aliasDecl = getReferencedTypeAliasDeclaration(sourceNode, checker);
3684
+ if (!aliasDecl) return void 0;
3685
+ const aliasName = aliasDecl.name.text;
3686
+ if (aliasName === resolvedTypeName) return void 0;
3687
+ if (!ts5.isTypeReferenceNode(aliasDecl.type)) return void 0;
3688
+ if (!hasInheritableTypeAnnotation(aliasDecl, checker, extensionRegistry)) {
3689
+ return void 0;
3690
+ }
3691
+ return { aliasName, aliasDecl };
3692
+ }
3693
+ function hasInheritableTypeAnnotation(aliasDecl, checker, extensionRegistry) {
3694
+ const file = aliasDecl.getSourceFile().fileName;
3695
+ const local = extractJSDocAnnotationNodes(aliasDecl, file, makeParseOptions(extensionRegistry));
3696
+ for (const annotation of local) {
3697
+ if (!INHERITABLE_TYPE_ANNOTATION_KINDS.has(annotation.annotationKind)) continue;
3698
+ if (!isOverridingInheritableAnnotation(annotation)) continue;
3699
+ return true;
3700
+ }
3701
+ const inherited = collectInheritedTypeAnnotations(aliasDecl, local, checker, extensionRegistry);
3702
+ for (const annotation of inherited) {
3703
+ if (INHERITABLE_TYPE_ANNOTATION_KINDS.has(annotation.annotationKind)) return true;
3704
+ }
3705
+ return false;
3706
+ }
3557
3707
  function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3558
3708
  const collectedDiagnostics = diagnostics ?? [];
3559
3709
  const typeName = getNamedTypeName(type);
3560
3710
  const namedTypeName = typeName ?? void 0;
3561
3711
  const namedDecl = getNamedTypeDeclaration(type);
3712
+ const passThroughAlias = getPassThroughTypeAliasFromSourceNode(
3713
+ sourceNode,
3714
+ checker,
3715
+ extensionRegistry,
3716
+ namedTypeName
3717
+ );
3718
+ const effectiveTypeName = passThroughAlias?.aliasName ?? namedTypeName;
3719
+ const effectiveNamedDecl = passThroughAlias?.aliasDecl ?? namedDecl;
3562
3720
  const referenceTypeArguments = extractReferenceTypeArguments(
3563
3721
  type,
3564
3722
  checker,
@@ -3570,13 +3728,13 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3570
3728
  extensionRegistry,
3571
3729
  collectedDiagnostics
3572
3730
  );
3573
- const instantiatedTypeName = namedTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
3574
- namedTypeName,
3731
+ const instantiatedTypeName = effectiveTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
3732
+ effectiveTypeName,
3575
3733
  referenceTypeArguments.map((argument) => argument.tsType),
3576
3734
  checker
3577
3735
  ) : void 0;
3578
- const registryTypeName = instantiatedTypeName ?? namedTypeName;
3579
- const shouldRegisterNamedType = registryTypeName !== void 0 && !(registryTypeName === "Record" && namedDecl?.getSourceFile().fileName !== file);
3736
+ const registryTypeName = instantiatedTypeName ?? effectiveTypeName;
3737
+ const shouldRegisterNamedType = registryTypeName !== void 0 && !(registryTypeName === "Record" && effectiveNamedDecl?.getSourceFile().fileName !== file);
3580
3738
  const clearNamedTypeRegistration = () => {
3581
3739
  if (registryTypeName === void 0 || !shouldRegisterNamedType) {
3582
3740
  return;
@@ -3597,7 +3755,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3597
3755
  typeRegistry[registryTypeName] = {
3598
3756
  name: registryTypeName,
3599
3757
  type: RESOLVING_TYPE_PLACEHOLDER,
3600
- provenance: provenanceForDeclaration(namedDecl, file)
3758
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
3601
3759
  };
3602
3760
  }
3603
3761
  visiting.add(type);
@@ -3629,17 +3787,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3629
3787
  clearNamedTypeRegistration();
3630
3788
  return recordNode;
3631
3789
  }
3632
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
3633
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
3790
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
3791
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
3634
3792
  metadataPolicy,
3635
3793
  "type",
3636
3794
  registryTypeName,
3637
- namedDecl,
3795
+ effectiveNamedDecl,
3638
3796
  checker,
3639
3797
  extensionRegistry,
3640
3798
  {
3641
3799
  checker,
3642
- declaration: namedDecl,
3800
+ declaration: effectiveNamedDecl,
3643
3801
  subjectType: type
3644
3802
  }
3645
3803
  ) : void 0;
@@ -3648,7 +3806,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3648
3806
  ...metadata !== void 0 && { metadata },
3649
3807
  type: recordNode,
3650
3808
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
3651
- provenance: provenanceForDeclaration(namedDecl, file)
3809
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
3652
3810
  };
3653
3811
  return {
3654
3812
  kind: "reference",
@@ -3674,7 +3832,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3674
3832
  if (!declaration) continue;
3675
3833
  if (!shouldEmitResolvedObjectProperty(prop, declaration)) continue;
3676
3834
  const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);
3677
- const optional = !!(prop.flags & ts6.SymbolFlags.Optional);
3835
+ const optional = !!(prop.flags & ts5.SymbolFlags.Optional);
3678
3836
  const propTypeNode = resolveTypeNode(
3679
3837
  propType,
3680
3838
  checker,
@@ -3687,7 +3845,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3687
3845
  collectedDiagnostics
3688
3846
  );
3689
3847
  const fieldNodeInfo = fieldInfoMap?.get(prop.name);
3690
- const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts6.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
3848
+ const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts5.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
3691
3849
  declaration,
3692
3850
  checker,
3693
3851
  file,
@@ -3697,7 +3855,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3697
3855
  type,
3698
3856
  metadataPolicy,
3699
3857
  extensionRegistry
3700
- ) : ts6.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
3858
+ ) : ts5.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
3701
3859
  declaration,
3702
3860
  checker,
3703
3861
  file,
@@ -3725,9 +3883,9 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3725
3883
  visiting.delete(type);
3726
3884
  const objectNode = {
3727
3885
  kind: "object",
3728
- properties: namedDecl !== void 0 && (ts6.isClassDeclaration(namedDecl) || ts6.isInterfaceDeclaration(namedDecl) || ts6.isTypeAliasDeclaration(namedDecl)) ? applyDiscriminatorToObjectProperties(
3886
+ properties: effectiveNamedDecl !== void 0 && (ts5.isClassDeclaration(effectiveNamedDecl) || ts5.isInterfaceDeclaration(effectiveNamedDecl) || ts5.isTypeAliasDeclaration(effectiveNamedDecl)) ? applyDiscriminatorToObjectProperties(
3729
3887
  properties,
3730
- namedDecl,
3888
+ effectiveNamedDecl,
3731
3889
  type,
3732
3890
  checker,
3733
3891
  file,
@@ -3737,17 +3895,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3737
3895
  additionalProperties: true
3738
3896
  };
3739
3897
  if (registryTypeName !== void 0 && shouldRegisterNamedType) {
3740
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
3741
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
3898
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
3899
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
3742
3900
  metadataPolicy,
3743
3901
  "type",
3744
3902
  registryTypeName,
3745
- namedDecl,
3903
+ effectiveNamedDecl,
3746
3904
  checker,
3747
3905
  extensionRegistry,
3748
3906
  {
3749
3907
  checker,
3750
- declaration: namedDecl,
3908
+ declaration: effectiveNamedDecl,
3751
3909
  subjectType: type
3752
3910
  }
3753
3911
  ) : void 0;
@@ -3756,7 +3914,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3756
3914
  ...metadata !== void 0 && { metadata },
3757
3915
  type: objectNode,
3758
3916
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
3759
- provenance: provenanceForDeclaration(namedDecl, file)
3917
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
3760
3918
  };
3761
3919
  return {
3762
3920
  kind: "reference",
@@ -3773,12 +3931,12 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
3773
3931
  for (const symbol of symbols) {
3774
3932
  const declarations = symbol.declarations;
3775
3933
  if (!declarations) continue;
3776
- const classDecl = declarations.find(ts6.isClassDeclaration);
3934
+ const classDecl = declarations.find(ts5.isClassDeclaration);
3777
3935
  if (classDecl) {
3778
3936
  const map = /* @__PURE__ */ new Map();
3779
3937
  const hostType = checker.getTypeAtLocation(classDecl);
3780
3938
  for (const member of classDecl.members) {
3781
- if (ts6.isPropertyDeclaration(member) && ts6.isIdentifier(member.name)) {
3939
+ if (ts5.isPropertyDeclaration(member) && ts5.isIdentifier(member.name)) {
3782
3940
  const fieldNode = analyzeFieldToIR(
3783
3941
  member,
3784
3942
  checker,
@@ -3802,7 +3960,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
3802
3960
  }
3803
3961
  return map;
3804
3962
  }
3805
- const interfaceDecl = declarations.find(ts6.isInterfaceDeclaration);
3963
+ const interfaceDecl = declarations.find(ts5.isInterfaceDeclaration);
3806
3964
  if (interfaceDecl) {
3807
3965
  return buildFieldNodeInfoMap(
3808
3966
  interfaceDecl.members,
@@ -3816,7 +3974,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
3816
3974
  extensionRegistry
3817
3975
  );
3818
3976
  }
3819
- const typeAliasDecl = declarations.find(ts6.isTypeAliasDeclaration);
3977
+ const typeAliasDecl = declarations.find(ts5.isTypeAliasDeclaration);
3820
3978
  const typeAliasMembers = typeAliasDecl === void 0 ? null : getObjectLikeTypeAliasMembers(typeAliasDecl.type);
3821
3979
  if (typeAliasDecl && typeAliasMembers !== null) {
3822
3980
  return buildFieldNodeInfoMap(
@@ -3840,10 +3998,10 @@ function extractArrayElementTypeNode(sourceNode, checker) {
3840
3998
  return void 0;
3841
3999
  }
3842
4000
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
3843
- if (ts6.isArrayTypeNode(resolvedTypeNode)) {
4001
+ if (ts5.isArrayTypeNode(resolvedTypeNode)) {
3844
4002
  return resolvedTypeNode.elementType;
3845
4003
  }
3846
- if (ts6.isTypeReferenceNode(resolvedTypeNode) && ts6.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
4004
+ if (ts5.isTypeReferenceNode(resolvedTypeNode) && ts5.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
3847
4005
  return resolvedTypeNode.typeArguments[0];
3848
4006
  }
3849
4007
  return void 0;
@@ -3854,13 +4012,13 @@ function extractUnionMemberTypeNodes(sourceNode, checker) {
3854
4012
  return [];
3855
4013
  }
3856
4014
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
3857
- return ts6.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
4015
+ return ts5.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
3858
4016
  }
3859
4017
  function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new Set()) {
3860
- if (ts6.isParenthesizedTypeNode(typeNode)) {
4018
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3861
4019
  return resolveAliasedTypeNode(typeNode.type, checker, visited);
3862
4020
  }
3863
- if (!ts6.isTypeReferenceNode(typeNode) || !ts6.isIdentifier(typeNode.typeName)) {
4021
+ if (!ts5.isTypeReferenceNode(typeNode) || !ts5.isIdentifier(typeNode.typeName)) {
3864
4022
  return typeNode;
3865
4023
  }
3866
4024
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -3871,15 +4029,15 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
3871
4029
  return resolveAliasedTypeNode(aliasDecl.type, checker, visited);
3872
4030
  }
3873
4031
  function isNullishTypeNode(typeNode) {
3874
- if (typeNode.kind === ts6.SyntaxKind.NullKeyword || typeNode.kind === ts6.SyntaxKind.UndefinedKeyword) {
4032
+ if (typeNode.kind === ts5.SyntaxKind.NullKeyword || typeNode.kind === ts5.SyntaxKind.UndefinedKeyword) {
3875
4033
  return true;
3876
4034
  }
3877
- return ts6.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts6.SyntaxKind.NullKeyword || typeNode.literal.kind === ts6.SyntaxKind.UndefinedKeyword);
4035
+ return ts5.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts5.SyntaxKind.NullKeyword || typeNode.literal.kind === ts5.SyntaxKind.UndefinedKeyword);
3878
4036
  }
3879
4037
  function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, metadataPolicy, hostType, diagnostics, extensionRegistry) {
3880
4038
  const map = /* @__PURE__ */ new Map();
3881
4039
  for (const member of members) {
3882
- if (ts6.isPropertySignature(member)) {
4040
+ if (ts5.isPropertySignature(member)) {
3883
4041
  const fieldNode = analyzeInterfacePropertyToIR(
3884
4042
  member,
3885
4043
  checker,
@@ -3905,7 +4063,7 @@ function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, m
3905
4063
  }
3906
4064
  var MAX_ALIAS_CHAIN_DEPTH = 8;
3907
4065
  function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegistry, depth = 0) {
3908
- if (!ts6.isTypeReferenceNode(typeNode)) return [];
4066
+ if (!ts5.isTypeReferenceNode(typeNode)) return [];
3909
4067
  if (depth >= MAX_ALIAS_CHAIN_DEPTH) {
3910
4068
  const aliasName = typeNode.typeName.getText();
3911
4069
  throw new Error(
@@ -3914,7 +4072,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
3914
4072
  }
3915
4073
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
3916
4074
  if (!aliasDecl) return [];
3917
- if (ts6.isTypeLiteralNode(aliasDecl.type)) return [];
4075
+ if (ts5.isTypeLiteralNode(aliasDecl.type)) return [];
3918
4076
  const aliasFieldType = resolveTypeNode(
3919
4077
  checker.getTypeAtLocation(aliasDecl.type),
3920
4078
  checker,
@@ -3958,14 +4116,14 @@ function getNamedTypeName(type) {
3958
4116
  const symbol = type.getSymbol();
3959
4117
  if (symbol?.declarations) {
3960
4118
  const decl = symbol.declarations[0];
3961
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
3962
- const name = ts6.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
4119
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
4120
+ const name = ts5.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
3963
4121
  if (name) return name;
3964
4122
  }
3965
4123
  }
3966
4124
  const aliasSymbol = type.aliasSymbol;
3967
4125
  if (aliasSymbol?.declarations) {
3968
- const aliasDecl = aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
4126
+ const aliasDecl = aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
3969
4127
  if (aliasDecl) {
3970
4128
  return aliasDecl.name.text;
3971
4129
  }
@@ -3976,24 +4134,24 @@ function getNamedTypeDeclaration(type) {
3976
4134
  const symbol = type.getSymbol();
3977
4135
  if (symbol?.declarations) {
3978
4136
  const decl = symbol.declarations[0];
3979
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
4137
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
3980
4138
  return decl;
3981
4139
  }
3982
4140
  }
3983
4141
  const aliasSymbol = type.aliasSymbol;
3984
4142
  if (aliasSymbol?.declarations) {
3985
- return aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
4143
+ return aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
3986
4144
  }
3987
4145
  return void 0;
3988
4146
  }
3989
4147
  function analyzeMethod(method, checker) {
3990
- if (!ts6.isIdentifier(method.name)) {
4148
+ if (!ts5.isIdentifier(method.name)) {
3991
4149
  return null;
3992
4150
  }
3993
4151
  const name = method.name.text;
3994
4152
  const parameters = [];
3995
4153
  for (const param of method.parameters) {
3996
- if (ts6.isIdentifier(param.name)) {
4154
+ if (ts5.isIdentifier(param.name)) {
3997
4155
  const paramInfo = analyzeParameter(param, checker);
3998
4156
  parameters.push(paramInfo);
3999
4157
  }
@@ -4004,7 +4162,7 @@ function analyzeMethod(method, checker) {
4004
4162
  return { name, parameters, returnTypeNode, returnType };
4005
4163
  }
4006
4164
  function analyzeParameter(param, checker) {
4007
- const name = ts6.isIdentifier(param.name) ? param.name.text : "param";
4165
+ const name = ts5.isIdentifier(param.name) ? param.name.text : "param";
4008
4166
  const typeNode = param.type;
4009
4167
  const type = checker.getTypeAtLocation(param);
4010
4168
  const formSpecExportName = detectFormSpecReference(typeNode);
@@ -4013,15 +4171,15 @@ function analyzeParameter(param, checker) {
4013
4171
  }
4014
4172
  function detectFormSpecReference(typeNode) {
4015
4173
  if (!typeNode) return null;
4016
- if (!ts6.isTypeReferenceNode(typeNode)) return null;
4017
- const typeName = ts6.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts6.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
4174
+ if (!ts5.isTypeReferenceNode(typeNode)) return null;
4175
+ const typeName = ts5.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts5.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
4018
4176
  if (typeName !== "InferSchema" && typeName !== "InferFormSchema") return null;
4019
4177
  const typeArg = typeNode.typeArguments?.[0];
4020
- if (!typeArg || !ts6.isTypeQueryNode(typeArg)) return null;
4021
- if (ts6.isIdentifier(typeArg.exprName)) {
4178
+ if (!typeArg || !ts5.isTypeQueryNode(typeArg)) return null;
4179
+ if (ts5.isIdentifier(typeArg.exprName)) {
4022
4180
  return typeArg.exprName.text;
4023
4181
  }
4024
- if (ts6.isQualifiedName(typeArg.exprName)) {
4182
+ if (ts5.isQualifiedName(typeArg.exprName)) {
4025
4183
  return typeArg.exprName.right.text;
4026
4184
  }
4027
4185
  return null;
@@ -4043,23 +4201,23 @@ function createProgramContextFromProgram(program, filePath) {
4043
4201
  function createProgramContext(filePath, additionalFiles) {
4044
4202
  const absolutePath = path.resolve(filePath);
4045
4203
  const fileDir = path.dirname(absolutePath);
4046
- const configPath = ts7.findConfigFile(fileDir, ts7.sys.fileExists.bind(ts7.sys), "tsconfig.json");
4204
+ const configPath = ts6.findConfigFile(fileDir, ts6.sys.fileExists.bind(ts6.sys), "tsconfig.json");
4047
4205
  let compilerOptions;
4048
4206
  let fileNames;
4049
4207
  if (configPath) {
4050
- const configFile = ts7.readConfigFile(configPath, ts7.sys.readFile.bind(ts7.sys));
4208
+ const configFile = ts6.readConfigFile(configPath, ts6.sys.readFile.bind(ts6.sys));
4051
4209
  if (configFile.error) {
4052
4210
  throw new Error(
4053
- `Error reading tsconfig.json: ${ts7.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
4211
+ `Error reading tsconfig.json: ${ts6.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
4054
4212
  );
4055
4213
  }
4056
- const parsed = ts7.parseJsonConfigFileContent(
4214
+ const parsed = ts6.parseJsonConfigFileContent(
4057
4215
  configFile.config,
4058
- ts7.sys,
4216
+ ts6.sys,
4059
4217
  path.dirname(configPath)
4060
4218
  );
4061
4219
  if (parsed.errors.length > 0) {
4062
- const errorMessages = parsed.errors.map((e) => ts7.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
4220
+ const errorMessages = parsed.errors.map((e) => ts6.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
4063
4221
  throw new Error(`Error parsing tsconfig.json: ${errorMessages}`);
4064
4222
  }
4065
4223
  compilerOptions = parsed.options;
@@ -4067,9 +4225,9 @@ function createProgramContext(filePath, additionalFiles) {
4067
4225
  fileNames = [.../* @__PURE__ */ new Set([...parsed.fileNames, absolutePath, ...normalizedAdditional])];
4068
4226
  } else {
4069
4227
  compilerOptions = {
4070
- target: ts7.ScriptTarget.ES2022,
4071
- module: ts7.ModuleKind.NodeNext,
4072
- moduleResolution: ts7.ModuleResolutionKind.NodeNext,
4228
+ target: ts6.ScriptTarget.ES2022,
4229
+ module: ts6.ModuleKind.NodeNext,
4230
+ moduleResolution: ts6.ModuleResolutionKind.NodeNext,
4073
4231
  strict: true,
4074
4232
  skipLibCheck: true,
4075
4233
  declaration: true
@@ -4077,7 +4235,7 @@ function createProgramContext(filePath, additionalFiles) {
4077
4235
  const normalizedAdditional = (additionalFiles ?? []).map((f) => path.resolve(f));
4078
4236
  fileNames = [.../* @__PURE__ */ new Set([absolutePath, ...normalizedAdditional])];
4079
4237
  }
4080
- const program = ts7.createProgram(fileNames, compilerOptions);
4238
+ const program = ts6.createProgram(fileNames, compilerOptions);
4081
4239
  const sourceFile = program.getSourceFile(absolutePath);
4082
4240
  if (!sourceFile) {
4083
4241
  throw new Error(`Could not find source file: ${absolutePath}`);
@@ -4096,19 +4254,19 @@ function findNodeByName(sourceFile, name, predicate, getName) {
4096
4254
  result = node;
4097
4255
  return;
4098
4256
  }
4099
- ts7.forEachChild(node, visit);
4257
+ ts6.forEachChild(node, visit);
4100
4258
  }
4101
4259
  visit(sourceFile);
4102
4260
  return result;
4103
4261
  }
4104
4262
  function findClassByName(sourceFile, className) {
4105
- return findNodeByName(sourceFile, className, ts7.isClassDeclaration, (n) => n.name?.text);
4263
+ return findNodeByName(sourceFile, className, ts6.isClassDeclaration, (n) => n.name?.text);
4106
4264
  }
4107
4265
  function findInterfaceByName(sourceFile, interfaceName) {
4108
- return findNodeByName(sourceFile, interfaceName, ts7.isInterfaceDeclaration, (n) => n.name.text);
4266
+ return findNodeByName(sourceFile, interfaceName, ts6.isInterfaceDeclaration, (n) => n.name.text);
4109
4267
  }
4110
4268
  function findTypeAliasByName(sourceFile, aliasName) {
4111
- return findNodeByName(sourceFile, aliasName, ts7.isTypeAliasDeclaration, (n) => n.name.text);
4269
+ return findNodeByName(sourceFile, aliasName, ts6.isTypeAliasDeclaration, (n) => n.name.text);
4112
4270
  }
4113
4271
  function getResolvedObjectRootType(rootType, typeRegistry) {
4114
4272
  if (rootType.kind === "object") {
@@ -4148,22 +4306,22 @@ function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInf
4148
4306
  };
4149
4307
  }
4150
4308
  function containsTypeReferenceInObjectLikeAlias(typeNode) {
4151
- if (ts7.isParenthesizedTypeNode(typeNode)) {
4309
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
4152
4310
  return containsTypeReferenceInObjectLikeAlias(typeNode.type);
4153
4311
  }
4154
- if (ts7.isTypeReferenceNode(typeNode)) {
4312
+ if (ts6.isTypeReferenceNode(typeNode)) {
4155
4313
  return true;
4156
4314
  }
4157
- return ts7.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
4315
+ return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
4158
4316
  }
4159
4317
  function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
4160
- if (ts7.isParenthesizedTypeNode(typeNode)) {
4318
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
4161
4319
  return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
4162
4320
  }
4163
- if (ts7.isTypeLiteralNode(typeNode)) {
4321
+ if (ts6.isTypeLiteralNode(typeNode)) {
4164
4322
  const propertyNames = [];
4165
4323
  for (const member of typeNode.members) {
4166
- if (!ts7.isPropertySignature(member)) {
4324
+ if (!ts6.isPropertySignature(member)) {
4167
4325
  continue;
4168
4326
  }
4169
4327
  const propertyName = getAnalyzableObjectLikePropertyName(member.name);
@@ -4173,13 +4331,13 @@ function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
4173
4331
  }
4174
4332
  return propertyNames;
4175
4333
  }
4176
- if (ts7.isTypeReferenceNode(typeNode)) {
4334
+ if (ts6.isTypeReferenceNode(typeNode)) {
4177
4335
  return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
4178
4336
  }
4179
4337
  return null;
4180
4338
  }
4181
4339
  function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
4182
- if (!ts7.isIntersectionTypeNode(typeNode)) {
4340
+ if (!ts6.isIntersectionTypeNode(typeNode)) {
4183
4341
  return [];
4184
4342
  }
4185
4343
  const seen = /* @__PURE__ */ new Set();
@@ -4369,7 +4527,7 @@ function makeFileProvenance(filePath) {
4369
4527
  }
4370
4528
 
4371
4529
  // src/generators/class-schema.ts
4372
- var ts9 = __toESM(require("typescript"), 1);
4530
+ var ts8 = __toESM(require("typescript"), 1);
4373
4531
 
4374
4532
  // src/metadata/collision-guards.ts
4375
4533
  function assertUniqueSerializedNames(entries, scope) {
@@ -4538,7 +4696,7 @@ function generateJsonSchemaFromIR(ir, options) {
4538
4696
  applyConstraints(ctx.defs[schemaName], typeDef.constraints, ctx);
4539
4697
  }
4540
4698
  if (typeDef.annotations && typeDef.annotations.length > 0) {
4541
- applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx);
4699
+ applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx, typeDef.type);
4542
4700
  }
4543
4701
  }
4544
4702
  const properties = {};
@@ -4611,7 +4769,7 @@ function generateFieldSchema(field, ctx) {
4611
4769
  }
4612
4770
  }
4613
4771
  applyResolvedMetadata(schema, field.metadata);
4614
- applyAnnotations(schema, rootAnnotations, ctx);
4772
+ applyAnnotations(schema, rootAnnotations, ctx, field.type);
4615
4773
  if (itemStringSchema !== void 0) {
4616
4774
  applyAnnotations(itemStringSchema, itemAnnotations, ctx);
4617
4775
  }
@@ -4654,32 +4812,36 @@ function applyPathTargetedConstraints(schema, pathConstraints, ctx, typeNode) {
4654
4812
  return schema;
4655
4813
  }
4656
4814
  if (schema.$ref) {
4657
- const { $ref, ...rest } = schema;
4658
- const refPart = { $ref };
4659
- const overridePart = {
4660
- properties: propertyOverrides,
4661
- ...rest
4815
+ return {
4816
+ ...schema,
4817
+ properties: propertyOverrides
4662
4818
  };
4663
- return { allOf: [refPart, overridePart] };
4664
4819
  }
4665
4820
  if (schema.type === "object" && schema.properties) {
4666
- const missingOverrides = {};
4667
4821
  for (const [target, overrideSchema] of Object.entries(propertyOverrides)) {
4668
- if (schema.properties[target]) {
4669
- mergeSchemaOverride(schema.properties[target], overrideSchema);
4670
- } else {
4671
- missingOverrides[target] = overrideSchema;
4822
+ if (Object.hasOwn(schema.properties, target)) {
4823
+ const existing = schema.properties[target];
4824
+ if (existing) {
4825
+ mergeSchemaOverride(existing, overrideSchema);
4826
+ continue;
4827
+ }
4672
4828
  }
4829
+ Object.defineProperty(schema.properties, target, {
4830
+ value: overrideSchema,
4831
+ writable: true,
4832
+ enumerable: true,
4833
+ configurable: true
4834
+ });
4673
4835
  }
4674
- if (Object.keys(missingOverrides).length === 0) {
4675
- return schema;
4676
- }
4677
- return {
4678
- allOf: [schema, { properties: missingOverrides }]
4679
- };
4836
+ return schema;
4680
4837
  }
4681
4838
  if (schema.allOf) {
4682
- schema.allOf = [...schema.allOf, { properties: propertyOverrides }];
4839
+ const overrideMember = { properties: propertyOverrides };
4840
+ const flattened = tryFlattenAllOfToSiblings(schema, overrideMember);
4841
+ if (flattened !== void 0) {
4842
+ return flattened;
4843
+ }
4844
+ schema.allOf = [...schema.allOf, overrideMember];
4683
4845
  return schema;
4684
4846
  }
4685
4847
  return schema;
@@ -4792,7 +4954,7 @@ function generatePropertySchema(prop, ctx) {
4792
4954
  const schema = generateTypeNode(prop.type, ctx);
4793
4955
  applyConstraints(schema, prop.constraints, ctx);
4794
4956
  applyResolvedMetadata(schema, prop.metadata);
4795
- applyAnnotations(schema, prop.annotations, ctx);
4957
+ applyAnnotations(schema, prop.annotations, ctx, prop.type);
4796
4958
  return schema;
4797
4959
  }
4798
4960
  function generateUnionType(type, ctx) {
@@ -4895,13 +5057,20 @@ function buildPropertyOverrides(pathConstraints, typeNode, ctx) {
4895
5057
  grouped.push(constraint);
4896
5058
  byTarget.set(target, grouped);
4897
5059
  }
4898
- const overrides = {};
5060
+ const overrides = /* @__PURE__ */ Object.create(null);
4899
5061
  for (const [target, constraints] of byTarget) {
4900
- overrides[resolveSerializedPropertyName(target, typeNode, ctx)] = buildPathOverrideSchema(
5062
+ const resolvedName = resolveSerializedPropertyName(target, typeNode, ctx);
5063
+ const schema = buildPathOverrideSchema(
4901
5064
  constraints.map(stripLeadingPathSegment),
4902
5065
  resolveTargetTypeNode(target, typeNode, ctx),
4903
5066
  ctx
4904
5067
  );
5068
+ Object.defineProperty(overrides, resolvedName, {
5069
+ value: schema,
5070
+ writable: true,
5071
+ enumerable: true,
5072
+ configurable: true
5073
+ });
4905
5074
  }
4906
5075
  return overrides;
4907
5076
  }
@@ -4928,6 +5097,34 @@ function buildPathOverrideSchema(constraints, typeNode, ctx) {
4928
5097
  schema.properties = buildPropertyOverrides(nestedConstraints, effectiveType, ctx);
4929
5098
  return schema;
4930
5099
  }
5100
+ function tryFlattenAllOfToSiblings(schema, overrideMember) {
5101
+ if (schema.allOf?.length !== 1) {
5102
+ return void 0;
5103
+ }
5104
+ const [soleMember] = schema.allOf;
5105
+ if (soleMember === void 0) {
5106
+ return void 0;
5107
+ }
5108
+ const { allOf: _allOf, ...outerRest } = schema;
5109
+ const outerKeys = new Set(Object.keys(outerRest));
5110
+ const memberKeys = new Set(Object.keys(soleMember));
5111
+ const overrideKeys = new Set(Object.keys(overrideMember));
5112
+ for (const key of memberKeys) {
5113
+ if (outerKeys.has(key) || overrideKeys.has(key)) {
5114
+ return void 0;
5115
+ }
5116
+ }
5117
+ for (const key of overrideKeys) {
5118
+ if (outerKeys.has(key)) {
5119
+ return void 0;
5120
+ }
5121
+ }
5122
+ return {
5123
+ ...outerRest,
5124
+ ...soleMember,
5125
+ ...overrideMember
5126
+ };
5127
+ }
4931
5128
  function mergeSchemaOverride(target, override) {
4932
5129
  const nullableValueBranch = getNullableUnionValueSchema(target);
4933
5130
  if (nullableValueBranch !== void 0) {
@@ -4935,11 +5132,16 @@ function mergeSchemaOverride(target, override) {
4935
5132
  return;
4936
5133
  }
4937
5134
  if (override.properties !== void 0) {
4938
- const mergedProperties = target.properties ?? {};
5135
+ const mergedProperties = target.properties ?? /* @__PURE__ */ Object.create(null);
4939
5136
  for (const [name, propertyOverride] of Object.entries(override.properties)) {
4940
- const existing = mergedProperties[name];
5137
+ const existing = Object.hasOwn(mergedProperties, name) ? mergedProperties[name] : void 0;
4941
5138
  if (existing === void 0) {
4942
- mergedProperties[name] = propertyOverride;
5139
+ Object.defineProperty(mergedProperties, name, {
5140
+ value: propertyOverride,
5141
+ writable: true,
5142
+ enumerable: true,
5143
+ configurable: true
5144
+ });
4943
5145
  } else {
4944
5146
  mergeSchemaOverride(existing, propertyOverride);
4945
5147
  }
@@ -4957,7 +5159,12 @@ function mergeSchemaOverride(target, override) {
4957
5159
  if (key === "properties" || key === "items") {
4958
5160
  continue;
4959
5161
  }
4960
- target[key] = value;
5162
+ Object.defineProperty(target, key, {
5163
+ value,
5164
+ writable: true,
5165
+ enumerable: true,
5166
+ configurable: true
5167
+ });
4961
5168
  }
4962
5169
  }
4963
5170
  function stripLeadingPathSegment(constraint) {
@@ -5057,7 +5264,7 @@ function applyConstraints(schema, constraints, ctx) {
5057
5264
  }
5058
5265
  }
5059
5266
  }
5060
- function applyAnnotations(schema, annotations, ctx) {
5267
+ function applyAnnotations(schema, annotations, ctx, typeNode) {
5061
5268
  for (const annotation of annotations) {
5062
5269
  switch (annotation.annotationKind) {
5063
5270
  case "displayName":
@@ -5070,7 +5277,7 @@ function applyAnnotations(schema, annotations, ctx) {
5070
5277
  schema[`${ctx.vendorPrefix}-remarks`] = annotation.value;
5071
5278
  break;
5072
5279
  case "defaultValue":
5073
- schema.default = annotation.value;
5280
+ schema.default = coerceDefaultValue(annotation.value, typeNode, schema, ctx);
5074
5281
  break;
5075
5282
  case "format":
5076
5283
  schema.format = annotation.value;
@@ -5095,6 +5302,34 @@ function applyAnnotations(schema, annotations, ctx) {
5095
5302
  }
5096
5303
  }
5097
5304
  }
5305
+ function coerceDefaultValue(value, typeNode, emittedSchema, ctx) {
5306
+ if (typeNode?.kind !== "custom") {
5307
+ return value;
5308
+ }
5309
+ const registration = ctx.extensionRegistry?.findType(typeNode.typeId);
5310
+ if (registration === void 0) {
5311
+ return value;
5312
+ }
5313
+ if (registration.serializeDefault !== void 0) {
5314
+ return registration.serializeDefault(value, typeNode.payload);
5315
+ }
5316
+ const declaredType = emittedSchema["type"];
5317
+ if (declaredType === "string" && typeof value !== "string") {
5318
+ if (typeof value === "number") {
5319
+ if (!Number.isFinite(value)) {
5320
+ return value;
5321
+ }
5322
+ return String(value);
5323
+ }
5324
+ if (typeof value === "boolean") {
5325
+ return String(value);
5326
+ }
5327
+ if (typeof value === "bigint") {
5328
+ return value.toString();
5329
+ }
5330
+ }
5331
+ return value;
5332
+ }
5098
5333
  function generateCustomType(type, ctx) {
5099
5334
  const registration = ctx.extensionRegistry?.findType(type.typeId);
5100
5335
  if (registration === void 0) {
@@ -5221,25 +5456,41 @@ function assignVendorPrefixedExtensionKeywords(schema, extensionSchema, vendorPr
5221
5456
 
5222
5457
  // src/extensions/registry.ts
5223
5458
  var import_internals5 = require("@formspec/core/internals");
5224
- var import_internal5 = require("@formspec/analysis/internal");
5459
+ var import_internal6 = require("@formspec/analysis/internal");
5225
5460
  var BUILTIN_METADATA_TAGS = /* @__PURE__ */ new Set(["apiName", "displayName"]);
5226
5461
  function buildConstraintTagSources(extensions) {
5227
5462
  return extensions.map((extension) => ({
5228
5463
  extensionId: extension.extensionId,
5229
5464
  ...extension.constraintTags !== void 0 ? {
5230
5465
  constraintTags: extension.constraintTags.map((tag) => ({
5231
- tagName: (0, import_internal5.normalizeFormSpecTagName)(tag.tagName)
5466
+ tagName: (0, import_internal6.normalizeFormSpecTagName)(tag.tagName)
5467
+ }))
5468
+ } : {},
5469
+ // Include customTypes so _validateExtensionSetup can check tsTypeNames for
5470
+ // unsupported built-in overrides and invalid identifier patterns.
5471
+ ...extension.types !== void 0 ? {
5472
+ customTypes: extension.types.map((type) => ({
5473
+ // tsTypeNames: deprecated in favour of symbol-based detection, but
5474
+ // still required for name-based validation in _validateExtensionSetup
5475
+ // until the bridge is fully retired (see §synthetic-checker-retirement §4C).
5476
+ tsTypeNames: type.tsTypeNames ?? [type.typeName]
5232
5477
  }))
5233
5478
  } : {}
5234
5479
  }));
5235
5480
  }
5236
5481
  function createExtensionRegistry(extensions) {
5237
- const registryLog = (0, import_internal5.getSyntheticLogger)();
5482
+ const registryLog = (0, import_internal6.getSyntheticLogger)();
5238
5483
  registryLog.debug("createExtensionRegistry: constructing", {
5239
5484
  extensionCount: extensions.length,
5240
5485
  extensionIds: extensions.map((e) => e.extensionId)
5241
5486
  });
5242
- const reservedTagSources = buildConstraintTagSources(extensions);
5487
+ const extensionTagSources = buildConstraintTagSources(extensions);
5488
+ const setupDiagnostics = (0, import_internal6._validateExtensionSetup)(extensionTagSources);
5489
+ (0, import_internal6.logSetupDiagnostics)(registryLog, {
5490
+ diagnosticCount: setupDiagnostics.length,
5491
+ codes: setupDiagnostics.map((d) => d.kind)
5492
+ });
5493
+ const reservedTagSources = extensionTagSources;
5243
5494
  let symbolMap = /* @__PURE__ */ new Map();
5244
5495
  const typeMap = /* @__PURE__ */ new Map();
5245
5496
  const typeNameMap = /* @__PURE__ */ new Map();
@@ -5306,7 +5557,7 @@ function createExtensionRegistry(extensions) {
5306
5557
  }
5307
5558
  if (ext.constraintTags !== void 0) {
5308
5559
  for (const tag of ext.constraintTags) {
5309
- const canonicalTagName = (0, import_internal5.normalizeFormSpecTagName)(tag.tagName);
5560
+ const canonicalTagName = (0, import_internal6.normalizeFormSpecTagName)(tag.tagName);
5310
5561
  if (constraintTagMap.has(canonicalTagName)) {
5311
5562
  throw new Error(`Duplicate custom constraint tag: "@${canonicalTagName}"`);
5312
5563
  }
@@ -5331,7 +5582,7 @@ function createExtensionRegistry(extensions) {
5331
5582
  throw new Error(`Duplicate metadata slot ID: "${slot.slotId}"`);
5332
5583
  }
5333
5584
  metadataSlotMap.set(slot.slotId, true);
5334
- const canonicalTagName = (0, import_internal5.normalizeFormSpecTagName)(slot.tagName);
5585
+ const canonicalTagName = (0, import_internal6.normalizeFormSpecTagName)(slot.tagName);
5335
5586
  if (slot.allowBare === false && (slot.qualifiers?.length ?? 0) === 0) {
5336
5587
  throw new Error(
5337
5588
  `Metadata tag "@${canonicalTagName}" must allow bare usage or declare at least one qualifier.`
@@ -5358,7 +5609,7 @@ function createExtensionRegistry(extensions) {
5358
5609
  `Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${(0, import_internals5.normalizeConstraintTagName)(canonicalTagName)}".`
5359
5610
  );
5360
5611
  }
5361
- const existingTag = (0, import_internal5.getTagDefinition)(canonicalTagName, reservedTagSources);
5612
+ const existingTag = (0, import_internal6.getTagDefinition)(canonicalTagName, reservedTagSources);
5362
5613
  if (existingTag !== null) {
5363
5614
  throw BUILTIN_METADATA_TAGS.has(existingTag.canonicalName) ? new Error(
5364
5615
  `Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
@@ -5376,10 +5627,12 @@ function createExtensionRegistry(extensions) {
5376
5627
  constraintTagCount: constraintTagMap.size,
5377
5628
  broadeningCount: builtinBroadeningMap.size,
5378
5629
  annotationCount: annotationMap.size,
5379
- metadataSlotCount: metadataSlotMap.size
5630
+ metadataSlotCount: metadataSlotMap.size,
5631
+ setupDiagnosticCount: setupDiagnostics.length
5380
5632
  });
5381
5633
  return {
5382
5634
  extensions,
5635
+ setupDiagnostics,
5383
5636
  findType: (typeId) => typeMap.get(typeId),
5384
5637
  findTypeByName: (typeName) => typeNameMap.get(typeName),
5385
5638
  findTypeByBrand: (brand) => brandMap.get(brand),
@@ -5388,14 +5641,14 @@ function createExtensionRegistry(extensions) {
5388
5641
  symbolMap = map;
5389
5642
  },
5390
5643
  findConstraint: (constraintId) => constraintMap.get(constraintId),
5391
- findConstraintTag: (tagName) => constraintTagMap.get((0, import_internal5.normalizeFormSpecTagName)(tagName)),
5644
+ findConstraintTag: (tagName) => constraintTagMap.get((0, import_internal6.normalizeFormSpecTagName)(tagName)),
5392
5645
  findBuiltinConstraintBroadening: (typeId, tagName) => builtinBroadeningMap.get(`${typeId}:${tagName}`),
5393
5646
  findAnnotation: (annotationId) => annotationMap.get(annotationId)
5394
5647
  };
5395
5648
  }
5396
5649
 
5397
5650
  // src/extensions/symbol-registry.ts
5398
- var ts8 = __toESM(require("typescript"), 1);
5651
+ var ts7 = __toESM(require("typescript"), 1);
5399
5652
  var path2 = __toESM(require("path"), 1);
5400
5653
 
5401
5654
  // src/ui-schema/schema.ts
@@ -5656,9 +5909,9 @@ function collectFieldNameMap(elements) {
5656
5909
  }
5657
5910
 
5658
5911
  // src/validate/constraint-validator.ts
5659
- var import_internal6 = require("@formspec/analysis/internal");
5912
+ var import_internal7 = require("@formspec/analysis/internal");
5660
5913
  function validateFieldNode(ctx, field) {
5661
- const analysis = (0, import_internal6.analyzeConstraintTargets)(
5914
+ const analysis = (0, import_internal7.analyzeConstraintTargets)(
5662
5915
  field.name,
5663
5916
  field.type,
5664
5917
  field.constraints,
@@ -5676,7 +5929,7 @@ function validateFieldNode(ctx, field) {
5676
5929
  }
5677
5930
  function validateObjectProperty(ctx, parentName, property) {
5678
5931
  const qualifiedName = `${parentName}.${property.name}`;
5679
- const analysis = (0, import_internal6.analyzeConstraintTargets)(
5932
+ const analysis = (0, import_internal7.analyzeConstraintTargets)(
5680
5933
  qualifiedName,
5681
5934
  property.type,
5682
5935
  property.constraints,
@@ -5788,7 +6041,7 @@ function formatLocation(location) {
5788
6041
  }
5789
6042
  function resolveStaticOptions(options) {
5790
6043
  const legacyRegistry = options.extensionRegistry;
5791
- const configRegistry = legacyRegistry === void 0 && options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
6044
+ const configRegistry = legacyRegistry === void 0 && options.config?.extensions !== void 0 && options.config.extensions.length > 0 ? createExtensionRegistry(options.config.extensions) : void 0;
5792
6045
  return {
5793
6046
  extensionRegistry: legacyRegistry ?? configRegistry,
5794
6047
  // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields