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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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);
@@ -1142,6 +1122,7 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
1142
1122
  sourceFile,
1143
1123
  tagName,
1144
1124
  parsedTag,
1125
+ text,
1145
1126
  provenance,
1146
1127
  supportingDeclarations,
1147
1128
  options
@@ -1150,7 +1131,7 @@ function processConstraintTag(tagName, text, parsedTag, provenance, node, source
1150
1131
  pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
1151
1132
  return;
1152
1133
  }
1153
- const constraintNode = (0, import_internal2.parseConstraintTagValue)(
1134
+ const constraintNode = (0, import_internal3.parseConstraintTagValue)(
1154
1135
  tagName,
1155
1136
  text,
1156
1137
  provenance,
@@ -1169,6 +1150,9 @@ function renderSyntheticArgumentExpression(valueKind, argumentText) {
1169
1150
  case "number":
1170
1151
  case "integer":
1171
1152
  case "signedInteger":
1153
+ if (trimmed === "Infinity" || trimmed === "-Infinity" || trimmed === "NaN") {
1154
+ return trimmed;
1155
+ }
1172
1156
  return Number.isFinite(Number(trimmed)) ? trimmed : JSON.stringify(trimmed);
1173
1157
  case "string":
1174
1158
  return JSON.stringify(argumentText);
@@ -1200,12 +1184,12 @@ function supportsConstraintCapability(type, checker, capability) {
1200
1184
  if (capability === void 0) {
1201
1185
  return true;
1202
1186
  }
1203
- if ((0, import_internal2.hasTypeSemanticCapability)(type, checker, capability)) {
1187
+ if ((0, import_internal3.hasTypeSemanticCapability)(type, checker, capability)) {
1204
1188
  return true;
1205
1189
  }
1206
1190
  if (capability === "string-like") {
1207
1191
  const itemType = getArrayElementType(type, checker);
1208
- return itemType !== null && (0, import_internal2.hasTypeSemanticCapability)(itemType, checker, capability);
1192
+ return itemType !== null && (0, import_internal3.hasTypeSemanticCapability)(itemType, checker, capability);
1209
1193
  }
1210
1194
  return false;
1211
1195
  }
@@ -1216,7 +1200,7 @@ function stripHintNullishUnion(type) {
1216
1200
  return type;
1217
1201
  }
1218
1202
  const nonNullish = type.types.filter(
1219
- (member) => (member.flags & (ts4.TypeFlags.Null | ts4.TypeFlags.Undefined)) === 0
1203
+ (member) => (member.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined)) === 0
1220
1204
  );
1221
1205
  if (nonNullish.length === 1 && nonNullish[0] !== void 0) {
1222
1206
  return nonNullish[0];
@@ -1232,10 +1216,10 @@ function isUserEmittableHintProperty(property, declaration) {
1232
1216
  }
1233
1217
  if ("name" in declaration && declaration.name !== void 0) {
1234
1218
  const name = declaration.name;
1235
- if (ts4.isComputedPropertyName(name) || ts4.isPrivateIdentifier(name)) {
1219
+ if (ts3.isComputedPropertyName(name) || ts3.isPrivateIdentifier(name)) {
1236
1220
  return false;
1237
1221
  }
1238
- if (!ts4.isIdentifier(name) && !ts4.isStringLiteral(name) && !ts4.isNumericLiteral(name)) {
1222
+ if (!ts3.isIdentifier(name) && !ts3.isStringLiteral(name) && !ts3.isNumericLiteral(name)) {
1239
1223
  return false;
1240
1224
  }
1241
1225
  }
@@ -1251,7 +1235,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
1251
1235
  if (isCallableType(stripped)) {
1252
1236
  return;
1253
1237
  }
1254
- if (!(0, import_internal2.hasTypeSemanticCapability)(stripped, checker, "object-like")) {
1238
+ if (!(0, import_internal3.hasTypeSemanticCapability)(stripped, checker, "object-like")) {
1255
1239
  return;
1256
1240
  }
1257
1241
  for (const property of stripped.getProperties()) {
@@ -1269,7 +1253,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
1269
1253
  continue;
1270
1254
  }
1271
1255
  const strippedPropertyType = stripHintNullishUnion(propertyType);
1272
- if (!isCallableType(strippedPropertyType) && (0, import_internal2.hasTypeSemanticCapability)(strippedPropertyType, checker, "object-like")) {
1256
+ if (!isCallableType(strippedPropertyType) && (0, import_internal3.hasTypeSemanticCapability)(strippedPropertyType, checker, "object-like")) {
1273
1257
  visit(strippedPropertyType, path3, depth + 1);
1274
1258
  }
1275
1259
  }
@@ -1278,7 +1262,7 @@ function collectObjectSubfieldCandidates(type, checker, capability) {
1278
1262
  return out;
1279
1263
  }
1280
1264
  function buildPathTargetHint(subjectType, checker, capability, tagName, argumentText) {
1281
- if (!(0, import_internal2.hasTypeSemanticCapability)(subjectType, checker, "object-like")) {
1265
+ if (!(0, import_internal3.hasTypeSemanticCapability)(subjectType, checker, "object-like")) {
1282
1266
  return null;
1283
1267
  }
1284
1268
  const candidates = collectObjectSubfieldCandidates(subjectType, checker, capability);
@@ -1380,7 +1364,7 @@ function hasBuiltinConstraintBroadening(tagName, options) {
1380
1364
  const broadenedTypeId = getBroadenedCustomTypeId(options?.fieldType);
1381
1365
  return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
1382
1366
  }
1383
- function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, provenance, supportingDeclarations, options) {
1367
+ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, rawText, provenance, supportingDeclarations, options) {
1384
1368
  if (!(0, import_internals3.isBuiltinConstraintName)(tagName)) {
1385
1369
  return [];
1386
1370
  }
@@ -1389,22 +1373,24 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1389
1373
  if (checker === void 0 || subjectType === void 0) {
1390
1374
  return [];
1391
1375
  }
1392
- const placement = (0, import_internal2.resolveDeclarationPlacement)(node);
1376
+ const placement = (0, import_internal3.resolveDeclarationPlacement)(node);
1393
1377
  if (placement === null) {
1394
1378
  return [];
1395
1379
  }
1396
- const definition = (0, import_internal2.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
1380
+ const definition = (0, import_internal3.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
1397
1381
  if (definition === null) {
1398
1382
  return [];
1399
1383
  }
1400
1384
  const nonNullPlacement = placement;
1401
- const log = (0, import_internal3.getBuildLogger)();
1402
- const broadeningLog = (0, import_internal3.getBroadeningLogger)();
1403
- const syntheticLog = (0, import_internal3.getSyntheticLogger)();
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)();
1404
1389
  const logsEnabled = log !== import_core.noopLogger || broadeningLog !== import_core.noopLogger;
1405
1390
  const syntheticTraceEnabled = syntheticLog !== import_core.noopLogger;
1406
- const logStart = logsEnabled ? (0, import_internal3.nowMicros)() : 0;
1407
- const subjectTypeKind = logsEnabled ? (0, import_internal3.describeTypeKind)(subjectType, checker) : "";
1391
+ const typedParserTraceEnabled = typedParserLog !== import_core.noopLogger;
1392
+ const logStart = logsEnabled ? (0, import_internal4.nowMicros)() : 0;
1393
+ const subjectTypeKind = logsEnabled ? (0, import_internal4.describeTypeKind)(subjectType, checker) : "";
1408
1394
  function emit(outcome, result2) {
1409
1395
  if (!logsEnabled) {
1410
1396
  return result2;
@@ -1415,11 +1401,11 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1415
1401
  placement: nonNullPlacement,
1416
1402
  subjectTypeKind,
1417
1403
  roleOutcome: outcome,
1418
- elapsedMicros: (0, import_internal3.elapsedMicros)(logStart)
1404
+ elapsedMicros: (0, import_internal4.elapsedMicros)(logStart)
1419
1405
  };
1420
- (0, import_internal3.logTagApplication)(log, entry);
1406
+ (0, import_internal4.logTagApplication)(log, entry);
1421
1407
  if (outcome === "bypass" || outcome === "D1" || outcome === "D2") {
1422
- (0, import_internal3.logTagApplication)(broadeningLog, entry);
1408
+ (0, import_internal4.logTagApplication)(broadeningLog, entry);
1423
1409
  }
1424
1410
  return result2;
1425
1411
  }
@@ -1454,7 +1440,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1454
1440
  )
1455
1441
  ]);
1456
1442
  }
1457
- const resolution = (0, import_internal2.resolvePathTargetType)(subjectType, checker, target.path.segments);
1443
+ const resolution = (0, import_internal3.resolvePathTargetType)(subjectType, checker, target.path.segments);
1458
1444
  if (resolution.kind === "missing-property") {
1459
1445
  return emit("B-reject", [
1460
1446
  makeDiagnostic(
@@ -1479,7 +1465,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1479
1465
  }
1480
1466
  const hasBroadening = (() => {
1481
1467
  if (target === null) {
1482
- 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")) {
1483
1469
  return true;
1484
1470
  }
1485
1471
  return hasBuiltinConstraintBroadening(tagName, options);
@@ -1510,16 +1496,41 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1510
1496
  ]);
1511
1497
  }
1512
1498
  }
1513
- const argumentExpression = renderSyntheticArgumentExpression(
1514
- definition.valueKind,
1515
- parsedTag?.argumentText ?? ""
1516
- );
1517
- if (definition.requiresArgument && argumentExpression === null) {
1518
- return emit("A-pass", []);
1519
- }
1520
1499
  if (hasBroadening) {
1521
1500
  return emit("bypass", []);
1522
1501
  }
1502
+ const effectiveArgumentText = (0, import_internal4.extractEffectiveArgumentText)(tagName, rawText, parsedTag);
1503
+ const typedParseResult = (0, import_internal4.parseTagArgument)(tagName, effectiveArgumentText, "build");
1504
+ if (!typedParseResult.ok) {
1505
+ if (typedParserTraceEnabled) {
1506
+ typedParserLog.trace("typed-parser C-reject", {
1507
+ consumer: "build",
1508
+ tag: tagName,
1509
+ placement: nonNullPlacement,
1510
+ subjectTypeKind: subjectTypeKind !== "" ? subjectTypeKind : "-",
1511
+ roleOutcome: "C-reject",
1512
+ diagnosticCode: typedParseResult.diagnostic.code
1513
+ });
1514
+ }
1515
+ const mappedCode = (0, import_internal4.mapTypedParserDiagnosticCode)(typedParseResult.diagnostic.code, tagName);
1516
+ return emit("C-reject", [
1517
+ makeDiagnostic(mappedCode, typedParseResult.diagnostic.message, provenance)
1518
+ ]);
1519
+ }
1520
+ if (typedParserTraceEnabled) {
1521
+ typedParserLog.trace("typed-parser C-pass", {
1522
+ consumer: "build",
1523
+ tag: tagName,
1524
+ placement: nonNullPlacement,
1525
+ subjectTypeKind: subjectTypeKind !== "" ? subjectTypeKind : "-",
1526
+ roleOutcome: "C-pass",
1527
+ valueKind: typedParseResult.value.kind
1528
+ });
1529
+ }
1530
+ const argumentExpression = renderSyntheticArgumentExpression(
1531
+ definition.valueKind,
1532
+ effectiveArgumentText
1533
+ );
1523
1534
  const subjectTypeText = checker.typeToString(subjectType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
1524
1535
  const hostType = options?.hostType ?? subjectType;
1525
1536
  const hostTypeText = checker.typeToString(hostType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
@@ -1532,7 +1543,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1532
1543
  subjectTypeText
1533
1544
  });
1534
1545
  }
1535
- const result = (0, import_internal2.checkSyntheticTagApplication)({
1546
+ const result = (0, import_internal3.checkSyntheticTagApplication)({
1536
1547
  tagName,
1537
1548
  placement,
1538
1549
  hostType: hostTypeText,
@@ -1558,13 +1569,13 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
1558
1569
  } : {}
1559
1570
  });
1560
1571
  if (result.diagnostics.length === 0) {
1561
- return emit("C-pass", []);
1572
+ return emit("D-pass", []);
1562
1573
  }
1563
1574
  const setupDiagnostic = result.diagnostics.find((diagnostic) => diagnostic.kind !== "typescript");
1564
1575
  if (setupDiagnostic !== void 0) {
1565
1576
  return emit("C-reject", [
1566
1577
  makeDiagnostic(
1567
- setupDiagnostic.kind === "unsupported-custom-type-override" ? "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" : "SYNTHETIC_SETUP_FAILURE",
1578
+ (0, import_internal4._mapSetupDiagnosticCode)(setupDiagnostic.kind),
1568
1579
  setupDiagnostic.message,
1569
1580
  provenance
1570
1581
  )
@@ -1583,10 +1594,10 @@ var parseResultCache = /* @__PURE__ */ new Map();
1583
1594
  function getExtensionTagNames(options) {
1584
1595
  return [
1585
1596
  ...options?.extensionRegistry?.extensions.flatMap(
1586
- (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName))
1597
+ (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal3.normalizeFormSpecTagName)(tag.tagName))
1587
1598
  ) ?? [],
1588
1599
  ...options?.extensionRegistry?.extensions.flatMap(
1589
- (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal2.normalizeFormSpecTagName)(slot.tagName))
1600
+ (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal3.normalizeFormSpecTagName)(slot.tagName))
1590
1601
  ) ?? []
1591
1602
  ].sort();
1592
1603
  }
@@ -1598,9 +1609,9 @@ function getExtensionRegistryCacheKey(registry) {
1598
1609
  (extension) => JSON.stringify({
1599
1610
  extensionId: extension.extensionId,
1600
1611
  typeNames: extension.types?.map((type) => type.typeName) ?? [],
1601
- constraintTags: extension.constraintTags?.map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName)) ?? [],
1612
+ constraintTags: extension.constraintTags?.map((tag) => (0, import_internal3.normalizeFormSpecTagName)(tag.tagName)) ?? [],
1602
1613
  metadataSlots: extension.metadataSlots?.map((slot) => ({
1603
- tagName: (0, import_internal2.normalizeFormSpecTagName)(slot.tagName),
1614
+ tagName: (0, import_internal3.normalizeFormSpecTagName)(slot.tagName),
1604
1615
  declarationKinds: [...slot.declarationKinds].sort(),
1605
1616
  allowBare: slot.allowBare !== false,
1606
1617
  qualifiers: (slot.qualifiers ?? []).map((qualifier) => ({
@@ -1632,6 +1643,16 @@ function parseTSDocTags(node, file = "", options) {
1632
1643
  if (cached !== void 0) {
1633
1644
  return cached;
1634
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
+ }
1635
1656
  const constraints = [];
1636
1657
  const annotations = [];
1637
1658
  const diagnostics = [];
@@ -1643,12 +1664,12 @@ function parseTSDocTags(node, file = "", options) {
1643
1664
  const sourceText = sourceFile.getFullText();
1644
1665
  const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
1645
1666
  const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
1646
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
1667
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
1647
1668
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
1648
1669
  const extensionTagNames = getExtensionTagNames(options);
1649
1670
  if (commentRanges) {
1650
1671
  for (const range of commentRanges) {
1651
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) {
1672
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) {
1652
1673
  continue;
1653
1674
  }
1654
1675
  const commentText = sourceText.substring(range.pos, range.end);
@@ -1656,7 +1677,7 @@ function parseTSDocTags(node, file = "", options) {
1656
1677
  continue;
1657
1678
  }
1658
1679
  const extensions = options?.extensionRegistry?.extensions;
1659
- const unified = (0, import_internal2.parseUnifiedComment)(commentText, {
1680
+ const unified = (0, import_internal3.parseUnifiedComment)(commentText, {
1660
1681
  offset: range.pos,
1661
1682
  extensionTagNames,
1662
1683
  ...extensions !== void 0 ? { extensions } : {}
@@ -1691,13 +1712,13 @@ function parseTSDocTags(node, file = "", options) {
1691
1712
  }
1692
1713
  continue;
1693
1714
  }
1694
- if (import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
1715
+ if (import_internal3.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
1695
1716
  const fallback = rawTextFallbacks.get(tagName)?.shift();
1696
- const text2 = (0, import_internal2.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
1717
+ const text2 = (0, import_internal3.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
1697
1718
  if (text2 === "") continue;
1698
1719
  const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
1699
1720
  if (tagName === "defaultValue") {
1700
- annotations.push((0, import_internal2.parseDefaultValueTagValue)(text2, provenance2));
1721
+ annotations.push((0, import_internal3.parseDefaultValueTagValue)(text2, provenance2));
1701
1722
  continue;
1702
1723
  }
1703
1724
  processConstraintTag(
@@ -1779,7 +1800,7 @@ function parseTSDocTags(node, file = "", options) {
1779
1800
  if (text === "") continue;
1780
1801
  const provenance = fallback.provenance;
1781
1802
  if (tagName === "defaultValue") {
1782
- annotations.push((0, import_internal2.parseDefaultValueTagValue)(text, provenance));
1803
+ annotations.push((0, import_internal3.parseDefaultValueTagValue)(text, provenance));
1783
1804
  continue;
1784
1805
  }
1785
1806
  processConstraintTag(
@@ -1805,13 +1826,13 @@ function extractDisplayNameMetadata(node) {
1805
1826
  const memberDisplayNames = /* @__PURE__ */ new Map();
1806
1827
  const sourceFile = node.getSourceFile();
1807
1828
  const sourceText = sourceFile.getFullText();
1808
- const commentRanges = ts4.getLeadingCommentRanges(sourceText, node.getFullStart());
1829
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
1809
1830
  if (commentRanges) {
1810
1831
  for (const range of commentRanges) {
1811
- if (range.kind !== ts4.SyntaxKind.MultiLineCommentTrivia) continue;
1832
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) continue;
1812
1833
  const commentText = sourceText.substring(range.pos, range.end);
1813
1834
  if (!commentText.startsWith("/**")) continue;
1814
- const unified = (0, import_internal2.parseUnifiedComment)(commentText);
1835
+ const unified = (0, import_internal3.parseUnifiedComment)(commentText);
1815
1836
  for (const tag of unified.tags) {
1816
1837
  if (tag.normalizedTagName !== "displayName") {
1817
1838
  continue;
@@ -1833,9 +1854,9 @@ function extractDisplayNameMetadata(node) {
1833
1854
  }
1834
1855
  function collectRawTextFallbacks(node, file) {
1835
1856
  const fallbacks = /* @__PURE__ */ new Map();
1836
- for (const tag of ts4.getJSDocTags(node)) {
1857
+ for (const tag of ts3.getJSDocTags(node)) {
1837
1858
  const tagName = (0, import_internals3.normalizeConstraintTagName)(tag.tagName.text);
1838
- if (!import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
1859
+ if (!import_internal3.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
1839
1860
  const commentText = getTagCommentText(tag)?.trim() ?? "";
1840
1861
  if (commentText === "") continue;
1841
1862
  const entries = fallbacks.get(tagName) ?? [];
@@ -1848,7 +1869,7 @@ function collectRawTextFallbacks(node, file) {
1848
1869
  return fallbacks;
1849
1870
  }
1850
1871
  function isMemberTargetDisplayName(text) {
1851
- return (0, import_internal2.parseTagSyntax)("displayName", text).target !== null;
1872
+ return (0, import_internal3.parseTagSyntax)("displayName", text).target !== null;
1852
1873
  }
1853
1874
  function provenanceForComment(range, sourceFile, file, tagName) {
1854
1875
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(range.pos);
@@ -1888,7 +1909,7 @@ function getTagCommentText(tag) {
1888
1909
  if (typeof tag.comment === "string") {
1889
1910
  return tag.comment;
1890
1911
  }
1891
- return ts4.getTextOfJSDocComment(tag.comment);
1912
+ return ts3.getTextOfJSDocComment(tag.comment);
1892
1913
  }
1893
1914
 
1894
1915
  // src/analyzer/jsdoc-constraints.ts
@@ -1906,18 +1927,18 @@ function extractJSDocAnnotationNodes(node, file = "", options) {
1906
1927
  function extractDefaultValueAnnotation(initializer, file = "") {
1907
1928
  if (!initializer) return null;
1908
1929
  let value;
1909
- if (ts5.isStringLiteral(initializer)) {
1930
+ if (ts4.isStringLiteral(initializer)) {
1910
1931
  value = initializer.text;
1911
- } else if (ts5.isNumericLiteral(initializer)) {
1932
+ } else if (ts4.isNumericLiteral(initializer)) {
1912
1933
  value = Number(initializer.text);
1913
- } else if (initializer.kind === ts5.SyntaxKind.TrueKeyword) {
1934
+ } else if (initializer.kind === ts4.SyntaxKind.TrueKeyword) {
1914
1935
  value = true;
1915
- } else if (initializer.kind === ts5.SyntaxKind.FalseKeyword) {
1936
+ } else if (initializer.kind === ts4.SyntaxKind.FalseKeyword) {
1916
1937
  value = false;
1917
- } else if (initializer.kind === ts5.SyntaxKind.NullKeyword) {
1938
+ } else if (initializer.kind === ts4.SyntaxKind.NullKeyword) {
1918
1939
  value = null;
1919
- } else if (ts5.isPrefixUnaryExpression(initializer)) {
1920
- 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)) {
1921
1942
  value = -Number(initializer.operand.text);
1922
1943
  }
1923
1944
  }
@@ -1939,28 +1960,28 @@ function extractDefaultValueAnnotation(initializer, file = "") {
1939
1960
 
1940
1961
  // src/analyzer/class-analyzer.ts
1941
1962
  function isObjectType(type) {
1942
- return !!(type.flags & ts6.TypeFlags.Object);
1963
+ return !!(type.flags & ts5.TypeFlags.Object);
1943
1964
  }
1944
1965
  function isIntersectionType(type) {
1945
- return !!(type.flags & ts6.TypeFlags.Intersection);
1966
+ return !!(type.flags & ts5.TypeFlags.Intersection);
1946
1967
  }
1947
1968
  function isResolvableObjectLikeAliasTypeNode(typeNode) {
1948
- if (ts6.isParenthesizedTypeNode(typeNode)) {
1969
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
1949
1970
  return isResolvableObjectLikeAliasTypeNode(typeNode.type);
1950
1971
  }
1951
- if (ts6.isTypeLiteralNode(typeNode) || ts6.isTypeReferenceNode(typeNode)) {
1972
+ if (ts5.isTypeLiteralNode(typeNode) || ts5.isTypeReferenceNode(typeNode)) {
1952
1973
  return true;
1953
1974
  }
1954
- 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));
1955
1976
  }
1956
1977
  function isSemanticallyPlainObjectLikeType(type, checker) {
1957
1978
  if (isIntersectionType(type)) {
1958
1979
  return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
1959
1980
  }
1960
- 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);
1961
1982
  }
1962
1983
  function isTypeReference(type) {
1963
- return !!(type.flags & ts6.TypeFlags.Object) && !!(type.objectFlags & ts6.ObjectFlags.Reference);
1984
+ return !!(type.flags & ts5.TypeFlags.Object) && !!(type.objectFlags & ts5.ObjectFlags.Reference);
1964
1985
  }
1965
1986
  var RESOLVING_TYPE_PLACEHOLDER = {
1966
1987
  kind: "object",
@@ -1986,8 +2007,23 @@ function createAnalyzerMetadataPolicy(input, discriminator) {
1986
2007
  discriminator
1987
2008
  };
1988
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
+ }
1989
2025
  function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node, checker, extensionRegistry, buildContext) {
1990
- const analysis = (0, import_internal4.analyzeMetadataForNodeWithChecker)({
2026
+ const analysis = (0, import_internal5.analyzeMetadataForNodeWithChecker)({
1991
2027
  checker,
1992
2028
  node,
1993
2029
  logicalName,
@@ -2022,10 +2058,121 @@ function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node,
2022
2058
  }
2023
2059
  return resolvedMetadata;
2024
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
+ }
2025
2172
  function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRegistry, metadataPolicy) {
2026
2173
  const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
2027
2174
  const declarationType = checker.getTypeAtLocation(declaration);
2028
- 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;
2029
2176
  const docResult = extractJSDocParseResult(
2030
2177
  declaration,
2031
2178
  file,
@@ -2067,13 +2214,19 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2067
2214
  file,
2068
2215
  makeParseOptions(extensionRegistry, void 0, checker, classType, classType)
2069
2216
  );
2070
- const annotations = [...classDoc.annotations];
2217
+ const inheritedClassAnnotations = collectInheritedTypeAnnotations(
2218
+ classDecl,
2219
+ classDoc.annotations,
2220
+ checker,
2221
+ extensionRegistry
2222
+ );
2223
+ const annotations = [...classDoc.annotations, ...inheritedClassAnnotations];
2071
2224
  diagnostics.push(...classDoc.diagnostics);
2072
2225
  const visiting = /* @__PURE__ */ new Set();
2073
2226
  const instanceMethods = [];
2074
2227
  const staticMethods = [];
2075
2228
  for (const member of classDecl.members) {
2076
- if (ts6.isPropertyDeclaration(member)) {
2229
+ if (ts5.isPropertyDeclaration(member)) {
2077
2230
  const fieldNode = analyzeFieldToIR(
2078
2231
  member,
2079
2232
  checker,
@@ -2089,10 +2242,10 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2089
2242
  fields.push(fieldNode);
2090
2243
  fieldLayouts.push({});
2091
2244
  }
2092
- } else if (ts6.isMethodDeclaration(member)) {
2245
+ } else if (ts5.isMethodDeclaration(member)) {
2093
2246
  const methodInfo = analyzeMethod(member, checker);
2094
2247
  if (methodInfo) {
2095
- const isStatic = member.modifiers?.some((m) => m.kind === ts6.SyntaxKind.StaticKeyword);
2248
+ const isStatic = member.modifiers?.some((m) => m.kind === ts5.SyntaxKind.StaticKeyword);
2096
2249
  if (isStatic) {
2097
2250
  staticMethods.push(methodInfo);
2098
2251
  } else {
@@ -2124,6 +2277,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2124
2277
  hostType: classType
2125
2278
  }
2126
2279
  );
2280
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
2127
2281
  return {
2128
2282
  name,
2129
2283
  ...metadata !== void 0 && { metadata },
@@ -2131,7 +2285,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2131
2285
  fieldLayouts,
2132
2286
  typeRegistry,
2133
2287
  ...annotations.length > 0 && { annotations },
2134
- ...diagnostics.length > 0 && { diagnostics },
2288
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
2135
2289
  instanceMethods,
2136
2290
  staticMethods
2137
2291
  };
@@ -2151,11 +2305,20 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
2151
2305
  file,
2152
2306
  makeParseOptions(extensionRegistry, void 0, checker, interfaceType, interfaceType)
2153
2307
  );
2154
- 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
+ ];
2155
2318
  diagnostics.push(...interfaceDoc.diagnostics);
2156
2319
  const visiting = /* @__PURE__ */ new Set();
2157
2320
  for (const member of interfaceDecl.members) {
2158
- if (ts6.isPropertySignature(member)) {
2321
+ if (ts5.isPropertySignature(member)) {
2159
2322
  const fieldNode = analyzeInterfacePropertyToIR(
2160
2323
  member,
2161
2324
  checker,
@@ -2196,6 +2359,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
2196
2359
  hostType: interfaceType
2197
2360
  }
2198
2361
  );
2362
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
2199
2363
  return {
2200
2364
  name,
2201
2365
  ...metadata !== void 0 && { metadata },
@@ -2203,7 +2367,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
2203
2367
  fieldLayouts,
2204
2368
  typeRegistry,
2205
2369
  ...annotations.length > 0 && { annotations },
2206
- ...diagnostics.length > 0 && { diagnostics },
2370
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
2207
2371
  instanceMethods: [],
2208
2372
  staticMethods: []
2209
2373
  };
@@ -2213,7 +2377,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
2213
2377
  if (members === null) {
2214
2378
  const sourceFile = typeAlias.getSourceFile();
2215
2379
  const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
2216
- const kindDesc = ts6.SyntaxKind[typeAlias.type.kind] ?? "unknown";
2380
+ const kindDesc = ts5.SyntaxKind[typeAlias.type.kind] ?? "unknown";
2217
2381
  return {
2218
2382
  ok: false,
2219
2383
  kind: "not-object-like",
@@ -2248,7 +2412,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
2248
2412
  diagnostics.push(...typeAliasDoc.diagnostics);
2249
2413
  const visiting = /* @__PURE__ */ new Set();
2250
2414
  for (const member of members) {
2251
- if (ts6.isPropertySignature(member)) {
2415
+ if (ts5.isPropertySignature(member)) {
2252
2416
  const fieldNode = analyzeInterfacePropertyToIR(
2253
2417
  member,
2254
2418
  checker,
@@ -2288,6 +2452,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
2288
2452
  hostType: aliasType
2289
2453
  }
2290
2454
  );
2455
+ const deduplicatedDiagnostics = deduplicateDiagnostics(diagnostics);
2291
2456
  return {
2292
2457
  ok: true,
2293
2458
  analysis: {
@@ -2297,7 +2462,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
2297
2462
  fieldLayouts: specializedFields.map(() => ({})),
2298
2463
  typeRegistry,
2299
2464
  ...annotations.length > 0 && { annotations },
2300
- ...diagnostics.length > 0 && { diagnostics },
2465
+ ...deduplicatedDiagnostics.length > 0 && { diagnostics: deduplicatedDiagnostics },
2301
2466
  instanceMethods: [],
2302
2467
  staticMethods: []
2303
2468
  }
@@ -2315,20 +2480,20 @@ function makeAnalysisDiagnostic(code, message, primaryLocation, relatedLocations
2315
2480
  function getLeadingParsedTags(node) {
2316
2481
  const sourceFile = node.getSourceFile();
2317
2482
  const sourceText = sourceFile.getFullText();
2318
- const commentRanges = ts6.getLeadingCommentRanges(sourceText, node.getFullStart());
2483
+ const commentRanges = ts5.getLeadingCommentRanges(sourceText, node.getFullStart());
2319
2484
  if (commentRanges === void 0) {
2320
2485
  return [];
2321
2486
  }
2322
2487
  const parsedTags = [];
2323
2488
  for (const range of commentRanges) {
2324
- if (range.kind !== ts6.SyntaxKind.MultiLineCommentTrivia) {
2489
+ if (range.kind !== ts5.SyntaxKind.MultiLineCommentTrivia) {
2325
2490
  continue;
2326
2491
  }
2327
2492
  const commentText = sourceText.slice(range.pos, range.end);
2328
2493
  if (!commentText.startsWith("/**")) {
2329
2494
  continue;
2330
2495
  }
2331
- parsedTags.push(...(0, import_internal4.parseCommentBlock)(commentText, { offset: range.pos }).tags);
2496
+ parsedTags.push(...(0, import_internal5.parseCommentBlock)(commentText, { offset: range.pos }).tags);
2332
2497
  }
2333
2498
  return parsedTags;
2334
2499
  }
@@ -2339,19 +2504,19 @@ function resolveDiscriminatorProperty(node, checker, fieldName) {
2339
2504
  return null;
2340
2505
  }
2341
2506
  const declaration = propertySymbol.valueDeclaration ?? propertySymbol.declarations?.find(
2342
- (candidate) => ts6.isPropertyDeclaration(candidate) || ts6.isPropertySignature(candidate)
2507
+ (candidate) => ts5.isPropertyDeclaration(candidate) || ts5.isPropertySignature(candidate)
2343
2508
  ) ?? propertySymbol.declarations?.[0];
2344
2509
  return {
2345
2510
  declaration,
2346
2511
  type: checker.getTypeOfSymbolAtLocation(propertySymbol, declaration ?? node),
2347
- 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
2348
2513
  };
2349
2514
  }
2350
2515
  function isLocalTypeParameterName(node, typeParameterName) {
2351
2516
  return node.typeParameters?.some((typeParameter) => typeParameter.name.text === typeParameterName) ?? false;
2352
2517
  }
2353
2518
  function isNullishSemanticType(type) {
2354
- 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)) {
2355
2520
  return true;
2356
2521
  }
2357
2522
  return type.isUnion() && type.types.some((member) => isNullishSemanticType(member));
@@ -2361,7 +2526,7 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
2361
2526
  return false;
2362
2527
  }
2363
2528
  seen.add(type);
2364
- if (type.flags & ts6.TypeFlags.StringLike) {
2529
+ if (type.flags & ts5.TypeFlags.StringLike) {
2365
2530
  return true;
2366
2531
  }
2367
2532
  if (type.isUnion()) {
@@ -2374,13 +2539,13 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
2374
2539
  return false;
2375
2540
  }
2376
2541
  function getObjectLikeTypeAliasMembers(typeNode) {
2377
- if (ts6.isParenthesizedTypeNode(typeNode)) {
2542
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
2378
2543
  return getObjectLikeTypeAliasMembers(typeNode.type);
2379
2544
  }
2380
- if (ts6.isTypeLiteralNode(typeNode)) {
2545
+ if (ts5.isTypeLiteralNode(typeNode)) {
2381
2546
  return [...typeNode.members];
2382
2547
  }
2383
- if (ts6.isIntersectionTypeNode(typeNode)) {
2548
+ if (ts5.isIntersectionTypeNode(typeNode)) {
2384
2549
  const members = [];
2385
2550
  for (const intersectionMember of typeNode.types) {
2386
2551
  const resolvedMembers = getObjectLikeTypeAliasMembers(intersectionMember);
@@ -2543,7 +2708,7 @@ function resolveLiteralDiscriminatorPropertyValue(boundType, propertyName, check
2543
2708
  }
2544
2709
  if (propertyType.isUnion()) {
2545
2710
  const nonNullMembers = propertyType.types.filter(
2546
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
2711
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
2547
2712
  );
2548
2713
  if (nonNullMembers.length > 0 && nonNullMembers.every((member) => member.isStringLiteral())) {
2549
2714
  diagnostics.push(
@@ -2592,13 +2757,13 @@ function resolveNamedDiscriminatorDeclaration(type, checker, seen = /* @__PURE__
2592
2757
  seen.add(type);
2593
2758
  const symbol = type.aliasSymbol ?? type.getSymbol();
2594
2759
  if (symbol !== void 0) {
2595
- 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;
2596
2761
  const targetSymbol = aliased ?? symbol;
2597
2762
  const declaration = targetSymbol.declarations?.find(
2598
- (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)
2599
2764
  );
2600
2765
  if (declaration !== void 0) {
2601
- 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) {
2602
2767
  return resolveNamedDiscriminatorDeclaration(
2603
2768
  checker.getTypeFromTypeNode(declaration.type),
2604
2769
  checker,
@@ -2626,7 +2791,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
2626
2791
  }
2627
2792
  if (boundType.isUnion()) {
2628
2793
  const nonNullMembers = boundType.types.filter(
2629
- (member) => !(member.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
2794
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
2630
2795
  );
2631
2796
  if (nonNullMembers.every((member) => member.isStringLiteral())) {
2632
2797
  diagnostics.push(
@@ -2671,7 +2836,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
2671
2836
  return null;
2672
2837
  }
2673
2838
  function getDeclarationName(node) {
2674
- 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)) {
2675
2840
  return node.name?.text ?? "anonymous";
2676
2841
  }
2677
2842
  return "anonymous";
@@ -2726,11 +2891,11 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
2726
2891
  if (sourceTypeNode === void 0) {
2727
2892
  return [];
2728
2893
  }
2729
- const unwrapParentheses = (typeNode) => ts6.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
2894
+ const unwrapParentheses = (typeNode) => ts5.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
2730
2895
  const directTypeNode = unwrapParentheses(sourceTypeNode);
2731
- const referenceTypeNode = ts6.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
2896
+ const referenceTypeNode = ts5.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
2732
2897
  const resolvedTypeNode = resolveAliasedTypeNode(directTypeNode, checker);
2733
- return ts6.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
2898
+ return ts5.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
2734
2899
  })();
2735
2900
  if (referenceTypeNode?.typeArguments === void 0) {
2736
2901
  return [];
@@ -2738,7 +2903,7 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
2738
2903
  return referenceTypeNode.typeArguments.map((argumentNode) => {
2739
2904
  const argumentType = checker.getTypeFromTypeNode(argumentNode);
2740
2905
  const baseSymbol = argumentType.aliasSymbol ?? argumentType.getSymbol();
2741
- 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;
2742
2907
  const argumentDecl = argumentSymbol?.declarations?.[0];
2743
2908
  if (argumentDecl !== void 0 && argumentDecl.getSourceFile().fileName !== file) {
2744
2909
  const argumentName = argumentSymbol?.getName() ?? baseSymbol?.getName();
@@ -2801,7 +2966,7 @@ function applyDiscriminatorToObjectProperties(properties, node, subjectType, che
2801
2966
  );
2802
2967
  }
2803
2968
  function analyzeFieldToIR(prop, checker, file, typeRegistry, visiting, diagnostics, hostType, metadataPolicy, extensionRegistry) {
2804
- if (!ts6.isIdentifier(prop.name)) {
2969
+ if (!ts5.isIdentifier(prop.name)) {
2805
2970
  return null;
2806
2971
  }
2807
2972
  const name = prop.name.text;
@@ -2928,7 +3093,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
2928
3093
  const seen = /* @__PURE__ */ new Set();
2929
3094
  const duplicates = /* @__PURE__ */ new Set();
2930
3095
  for (const member of members) {
2931
- if (!ts6.isPropertySignature(member)) {
3096
+ if (!ts5.isPropertySignature(member)) {
2932
3097
  continue;
2933
3098
  }
2934
3099
  const name = getAnalyzableObjectLikePropertyName(member.name);
@@ -2944,7 +3109,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
2944
3109
  return [...duplicates].sort();
2945
3110
  }
2946
3111
  function getAnalyzableObjectLikePropertyName(name) {
2947
- if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
3112
+ if (ts5.isIdentifier(name) || ts5.isStringLiteral(name) || ts5.isNumericLiteral(name)) {
2948
3113
  return name.text;
2949
3114
  }
2950
3115
  return null;
@@ -3039,28 +3204,28 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
3039
3204
  if (primitiveAlias) {
3040
3205
  return primitiveAlias;
3041
3206
  }
3042
- if (isIntegerBrandedType(type)) {
3207
+ if ((0, import_internal2._isIntegerBrandedType)(type)) {
3043
3208
  return { kind: "primitive", primitiveKind: "integer" };
3044
3209
  }
3045
- if (type.flags & ts6.TypeFlags.String) {
3210
+ if (type.flags & ts5.TypeFlags.String) {
3046
3211
  return { kind: "primitive", primitiveKind: "string" };
3047
3212
  }
3048
- if (type.flags & ts6.TypeFlags.Number) {
3213
+ if (type.flags & ts5.TypeFlags.Number) {
3049
3214
  return { kind: "primitive", primitiveKind: "number" };
3050
3215
  }
3051
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
3216
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
3052
3217
  return { kind: "primitive", primitiveKind: "bigint" };
3053
3218
  }
3054
- if (type.flags & ts6.TypeFlags.Boolean) {
3219
+ if (type.flags & ts5.TypeFlags.Boolean) {
3055
3220
  return { kind: "primitive", primitiveKind: "boolean" };
3056
3221
  }
3057
- if (type.flags & ts6.TypeFlags.Null) {
3222
+ if (type.flags & ts5.TypeFlags.Null) {
3058
3223
  return { kind: "primitive", primitiveKind: "null" };
3059
3224
  }
3060
- if (type.flags & ts6.TypeFlags.Undefined) {
3225
+ if (type.flags & ts5.TypeFlags.Undefined) {
3061
3226
  return { kind: "primitive", primitiveKind: "null" };
3062
3227
  }
3063
- if (type.flags & ts6.TypeFlags.Void) {
3228
+ if (type.flags & ts5.TypeFlags.Void) {
3064
3229
  return { kind: "primitive", primitiveKind: "null" };
3065
3230
  }
3066
3231
  if (type.isStringLiteral()) {
@@ -3147,10 +3312,10 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
3147
3312
  return { kind: "primitive", primitiveKind: "string" };
3148
3313
  }
3149
3314
  function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3150
- 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)) {
3151
3316
  return null;
3152
3317
  }
3153
- const aliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
3318
+ const aliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
3154
3319
  if (!aliasDecl) {
3155
3320
  return null;
3156
3321
  }
@@ -3161,11 +3326,18 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
3161
3326
  ...extractJSDocConstraintNodes(aliasDecl, file, makeParseOptions(extensionRegistry)),
3162
3327
  ...extractTypeAliasConstraintNodes(aliasDecl.type, checker, file, extensionRegistry)
3163
3328
  ];
3164
- const annotations = extractJSDocAnnotationNodes(
3329
+ const localAnnotations = extractJSDocAnnotationNodes(
3165
3330
  aliasDecl,
3166
3331
  file,
3167
3332
  makeParseOptions(extensionRegistry)
3168
3333
  );
3334
+ const inheritedAnnotations = collectInheritedTypeAnnotations(
3335
+ aliasDecl,
3336
+ localAnnotations,
3337
+ checker,
3338
+ extensionRegistry
3339
+ );
3340
+ const annotations = [...localAnnotations, ...inheritedAnnotations];
3169
3341
  const metadata = resolveNodeMetadata(
3170
3342
  metadataPolicy,
3171
3343
  "type",
@@ -3200,8 +3372,8 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
3200
3372
  return { kind: "reference", name: aliasName, typeArguments: [] };
3201
3373
  }
3202
3374
  function getReferencedTypeAliasDeclaration(sourceNode, checker) {
3203
- const typeNode = sourceNode && (ts6.isPropertyDeclaration(sourceNode) || ts6.isPropertySignature(sourceNode) || ts6.isParameter(sourceNode)) ? sourceNode.type : void 0;
3204
- 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)) {
3205
3377
  return void 0;
3206
3378
  }
3207
3379
  return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -3222,7 +3394,7 @@ function resolveNamedTypeWithSourceRecovery(type, sourceNode, checker) {
3222
3394
  return { typeName: refAliasDecl.name.text, namedDecl: refAliasDecl };
3223
3395
  }
3224
3396
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
3225
- if (!ts6.isTypeReferenceNode(typeNode)) {
3397
+ if (!ts5.isTypeReferenceNode(typeNode)) {
3226
3398
  return false;
3227
3399
  }
3228
3400
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -3230,10 +3402,10 @@ function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
3230
3402
  return false;
3231
3403
  }
3232
3404
  const resolved = checker.getTypeFromTypeNode(aliasDecl.type);
3233
- 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));
3234
3406
  }
3235
3407
  function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics, visitedAliases = /* @__PURE__ */ new Set()) {
3236
- const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts6.isTypeAliasDeclaration);
3408
+ const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration);
3237
3409
  if (nestedAliasDecl !== void 0 && !visitedAliases.has(nestedAliasDecl)) {
3238
3410
  visitedAliases.add(nestedAliasDecl);
3239
3411
  return resolveAliasedPrimitiveTarget(
@@ -3248,22 +3420,22 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
3248
3420
  visitedAliases
3249
3421
  );
3250
3422
  }
3251
- if (isIntegerBrandedType(type)) {
3423
+ if ((0, import_internal2._isIntegerBrandedType)(type)) {
3252
3424
  return { kind: "primitive", primitiveKind: "integer" };
3253
3425
  }
3254
- if (type.flags & ts6.TypeFlags.String) {
3426
+ if (type.flags & ts5.TypeFlags.String) {
3255
3427
  return { kind: "primitive", primitiveKind: "string" };
3256
3428
  }
3257
- if (type.flags & ts6.TypeFlags.Number) {
3429
+ if (type.flags & ts5.TypeFlags.Number) {
3258
3430
  return { kind: "primitive", primitiveKind: "number" };
3259
3431
  }
3260
- if (type.flags & (ts6.TypeFlags.BigInt | ts6.TypeFlags.BigIntLiteral)) {
3432
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
3261
3433
  return { kind: "primitive", primitiveKind: "bigint" };
3262
3434
  }
3263
- if (type.flags & ts6.TypeFlags.Boolean) {
3435
+ if (type.flags & ts5.TypeFlags.Boolean) {
3264
3436
  return { kind: "primitive", primitiveKind: "boolean" };
3265
3437
  }
3266
- if (type.flags & ts6.TypeFlags.Null) {
3438
+ if (type.flags & ts5.TypeFlags.Null) {
3267
3439
  return { kind: "primitive", primitiveKind: "null" };
3268
3440
  }
3269
3441
  return resolveTypeNode(
@@ -3283,7 +3455,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
3283
3455
  let typeName = null;
3284
3456
  let namedDecl;
3285
3457
  if (recovered !== null) {
3286
- const recoveredAliasDecl = ts6.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
3458
+ const recoveredAliasDecl = ts5.isTypeAliasDeclaration(recovered.namedDecl) ? recovered.namedDecl : void 0;
3287
3459
  if (recoveredAliasDecl !== void 0) {
3288
3460
  const aliasUnderlyingType = checker.getTypeFromTypeNode(recoveredAliasDecl.type);
3289
3461
  const isNonGeneric = recoveredAliasDecl.typeParameters === void 0 || recoveredAliasDecl.typeParameters.length === 0;
@@ -3305,13 +3477,13 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
3305
3477
  (memberTypeNode) => !isNullishTypeNode(resolveAliasedTypeNode(memberTypeNode, checker))
3306
3478
  );
3307
3479
  const nonNullTypes = allTypes.filter(
3308
- (memberType) => !(memberType.flags & (ts6.TypeFlags.Null | ts6.TypeFlags.Undefined))
3480
+ (memberType) => !(memberType.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
3309
3481
  );
3310
3482
  const nonNullMembers = nonNullTypes.map((memberType, index) => ({
3311
3483
  memberType,
3312
3484
  sourceNode: nonNullSourceNodes.length === nonNullTypes.length ? nonNullSourceNodes[index] : void 0
3313
3485
  }));
3314
- const hasNull = allTypes.some((t) => t.flags & ts6.TypeFlags.Null);
3486
+ const hasNull = allTypes.some((t) => t.flags & ts5.TypeFlags.Null);
3315
3487
  const memberDisplayNames = /* @__PURE__ */ new Map();
3316
3488
  if (namedDecl) {
3317
3489
  for (const [value, label] of extractDisplayNameMetadata(namedDecl).memberDisplayNames) {
@@ -3331,7 +3503,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
3331
3503
  if (existing !== void 0 && existing.type !== RESOLVING_TYPE_PLACEHOLDER) {
3332
3504
  return { kind: "reference", name: typeName, typeArguments: [] };
3333
3505
  }
3334
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
3506
+ const annotations = namedDecl ? extractNamedTypeAnnotations(namedDecl, checker, file, extensionRegistry) : void 0;
3335
3507
  const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
3336
3508
  metadataPolicy,
3337
3509
  "type",
@@ -3358,7 +3530,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
3358
3530
  const displayName = memberDisplayNames.get(String(value));
3359
3531
  return displayName !== void 0 ? { value, displayName } : { value };
3360
3532
  });
3361
- 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);
3362
3534
  if (isBooleanUnion2) {
3363
3535
  const boolNode = { kind: "primitive", primitiveKind: "boolean" };
3364
3536
  const result = hasNull ? {
@@ -3450,7 +3622,7 @@ function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metad
3450
3622
  if (type.getProperties().length > 0) {
3451
3623
  return null;
3452
3624
  }
3453
- const indexInfo = checker.getIndexInfoOfType(type, ts6.IndexKind.String);
3625
+ const indexInfo = checker.getIndexInfoOfType(type, ts5.IndexKind.String);
3454
3626
  if (!indexInfo) {
3455
3627
  return null;
3456
3628
  }
@@ -3498,20 +3670,53 @@ function shouldEmitResolvedObjectProperty(property, declaration) {
3498
3670
  }
3499
3671
  if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
3500
3672
  const name = declaration.name;
3501
- if (ts6.isComputedPropertyName(name) || ts6.isPrivateIdentifier(name)) {
3673
+ if (ts5.isComputedPropertyName(name) || ts5.isPrivateIdentifier(name)) {
3502
3674
  return false;
3503
3675
  }
3504
- if (!ts6.isIdentifier(name) && !ts6.isStringLiteral(name) && !ts6.isNumericLiteral(name)) {
3676
+ if (!ts5.isIdentifier(name) && !ts5.isStringLiteral(name) && !ts5.isNumericLiteral(name)) {
3505
3677
  return false;
3506
3678
  }
3507
3679
  }
3508
3680
  return true;
3509
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
+ }
3510
3707
  function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3511
3708
  const collectedDiagnostics = diagnostics ?? [];
3512
3709
  const typeName = getNamedTypeName(type);
3513
3710
  const namedTypeName = typeName ?? void 0;
3514
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;
3515
3720
  const referenceTypeArguments = extractReferenceTypeArguments(
3516
3721
  type,
3517
3722
  checker,
@@ -3523,13 +3728,13 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3523
3728
  extensionRegistry,
3524
3729
  collectedDiagnostics
3525
3730
  );
3526
- const instantiatedTypeName = namedTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
3527
- namedTypeName,
3731
+ const instantiatedTypeName = effectiveTypeName !== void 0 && referenceTypeArguments.length > 0 ? buildInstantiatedReferenceName(
3732
+ effectiveTypeName,
3528
3733
  referenceTypeArguments.map((argument) => argument.tsType),
3529
3734
  checker
3530
3735
  ) : void 0;
3531
- const registryTypeName = instantiatedTypeName ?? namedTypeName;
3532
- 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);
3533
3738
  const clearNamedTypeRegistration = () => {
3534
3739
  if (registryTypeName === void 0 || !shouldRegisterNamedType) {
3535
3740
  return;
@@ -3550,7 +3755,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3550
3755
  typeRegistry[registryTypeName] = {
3551
3756
  name: registryTypeName,
3552
3757
  type: RESOLVING_TYPE_PLACEHOLDER,
3553
- provenance: provenanceForDeclaration(namedDecl, file)
3758
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
3554
3759
  };
3555
3760
  }
3556
3761
  visiting.add(type);
@@ -3582,17 +3787,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3582
3787
  clearNamedTypeRegistration();
3583
3788
  return recordNode;
3584
3789
  }
3585
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
3586
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
3790
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
3791
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
3587
3792
  metadataPolicy,
3588
3793
  "type",
3589
3794
  registryTypeName,
3590
- namedDecl,
3795
+ effectiveNamedDecl,
3591
3796
  checker,
3592
3797
  extensionRegistry,
3593
3798
  {
3594
3799
  checker,
3595
- declaration: namedDecl,
3800
+ declaration: effectiveNamedDecl,
3596
3801
  subjectType: type
3597
3802
  }
3598
3803
  ) : void 0;
@@ -3601,7 +3806,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3601
3806
  ...metadata !== void 0 && { metadata },
3602
3807
  type: recordNode,
3603
3808
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
3604
- provenance: provenanceForDeclaration(namedDecl, file)
3809
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
3605
3810
  };
3606
3811
  return {
3607
3812
  kind: "reference",
@@ -3627,7 +3832,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3627
3832
  if (!declaration) continue;
3628
3833
  if (!shouldEmitResolvedObjectProperty(prop, declaration)) continue;
3629
3834
  const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);
3630
- const optional = !!(prop.flags & ts6.SymbolFlags.Optional);
3835
+ const optional = !!(prop.flags & ts5.SymbolFlags.Optional);
3631
3836
  const propTypeNode = resolveTypeNode(
3632
3837
  propType,
3633
3838
  checker,
@@ -3640,7 +3845,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3640
3845
  collectedDiagnostics
3641
3846
  );
3642
3847
  const fieldNodeInfo = fieldInfoMap?.get(prop.name);
3643
- const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts6.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
3848
+ const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts5.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
3644
3849
  declaration,
3645
3850
  checker,
3646
3851
  file,
@@ -3650,7 +3855,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3650
3855
  type,
3651
3856
  metadataPolicy,
3652
3857
  extensionRegistry
3653
- ) : ts6.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
3858
+ ) : ts5.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
3654
3859
  declaration,
3655
3860
  checker,
3656
3861
  file,
@@ -3678,9 +3883,9 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3678
3883
  visiting.delete(type);
3679
3884
  const objectNode = {
3680
3885
  kind: "object",
3681
- 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(
3682
3887
  properties,
3683
- namedDecl,
3888
+ effectiveNamedDecl,
3684
3889
  type,
3685
3890
  checker,
3686
3891
  file,
@@ -3690,17 +3895,17 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3690
3895
  additionalProperties: true
3691
3896
  };
3692
3897
  if (registryTypeName !== void 0 && shouldRegisterNamedType) {
3693
- const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
3694
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
3898
+ const annotations = effectiveNamedDecl ? extractNamedTypeAnnotations(effectiveNamedDecl, checker, file, extensionRegistry) : void 0;
3899
+ const metadata = effectiveNamedDecl !== void 0 ? resolveNodeMetadata(
3695
3900
  metadataPolicy,
3696
3901
  "type",
3697
3902
  registryTypeName,
3698
- namedDecl,
3903
+ effectiveNamedDecl,
3699
3904
  checker,
3700
3905
  extensionRegistry,
3701
3906
  {
3702
3907
  checker,
3703
- declaration: namedDecl,
3908
+ declaration: effectiveNamedDecl,
3704
3909
  subjectType: type
3705
3910
  }
3706
3911
  ) : void 0;
@@ -3709,7 +3914,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
3709
3914
  ...metadata !== void 0 && { metadata },
3710
3915
  type: objectNode,
3711
3916
  ...annotations !== void 0 && annotations.length > 0 && { annotations },
3712
- provenance: provenanceForDeclaration(namedDecl, file)
3917
+ provenance: provenanceForDeclaration(effectiveNamedDecl, file)
3713
3918
  };
3714
3919
  return {
3715
3920
  kind: "reference",
@@ -3726,12 +3931,12 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
3726
3931
  for (const symbol of symbols) {
3727
3932
  const declarations = symbol.declarations;
3728
3933
  if (!declarations) continue;
3729
- const classDecl = declarations.find(ts6.isClassDeclaration);
3934
+ const classDecl = declarations.find(ts5.isClassDeclaration);
3730
3935
  if (classDecl) {
3731
3936
  const map = /* @__PURE__ */ new Map();
3732
3937
  const hostType = checker.getTypeAtLocation(classDecl);
3733
3938
  for (const member of classDecl.members) {
3734
- if (ts6.isPropertyDeclaration(member) && ts6.isIdentifier(member.name)) {
3939
+ if (ts5.isPropertyDeclaration(member) && ts5.isIdentifier(member.name)) {
3735
3940
  const fieldNode = analyzeFieldToIR(
3736
3941
  member,
3737
3942
  checker,
@@ -3755,7 +3960,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
3755
3960
  }
3756
3961
  return map;
3757
3962
  }
3758
- const interfaceDecl = declarations.find(ts6.isInterfaceDeclaration);
3963
+ const interfaceDecl = declarations.find(ts5.isInterfaceDeclaration);
3759
3964
  if (interfaceDecl) {
3760
3965
  return buildFieldNodeInfoMap(
3761
3966
  interfaceDecl.members,
@@ -3769,7 +3974,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
3769
3974
  extensionRegistry
3770
3975
  );
3771
3976
  }
3772
- const typeAliasDecl = declarations.find(ts6.isTypeAliasDeclaration);
3977
+ const typeAliasDecl = declarations.find(ts5.isTypeAliasDeclaration);
3773
3978
  const typeAliasMembers = typeAliasDecl === void 0 ? null : getObjectLikeTypeAliasMembers(typeAliasDecl.type);
3774
3979
  if (typeAliasDecl && typeAliasMembers !== null) {
3775
3980
  return buildFieldNodeInfoMap(
@@ -3793,10 +3998,10 @@ function extractArrayElementTypeNode(sourceNode, checker) {
3793
3998
  return void 0;
3794
3999
  }
3795
4000
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
3796
- if (ts6.isArrayTypeNode(resolvedTypeNode)) {
4001
+ if (ts5.isArrayTypeNode(resolvedTypeNode)) {
3797
4002
  return resolvedTypeNode.elementType;
3798
4003
  }
3799
- 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]) {
3800
4005
  return resolvedTypeNode.typeArguments[0];
3801
4006
  }
3802
4007
  return void 0;
@@ -3807,13 +4012,13 @@ function extractUnionMemberTypeNodes(sourceNode, checker) {
3807
4012
  return [];
3808
4013
  }
3809
4014
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
3810
- return ts6.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
4015
+ return ts5.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
3811
4016
  }
3812
4017
  function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new Set()) {
3813
- if (ts6.isParenthesizedTypeNode(typeNode)) {
4018
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3814
4019
  return resolveAliasedTypeNode(typeNode.type, checker, visited);
3815
4020
  }
3816
- if (!ts6.isTypeReferenceNode(typeNode) || !ts6.isIdentifier(typeNode.typeName)) {
4021
+ if (!ts5.isTypeReferenceNode(typeNode) || !ts5.isIdentifier(typeNode.typeName)) {
3817
4022
  return typeNode;
3818
4023
  }
3819
4024
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -3824,15 +4029,15 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
3824
4029
  return resolveAliasedTypeNode(aliasDecl.type, checker, visited);
3825
4030
  }
3826
4031
  function isNullishTypeNode(typeNode) {
3827
- if (typeNode.kind === ts6.SyntaxKind.NullKeyword || typeNode.kind === ts6.SyntaxKind.UndefinedKeyword) {
4032
+ if (typeNode.kind === ts5.SyntaxKind.NullKeyword || typeNode.kind === ts5.SyntaxKind.UndefinedKeyword) {
3828
4033
  return true;
3829
4034
  }
3830
- 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);
3831
4036
  }
3832
4037
  function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, metadataPolicy, hostType, diagnostics, extensionRegistry) {
3833
4038
  const map = /* @__PURE__ */ new Map();
3834
4039
  for (const member of members) {
3835
- if (ts6.isPropertySignature(member)) {
4040
+ if (ts5.isPropertySignature(member)) {
3836
4041
  const fieldNode = analyzeInterfacePropertyToIR(
3837
4042
  member,
3838
4043
  checker,
@@ -3858,7 +4063,7 @@ function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, m
3858
4063
  }
3859
4064
  var MAX_ALIAS_CHAIN_DEPTH = 8;
3860
4065
  function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegistry, depth = 0) {
3861
- if (!ts6.isTypeReferenceNode(typeNode)) return [];
4066
+ if (!ts5.isTypeReferenceNode(typeNode)) return [];
3862
4067
  if (depth >= MAX_ALIAS_CHAIN_DEPTH) {
3863
4068
  const aliasName = typeNode.typeName.getText();
3864
4069
  throw new Error(
@@ -3867,7 +4072,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
3867
4072
  }
3868
4073
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
3869
4074
  if (!aliasDecl) return [];
3870
- if (ts6.isTypeLiteralNode(aliasDecl.type)) return [];
4075
+ if (ts5.isTypeLiteralNode(aliasDecl.type)) return [];
3871
4076
  const aliasFieldType = resolveTypeNode(
3872
4077
  checker.getTypeAtLocation(aliasDecl.type),
3873
4078
  checker,
@@ -3911,14 +4116,14 @@ function getNamedTypeName(type) {
3911
4116
  const symbol = type.getSymbol();
3912
4117
  if (symbol?.declarations) {
3913
4118
  const decl = symbol.declarations[0];
3914
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
3915
- 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;
3916
4121
  if (name) return name;
3917
4122
  }
3918
4123
  }
3919
4124
  const aliasSymbol = type.aliasSymbol;
3920
4125
  if (aliasSymbol?.declarations) {
3921
- const aliasDecl = aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
4126
+ const aliasDecl = aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
3922
4127
  if (aliasDecl) {
3923
4128
  return aliasDecl.name.text;
3924
4129
  }
@@ -3929,24 +4134,24 @@ function getNamedTypeDeclaration(type) {
3929
4134
  const symbol = type.getSymbol();
3930
4135
  if (symbol?.declarations) {
3931
4136
  const decl = symbol.declarations[0];
3932
- if (decl && (ts6.isClassDeclaration(decl) || ts6.isInterfaceDeclaration(decl) || ts6.isTypeAliasDeclaration(decl))) {
4137
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
3933
4138
  return decl;
3934
4139
  }
3935
4140
  }
3936
4141
  const aliasSymbol = type.aliasSymbol;
3937
4142
  if (aliasSymbol?.declarations) {
3938
- return aliasSymbol.declarations.find(ts6.isTypeAliasDeclaration);
4143
+ return aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
3939
4144
  }
3940
4145
  return void 0;
3941
4146
  }
3942
4147
  function analyzeMethod(method, checker) {
3943
- if (!ts6.isIdentifier(method.name)) {
4148
+ if (!ts5.isIdentifier(method.name)) {
3944
4149
  return null;
3945
4150
  }
3946
4151
  const name = method.name.text;
3947
4152
  const parameters = [];
3948
4153
  for (const param of method.parameters) {
3949
- if (ts6.isIdentifier(param.name)) {
4154
+ if (ts5.isIdentifier(param.name)) {
3950
4155
  const paramInfo = analyzeParameter(param, checker);
3951
4156
  parameters.push(paramInfo);
3952
4157
  }
@@ -3957,7 +4162,7 @@ function analyzeMethod(method, checker) {
3957
4162
  return { name, parameters, returnTypeNode, returnType };
3958
4163
  }
3959
4164
  function analyzeParameter(param, checker) {
3960
- const name = ts6.isIdentifier(param.name) ? param.name.text : "param";
4165
+ const name = ts5.isIdentifier(param.name) ? param.name.text : "param";
3961
4166
  const typeNode = param.type;
3962
4167
  const type = checker.getTypeAtLocation(param);
3963
4168
  const formSpecExportName = detectFormSpecReference(typeNode);
@@ -3966,15 +4171,15 @@ function analyzeParameter(param, checker) {
3966
4171
  }
3967
4172
  function detectFormSpecReference(typeNode) {
3968
4173
  if (!typeNode) return null;
3969
- if (!ts6.isTypeReferenceNode(typeNode)) return null;
3970
- 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;
3971
4176
  if (typeName !== "InferSchema" && typeName !== "InferFormSchema") return null;
3972
4177
  const typeArg = typeNode.typeArguments?.[0];
3973
- if (!typeArg || !ts6.isTypeQueryNode(typeArg)) return null;
3974
- if (ts6.isIdentifier(typeArg.exprName)) {
4178
+ if (!typeArg || !ts5.isTypeQueryNode(typeArg)) return null;
4179
+ if (ts5.isIdentifier(typeArg.exprName)) {
3975
4180
  return typeArg.exprName.text;
3976
4181
  }
3977
- if (ts6.isQualifiedName(typeArg.exprName)) {
4182
+ if (ts5.isQualifiedName(typeArg.exprName)) {
3978
4183
  return typeArg.exprName.right.text;
3979
4184
  }
3980
4185
  return null;
@@ -3996,23 +4201,23 @@ function createProgramContextFromProgram(program, filePath) {
3996
4201
  function createProgramContext(filePath, additionalFiles) {
3997
4202
  const absolutePath = path.resolve(filePath);
3998
4203
  const fileDir = path.dirname(absolutePath);
3999
- 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");
4000
4205
  let compilerOptions;
4001
4206
  let fileNames;
4002
4207
  if (configPath) {
4003
- const configFile = ts7.readConfigFile(configPath, ts7.sys.readFile.bind(ts7.sys));
4208
+ const configFile = ts6.readConfigFile(configPath, ts6.sys.readFile.bind(ts6.sys));
4004
4209
  if (configFile.error) {
4005
4210
  throw new Error(
4006
- `Error reading tsconfig.json: ${ts7.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
4211
+ `Error reading tsconfig.json: ${ts6.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
4007
4212
  );
4008
4213
  }
4009
- const parsed = ts7.parseJsonConfigFileContent(
4214
+ const parsed = ts6.parseJsonConfigFileContent(
4010
4215
  configFile.config,
4011
- ts7.sys,
4216
+ ts6.sys,
4012
4217
  path.dirname(configPath)
4013
4218
  );
4014
4219
  if (parsed.errors.length > 0) {
4015
- 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");
4016
4221
  throw new Error(`Error parsing tsconfig.json: ${errorMessages}`);
4017
4222
  }
4018
4223
  compilerOptions = parsed.options;
@@ -4020,9 +4225,9 @@ function createProgramContext(filePath, additionalFiles) {
4020
4225
  fileNames = [.../* @__PURE__ */ new Set([...parsed.fileNames, absolutePath, ...normalizedAdditional])];
4021
4226
  } else {
4022
4227
  compilerOptions = {
4023
- target: ts7.ScriptTarget.ES2022,
4024
- module: ts7.ModuleKind.NodeNext,
4025
- moduleResolution: ts7.ModuleResolutionKind.NodeNext,
4228
+ target: ts6.ScriptTarget.ES2022,
4229
+ module: ts6.ModuleKind.NodeNext,
4230
+ moduleResolution: ts6.ModuleResolutionKind.NodeNext,
4026
4231
  strict: true,
4027
4232
  skipLibCheck: true,
4028
4233
  declaration: true
@@ -4030,7 +4235,7 @@ function createProgramContext(filePath, additionalFiles) {
4030
4235
  const normalizedAdditional = (additionalFiles ?? []).map((f) => path.resolve(f));
4031
4236
  fileNames = [.../* @__PURE__ */ new Set([absolutePath, ...normalizedAdditional])];
4032
4237
  }
4033
- const program = ts7.createProgram(fileNames, compilerOptions);
4238
+ const program = ts6.createProgram(fileNames, compilerOptions);
4034
4239
  const sourceFile = program.getSourceFile(absolutePath);
4035
4240
  if (!sourceFile) {
4036
4241
  throw new Error(`Could not find source file: ${absolutePath}`);
@@ -4049,19 +4254,19 @@ function findNodeByName(sourceFile, name, predicate, getName) {
4049
4254
  result = node;
4050
4255
  return;
4051
4256
  }
4052
- ts7.forEachChild(node, visit);
4257
+ ts6.forEachChild(node, visit);
4053
4258
  }
4054
4259
  visit(sourceFile);
4055
4260
  return result;
4056
4261
  }
4057
4262
  function findClassByName(sourceFile, className) {
4058
- return findNodeByName(sourceFile, className, ts7.isClassDeclaration, (n) => n.name?.text);
4263
+ return findNodeByName(sourceFile, className, ts6.isClassDeclaration, (n) => n.name?.text);
4059
4264
  }
4060
4265
  function findInterfaceByName(sourceFile, interfaceName) {
4061
- return findNodeByName(sourceFile, interfaceName, ts7.isInterfaceDeclaration, (n) => n.name.text);
4266
+ return findNodeByName(sourceFile, interfaceName, ts6.isInterfaceDeclaration, (n) => n.name.text);
4062
4267
  }
4063
4268
  function findTypeAliasByName(sourceFile, aliasName) {
4064
- return findNodeByName(sourceFile, aliasName, ts7.isTypeAliasDeclaration, (n) => n.name.text);
4269
+ return findNodeByName(sourceFile, aliasName, ts6.isTypeAliasDeclaration, (n) => n.name.text);
4065
4270
  }
4066
4271
  function getResolvedObjectRootType(rootType, typeRegistry) {
4067
4272
  if (rootType.kind === "object") {
@@ -4101,22 +4306,22 @@ function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInf
4101
4306
  };
4102
4307
  }
4103
4308
  function containsTypeReferenceInObjectLikeAlias(typeNode) {
4104
- if (ts7.isParenthesizedTypeNode(typeNode)) {
4309
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
4105
4310
  return containsTypeReferenceInObjectLikeAlias(typeNode.type);
4106
4311
  }
4107
- if (ts7.isTypeReferenceNode(typeNode)) {
4312
+ if (ts6.isTypeReferenceNode(typeNode)) {
4108
4313
  return true;
4109
4314
  }
4110
- return ts7.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
4315
+ return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
4111
4316
  }
4112
4317
  function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
4113
- if (ts7.isParenthesizedTypeNode(typeNode)) {
4318
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
4114
4319
  return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
4115
4320
  }
4116
- if (ts7.isTypeLiteralNode(typeNode)) {
4321
+ if (ts6.isTypeLiteralNode(typeNode)) {
4117
4322
  const propertyNames = [];
4118
4323
  for (const member of typeNode.members) {
4119
- if (!ts7.isPropertySignature(member)) {
4324
+ if (!ts6.isPropertySignature(member)) {
4120
4325
  continue;
4121
4326
  }
4122
4327
  const propertyName = getAnalyzableObjectLikePropertyName(member.name);
@@ -4126,13 +4331,13 @@ function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
4126
4331
  }
4127
4332
  return propertyNames;
4128
4333
  }
4129
- if (ts7.isTypeReferenceNode(typeNode)) {
4334
+ if (ts6.isTypeReferenceNode(typeNode)) {
4130
4335
  return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
4131
4336
  }
4132
4337
  return null;
4133
4338
  }
4134
4339
  function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
4135
- if (!ts7.isIntersectionTypeNode(typeNode)) {
4340
+ if (!ts6.isIntersectionTypeNode(typeNode)) {
4136
4341
  return [];
4137
4342
  }
4138
4343
  const seen = /* @__PURE__ */ new Set();
@@ -4322,7 +4527,7 @@ function makeFileProvenance(filePath) {
4322
4527
  }
4323
4528
 
4324
4529
  // src/generators/class-schema.ts
4325
- var ts9 = __toESM(require("typescript"), 1);
4530
+ var ts8 = __toESM(require("typescript"), 1);
4326
4531
 
4327
4532
  // src/metadata/collision-guards.ts
4328
4533
  function assertUniqueSerializedNames(entries, scope) {
@@ -4491,7 +4696,7 @@ function generateJsonSchemaFromIR(ir, options) {
4491
4696
  applyConstraints(ctx.defs[schemaName], typeDef.constraints, ctx);
4492
4697
  }
4493
4698
  if (typeDef.annotations && typeDef.annotations.length > 0) {
4494
- applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx);
4699
+ applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx, typeDef.type);
4495
4700
  }
4496
4701
  }
4497
4702
  const properties = {};
@@ -4564,7 +4769,7 @@ function generateFieldSchema(field, ctx) {
4564
4769
  }
4565
4770
  }
4566
4771
  applyResolvedMetadata(schema, field.metadata);
4567
- applyAnnotations(schema, rootAnnotations, ctx);
4772
+ applyAnnotations(schema, rootAnnotations, ctx, field.type);
4568
4773
  if (itemStringSchema !== void 0) {
4569
4774
  applyAnnotations(itemStringSchema, itemAnnotations, ctx);
4570
4775
  }
@@ -4607,32 +4812,36 @@ function applyPathTargetedConstraints(schema, pathConstraints, ctx, typeNode) {
4607
4812
  return schema;
4608
4813
  }
4609
4814
  if (schema.$ref) {
4610
- const { $ref, ...rest } = schema;
4611
- const refPart = { $ref };
4612
- const overridePart = {
4613
- properties: propertyOverrides,
4614
- ...rest
4815
+ return {
4816
+ ...schema,
4817
+ properties: propertyOverrides
4615
4818
  };
4616
- return { allOf: [refPart, overridePart] };
4617
4819
  }
4618
4820
  if (schema.type === "object" && schema.properties) {
4619
- const missingOverrides = {};
4620
4821
  for (const [target, overrideSchema] of Object.entries(propertyOverrides)) {
4621
- if (schema.properties[target]) {
4622
- mergeSchemaOverride(schema.properties[target], overrideSchema);
4623
- } else {
4624
- 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
+ }
4625
4828
  }
4829
+ Object.defineProperty(schema.properties, target, {
4830
+ value: overrideSchema,
4831
+ writable: true,
4832
+ enumerable: true,
4833
+ configurable: true
4834
+ });
4626
4835
  }
4627
- if (Object.keys(missingOverrides).length === 0) {
4628
- return schema;
4629
- }
4630
- return {
4631
- allOf: [schema, { properties: missingOverrides }]
4632
- };
4836
+ return schema;
4633
4837
  }
4634
4838
  if (schema.allOf) {
4635
- 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];
4636
4845
  return schema;
4637
4846
  }
4638
4847
  return schema;
@@ -4745,7 +4954,7 @@ function generatePropertySchema(prop, ctx) {
4745
4954
  const schema = generateTypeNode(prop.type, ctx);
4746
4955
  applyConstraints(schema, prop.constraints, ctx);
4747
4956
  applyResolvedMetadata(schema, prop.metadata);
4748
- applyAnnotations(schema, prop.annotations, ctx);
4957
+ applyAnnotations(schema, prop.annotations, ctx, prop.type);
4749
4958
  return schema;
4750
4959
  }
4751
4960
  function generateUnionType(type, ctx) {
@@ -4848,13 +5057,20 @@ function buildPropertyOverrides(pathConstraints, typeNode, ctx) {
4848
5057
  grouped.push(constraint);
4849
5058
  byTarget.set(target, grouped);
4850
5059
  }
4851
- const overrides = {};
5060
+ const overrides = /* @__PURE__ */ Object.create(null);
4852
5061
  for (const [target, constraints] of byTarget) {
4853
- overrides[resolveSerializedPropertyName(target, typeNode, ctx)] = buildPathOverrideSchema(
5062
+ const resolvedName = resolveSerializedPropertyName(target, typeNode, ctx);
5063
+ const schema = buildPathOverrideSchema(
4854
5064
  constraints.map(stripLeadingPathSegment),
4855
5065
  resolveTargetTypeNode(target, typeNode, ctx),
4856
5066
  ctx
4857
5067
  );
5068
+ Object.defineProperty(overrides, resolvedName, {
5069
+ value: schema,
5070
+ writable: true,
5071
+ enumerable: true,
5072
+ configurable: true
5073
+ });
4858
5074
  }
4859
5075
  return overrides;
4860
5076
  }
@@ -4881,6 +5097,34 @@ function buildPathOverrideSchema(constraints, typeNode, ctx) {
4881
5097
  schema.properties = buildPropertyOverrides(nestedConstraints, effectiveType, ctx);
4882
5098
  return schema;
4883
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
+ }
4884
5128
  function mergeSchemaOverride(target, override) {
4885
5129
  const nullableValueBranch = getNullableUnionValueSchema(target);
4886
5130
  if (nullableValueBranch !== void 0) {
@@ -4888,11 +5132,16 @@ function mergeSchemaOverride(target, override) {
4888
5132
  return;
4889
5133
  }
4890
5134
  if (override.properties !== void 0) {
4891
- const mergedProperties = target.properties ?? {};
5135
+ const mergedProperties = target.properties ?? /* @__PURE__ */ Object.create(null);
4892
5136
  for (const [name, propertyOverride] of Object.entries(override.properties)) {
4893
- const existing = mergedProperties[name];
5137
+ const existing = Object.hasOwn(mergedProperties, name) ? mergedProperties[name] : void 0;
4894
5138
  if (existing === void 0) {
4895
- mergedProperties[name] = propertyOverride;
5139
+ Object.defineProperty(mergedProperties, name, {
5140
+ value: propertyOverride,
5141
+ writable: true,
5142
+ enumerable: true,
5143
+ configurable: true
5144
+ });
4896
5145
  } else {
4897
5146
  mergeSchemaOverride(existing, propertyOverride);
4898
5147
  }
@@ -4910,7 +5159,12 @@ function mergeSchemaOverride(target, override) {
4910
5159
  if (key === "properties" || key === "items") {
4911
5160
  continue;
4912
5161
  }
4913
- target[key] = value;
5162
+ Object.defineProperty(target, key, {
5163
+ value,
5164
+ writable: true,
5165
+ enumerable: true,
5166
+ configurable: true
5167
+ });
4914
5168
  }
4915
5169
  }
4916
5170
  function stripLeadingPathSegment(constraint) {
@@ -5010,7 +5264,7 @@ function applyConstraints(schema, constraints, ctx) {
5010
5264
  }
5011
5265
  }
5012
5266
  }
5013
- function applyAnnotations(schema, annotations, ctx) {
5267
+ function applyAnnotations(schema, annotations, ctx, typeNode) {
5014
5268
  for (const annotation of annotations) {
5015
5269
  switch (annotation.annotationKind) {
5016
5270
  case "displayName":
@@ -5023,7 +5277,7 @@ function applyAnnotations(schema, annotations, ctx) {
5023
5277
  schema[`${ctx.vendorPrefix}-remarks`] = annotation.value;
5024
5278
  break;
5025
5279
  case "defaultValue":
5026
- schema.default = annotation.value;
5280
+ schema.default = coerceDefaultValue(annotation.value, typeNode, schema, ctx);
5027
5281
  break;
5028
5282
  case "format":
5029
5283
  schema.format = annotation.value;
@@ -5048,6 +5302,34 @@ function applyAnnotations(schema, annotations, ctx) {
5048
5302
  }
5049
5303
  }
5050
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
+ }
5051
5333
  function generateCustomType(type, ctx) {
5052
5334
  const registration = ctx.extensionRegistry?.findType(type.typeId);
5053
5335
  if (registration === void 0) {
@@ -5174,25 +5456,41 @@ function assignVendorPrefixedExtensionKeywords(schema, extensionSchema, vendorPr
5174
5456
 
5175
5457
  // src/extensions/registry.ts
5176
5458
  var import_internals5 = require("@formspec/core/internals");
5177
- var import_internal5 = require("@formspec/analysis/internal");
5459
+ var import_internal6 = require("@formspec/analysis/internal");
5178
5460
  var BUILTIN_METADATA_TAGS = /* @__PURE__ */ new Set(["apiName", "displayName"]);
5179
5461
  function buildConstraintTagSources(extensions) {
5180
5462
  return extensions.map((extension) => ({
5181
5463
  extensionId: extension.extensionId,
5182
5464
  ...extension.constraintTags !== void 0 ? {
5183
5465
  constraintTags: extension.constraintTags.map((tag) => ({
5184
- 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]
5185
5477
  }))
5186
5478
  } : {}
5187
5479
  }));
5188
5480
  }
5189
5481
  function createExtensionRegistry(extensions) {
5190
- const registryLog = (0, import_internal5.getSyntheticLogger)();
5482
+ const registryLog = (0, import_internal6.getSyntheticLogger)();
5191
5483
  registryLog.debug("createExtensionRegistry: constructing", {
5192
5484
  extensionCount: extensions.length,
5193
5485
  extensionIds: extensions.map((e) => e.extensionId)
5194
5486
  });
5195
- 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;
5196
5494
  let symbolMap = /* @__PURE__ */ new Map();
5197
5495
  const typeMap = /* @__PURE__ */ new Map();
5198
5496
  const typeNameMap = /* @__PURE__ */ new Map();
@@ -5259,7 +5557,7 @@ function createExtensionRegistry(extensions) {
5259
5557
  }
5260
5558
  if (ext.constraintTags !== void 0) {
5261
5559
  for (const tag of ext.constraintTags) {
5262
- const canonicalTagName = (0, import_internal5.normalizeFormSpecTagName)(tag.tagName);
5560
+ const canonicalTagName = (0, import_internal6.normalizeFormSpecTagName)(tag.tagName);
5263
5561
  if (constraintTagMap.has(canonicalTagName)) {
5264
5562
  throw new Error(`Duplicate custom constraint tag: "@${canonicalTagName}"`);
5265
5563
  }
@@ -5284,7 +5582,7 @@ function createExtensionRegistry(extensions) {
5284
5582
  throw new Error(`Duplicate metadata slot ID: "${slot.slotId}"`);
5285
5583
  }
5286
5584
  metadataSlotMap.set(slot.slotId, true);
5287
- const canonicalTagName = (0, import_internal5.normalizeFormSpecTagName)(slot.tagName);
5585
+ const canonicalTagName = (0, import_internal6.normalizeFormSpecTagName)(slot.tagName);
5288
5586
  if (slot.allowBare === false && (slot.qualifiers?.length ?? 0) === 0) {
5289
5587
  throw new Error(
5290
5588
  `Metadata tag "@${canonicalTagName}" must allow bare usage or declare at least one qualifier.`
@@ -5311,7 +5609,7 @@ function createExtensionRegistry(extensions) {
5311
5609
  `Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${(0, import_internals5.normalizeConstraintTagName)(canonicalTagName)}".`
5312
5610
  );
5313
5611
  }
5314
- const existingTag = (0, import_internal5.getTagDefinition)(canonicalTagName, reservedTagSources);
5612
+ const existingTag = (0, import_internal6.getTagDefinition)(canonicalTagName, reservedTagSources);
5315
5613
  if (existingTag !== null) {
5316
5614
  throw BUILTIN_METADATA_TAGS.has(existingTag.canonicalName) ? new Error(
5317
5615
  `Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
@@ -5329,10 +5627,12 @@ function createExtensionRegistry(extensions) {
5329
5627
  constraintTagCount: constraintTagMap.size,
5330
5628
  broadeningCount: builtinBroadeningMap.size,
5331
5629
  annotationCount: annotationMap.size,
5332
- metadataSlotCount: metadataSlotMap.size
5630
+ metadataSlotCount: metadataSlotMap.size,
5631
+ setupDiagnosticCount: setupDiagnostics.length
5333
5632
  });
5334
5633
  return {
5335
5634
  extensions,
5635
+ setupDiagnostics,
5336
5636
  findType: (typeId) => typeMap.get(typeId),
5337
5637
  findTypeByName: (typeName) => typeNameMap.get(typeName),
5338
5638
  findTypeByBrand: (brand) => brandMap.get(brand),
@@ -5341,14 +5641,14 @@ function createExtensionRegistry(extensions) {
5341
5641
  symbolMap = map;
5342
5642
  },
5343
5643
  findConstraint: (constraintId) => constraintMap.get(constraintId),
5344
- findConstraintTag: (tagName) => constraintTagMap.get((0, import_internal5.normalizeFormSpecTagName)(tagName)),
5644
+ findConstraintTag: (tagName) => constraintTagMap.get((0, import_internal6.normalizeFormSpecTagName)(tagName)),
5345
5645
  findBuiltinConstraintBroadening: (typeId, tagName) => builtinBroadeningMap.get(`${typeId}:${tagName}`),
5346
5646
  findAnnotation: (annotationId) => annotationMap.get(annotationId)
5347
5647
  };
5348
5648
  }
5349
5649
 
5350
5650
  // src/extensions/symbol-registry.ts
5351
- var ts8 = __toESM(require("typescript"), 1);
5651
+ var ts7 = __toESM(require("typescript"), 1);
5352
5652
  var path2 = __toESM(require("path"), 1);
5353
5653
 
5354
5654
  // src/ui-schema/schema.ts
@@ -5609,9 +5909,9 @@ function collectFieldNameMap(elements) {
5609
5909
  }
5610
5910
 
5611
5911
  // src/validate/constraint-validator.ts
5612
- var import_internal6 = require("@formspec/analysis/internal");
5912
+ var import_internal7 = require("@formspec/analysis/internal");
5613
5913
  function validateFieldNode(ctx, field) {
5614
- const analysis = (0, import_internal6.analyzeConstraintTargets)(
5914
+ const analysis = (0, import_internal7.analyzeConstraintTargets)(
5615
5915
  field.name,
5616
5916
  field.type,
5617
5917
  field.constraints,
@@ -5629,7 +5929,7 @@ function validateFieldNode(ctx, field) {
5629
5929
  }
5630
5930
  function validateObjectProperty(ctx, parentName, property) {
5631
5931
  const qualifiedName = `${parentName}.${property.name}`;
5632
- const analysis = (0, import_internal6.analyzeConstraintTargets)(
5932
+ const analysis = (0, import_internal7.analyzeConstraintTargets)(
5633
5933
  qualifiedName,
5634
5934
  property.type,
5635
5935
  property.constraints,
@@ -5741,7 +6041,7 @@ function formatLocation(location) {
5741
6041
  }
5742
6042
  function resolveStaticOptions(options) {
5743
6043
  const legacyRegistry = options.extensionRegistry;
5744
- 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;
5745
6045
  return {
5746
6046
  extensionRegistry: legacyRegistry ?? configRegistry,
5747
6047
  // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields