@formspec/build 0.1.0-alpha.49 → 0.1.0-alpha.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -2275,8 +2275,134 @@ var init_schema2 = __esm({
2275
2275
  }
2276
2276
  });
2277
2277
 
2278
- // src/analyzer/tsdoc-parser.ts
2278
+ // src/extensions/ts-type-utils.ts
2279
2279
  import * as ts from "typescript";
2280
+ function collectBrandIdentifiers(type) {
2281
+ if (!type.isIntersection()) {
2282
+ return [];
2283
+ }
2284
+ const brands = [];
2285
+ for (const prop of type.getProperties()) {
2286
+ const decl = prop.valueDeclaration ?? prop.declarations?.[0];
2287
+ if (decl === void 0) continue;
2288
+ if (!ts.isPropertySignature(decl) && !ts.isPropertyDeclaration(decl)) continue;
2289
+ if (!ts.isComputedPropertyName(decl.name)) continue;
2290
+ if (!ts.isIdentifier(decl.name.expression)) continue;
2291
+ brands.push(decl.name.expression.text);
2292
+ }
2293
+ return brands;
2294
+ }
2295
+ function resolveCanonicalSymbol(type, checker) {
2296
+ const raw = type.aliasSymbol ?? type.getSymbol();
2297
+ if (raw === void 0) return void 0;
2298
+ return raw.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(raw) : raw;
2299
+ }
2300
+ function extractTypeNodeFromSource(sourceNode) {
2301
+ if (ts.isPropertyDeclaration(sourceNode) || ts.isPropertySignature(sourceNode) || ts.isParameter(sourceNode) || ts.isTypeAliasDeclaration(sourceNode)) {
2302
+ return sourceNode.type;
2303
+ }
2304
+ if (ts.isTypeNode(sourceNode)) {
2305
+ return sourceNode;
2306
+ }
2307
+ return void 0;
2308
+ }
2309
+ function resolveAliasedSymbol(symbol, checker) {
2310
+ if (symbol === void 0) return void 0;
2311
+ return symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
2312
+ }
2313
+ function getTypeAliasDeclarationFromTypeReference(typeNode, checker) {
2314
+ const symbol = checker.getSymbolAtLocation(typeNode.typeName);
2315
+ return resolveAliasedSymbol(symbol, checker)?.declarations?.find(ts.isTypeAliasDeclaration);
2316
+ }
2317
+ var init_ts_type_utils = __esm({
2318
+ "src/extensions/ts-type-utils.ts"() {
2319
+ "use strict";
2320
+ }
2321
+ });
2322
+
2323
+ // src/extensions/resolve-custom-type.ts
2324
+ import * as ts2 from "typescript";
2325
+ import { stripNullishUnion } from "@formspec/analysis/internal";
2326
+ function getTypeNodeRegistrationName(typeNode) {
2327
+ if (ts2.isTypeReferenceNode(typeNode)) {
2328
+ return ts2.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : typeNode.typeName.right.text;
2329
+ }
2330
+ if (ts2.isParenthesizedTypeNode(typeNode)) {
2331
+ return getTypeNodeRegistrationName(typeNode.type);
2332
+ }
2333
+ if (typeNode.kind === ts2.SyntaxKind.BigIntKeyword || typeNode.kind === ts2.SyntaxKind.StringKeyword || typeNode.kind === ts2.SyntaxKind.NumberKeyword || typeNode.kind === ts2.SyntaxKind.BooleanKeyword) {
2334
+ return typeNode.getText();
2335
+ }
2336
+ return null;
2337
+ }
2338
+ function resolveByNameFromTypeNode(typeNode, registry, checker) {
2339
+ if (ts2.isParenthesizedTypeNode(typeNode)) {
2340
+ return resolveByNameFromTypeNode(typeNode.type, registry, checker);
2341
+ }
2342
+ const typeName = getTypeNodeRegistrationName(typeNode);
2343
+ if (typeName !== null) {
2344
+ const byName = registry.findTypeByName(typeName);
2345
+ if (byName !== void 0) {
2346
+ return byName;
2347
+ }
2348
+ }
2349
+ if (ts2.isTypeReferenceNode(typeNode) && ts2.isIdentifier(typeNode.typeName)) {
2350
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
2351
+ if (aliasDecl !== void 0) {
2352
+ return resolveByNameFromTypeNode(aliasDecl.type, registry, checker);
2353
+ }
2354
+ }
2355
+ return null;
2356
+ }
2357
+ function resolveCustomTypeFromTsType(type, checker, registry, sourceNode) {
2358
+ if (registry === void 0) {
2359
+ return null;
2360
+ }
2361
+ const stripped = stripNullishUnion(type);
2362
+ if (sourceNode !== void 0) {
2363
+ const typeNode = extractTypeNodeFromSource(sourceNode);
2364
+ if (typeNode !== void 0) {
2365
+ const byName = resolveByNameFromTypeNode(typeNode, registry, checker);
2366
+ if (byName !== null) {
2367
+ return byName;
2368
+ }
2369
+ }
2370
+ } else {
2371
+ const typeName = (stripped.aliasSymbol ?? stripped.getSymbol())?.getName();
2372
+ if (typeName !== void 0) {
2373
+ const byName = registry.findTypeByName(typeName);
2374
+ if (byName !== void 0) {
2375
+ return byName;
2376
+ }
2377
+ }
2378
+ }
2379
+ const canonical = resolveCanonicalSymbol(stripped, checker);
2380
+ if (canonical !== void 0) {
2381
+ const bySymbol = registry.findTypeBySymbol(canonical);
2382
+ if (bySymbol !== void 0) {
2383
+ return bySymbol;
2384
+ }
2385
+ }
2386
+ for (const brand of collectBrandIdentifiers(stripped)) {
2387
+ const byBrand = registry.findTypeByBrand(brand);
2388
+ if (byBrand !== void 0) {
2389
+ return byBrand;
2390
+ }
2391
+ }
2392
+ return null;
2393
+ }
2394
+ function customTypeIdFromLookup(result) {
2395
+ return `${result.extensionId}/${result.registration.typeName}`;
2396
+ }
2397
+ var init_resolve_custom_type = __esm({
2398
+ "src/extensions/resolve-custom-type.ts"() {
2399
+ "use strict";
2400
+ init_ts_type_utils();
2401
+ }
2402
+ });
2403
+
2404
+ // src/analyzer/tsdoc-parser.ts
2405
+ import * as ts3 from "typescript";
2280
2406
  import {
2281
2407
  checkSyntheticTagApplication,
2282
2408
  choosePreferredPayloadText,
@@ -2317,23 +2443,23 @@ function getExtensionTypeNames(registry) {
2317
2443
  function collectImportedNames(sourceFile) {
2318
2444
  const importedNames = /* @__PURE__ */ new Set();
2319
2445
  for (const statement of sourceFile.statements) {
2320
- if (ts.isImportDeclaration(statement) && statement.importClause !== void 0) {
2446
+ if (ts3.isImportDeclaration(statement) && statement.importClause !== void 0) {
2321
2447
  const clause = statement.importClause;
2322
2448
  if (clause.name !== void 0) {
2323
2449
  importedNames.add(clause.name.text);
2324
2450
  }
2325
2451
  if (clause.namedBindings !== void 0) {
2326
- if (ts.isNamedImports(clause.namedBindings)) {
2452
+ if (ts3.isNamedImports(clause.namedBindings)) {
2327
2453
  for (const specifier of clause.namedBindings.elements) {
2328
2454
  importedNames.add(specifier.name.text);
2329
2455
  }
2330
- } else if (ts.isNamespaceImport(clause.namedBindings)) {
2456
+ } else if (ts3.isNamespaceImport(clause.namedBindings)) {
2331
2457
  importedNames.add(clause.namedBindings.name.text);
2332
2458
  }
2333
2459
  }
2334
2460
  continue;
2335
2461
  }
2336
- if (ts.isImportEqualsDeclaration(statement)) {
2462
+ if (ts3.isImportEqualsDeclaration(statement)) {
2337
2463
  importedNames.add(statement.name.text);
2338
2464
  }
2339
2465
  }
@@ -2341,13 +2467,13 @@ function collectImportedNames(sourceFile) {
2341
2467
  }
2342
2468
  function isNonReferenceIdentifier(node) {
2343
2469
  const parent = node.parent;
2344
- if ((ts.isBindingElement(parent) || ts.isClassDeclaration(parent) || ts.isEnumDeclaration(parent) || ts.isEnumMember(parent) || ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) || ts.isImportSpecifier(parent) || ts.isInterfaceDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isMethodSignature(parent) || ts.isModuleDeclaration(parent) || ts.isNamespaceExport(parent) || ts.isNamespaceImport(parent) || ts.isParameter(parent) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent) || ts.isSetAccessorDeclaration(parent) || ts.isGetAccessorDeclaration(parent) || ts.isTypeAliasDeclaration(parent) || ts.isTypeParameterDeclaration(parent) || ts.isVariableDeclaration(parent)) && parent.name === node) {
2470
+ 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) {
2345
2471
  return true;
2346
2472
  }
2347
- if ((ts.isPropertyAssignment(parent) || ts.isPropertyAccessExpression(parent)) && parent.name === node) {
2473
+ if ((ts3.isPropertyAssignment(parent) || ts3.isPropertyAccessExpression(parent)) && parent.name === node) {
2348
2474
  return true;
2349
2475
  }
2350
- if (ts.isQualifiedName(parent) && parent.right === node) {
2476
+ if (ts3.isQualifiedName(parent) && parent.right === node) {
2351
2477
  return true;
2352
2478
  }
2353
2479
  return false;
@@ -2361,11 +2487,11 @@ function statementReferencesImportedName(statement, importedNames) {
2361
2487
  if (referencesImportedName) {
2362
2488
  return;
2363
2489
  }
2364
- if (ts.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
2490
+ if (ts3.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
2365
2491
  referencesImportedName = true;
2366
2492
  return;
2367
2493
  }
2368
- ts.forEachChild(node, visit);
2494
+ ts3.forEachChild(node, visit);
2369
2495
  };
2370
2496
  visit(statement);
2371
2497
  return referencesImportedName;
@@ -2376,9 +2502,9 @@ function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
2376
2502
  [...importedNames].filter((name) => !extensionTypeNames.has(name))
2377
2503
  );
2378
2504
  return sourceFile.statements.filter((statement) => {
2379
- if (ts.isImportDeclaration(statement)) return false;
2380
- if (ts.isImportEqualsDeclaration(statement)) return false;
2381
- if (ts.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0)
2505
+ if (ts3.isImportDeclaration(statement)) return false;
2506
+ if (ts3.isImportEqualsDeclaration(statement)) return false;
2507
+ if (ts3.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0)
2382
2508
  return false;
2383
2509
  if (statementReferencesImportedName(statement, importedNamesToSkip)) {
2384
2510
  return false;
@@ -2474,7 +2600,7 @@ function stripHintNullishUnion(type) {
2474
2600
  return type;
2475
2601
  }
2476
2602
  const nonNullish = type.types.filter(
2477
- (member) => (member.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) === 0
2603
+ (member) => (member.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined)) === 0
2478
2604
  );
2479
2605
  if (nonNullish.length === 1 && nonNullish[0] !== void 0) {
2480
2606
  return nonNullish[0];
@@ -2490,10 +2616,10 @@ function isUserEmittableHintProperty(property, declaration) {
2490
2616
  }
2491
2617
  if ("name" in declaration && declaration.name !== void 0) {
2492
2618
  const name = declaration.name;
2493
- if (ts.isComputedPropertyName(name) || ts.isPrivateIdentifier(name)) {
2619
+ if (ts3.isComputedPropertyName(name) || ts3.isPrivateIdentifier(name)) {
2494
2620
  return false;
2495
2621
  }
2496
- if (!ts.isIdentifier(name) && !ts.isStringLiteral(name) && !ts.isNumericLiteral(name)) {
2622
+ if (!ts3.isIdentifier(name) && !ts3.isStringLiteral(name) && !ts3.isNumericLiteral(name)) {
2497
2623
  return false;
2498
2624
  }
2499
2625
  }
@@ -2665,7 +2791,8 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2665
2791
  ];
2666
2792
  }
2667
2793
  const target = parsedTag?.target ?? null;
2668
- const hasBroadening = target === null && hasBuiltinConstraintBroadening(tagName, options);
2794
+ let evaluatedType = subjectType;
2795
+ let targetLabel = node.getText(sourceFile);
2669
2796
  if (target !== null) {
2670
2797
  if (target.kind !== "path") {
2671
2798
  return [
@@ -2705,29 +2832,30 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2705
2832
  )
2706
2833
  ];
2707
2834
  }
2708
- const requiredCapability = definition.capabilities[0];
2709
- if (requiredCapability !== void 0 && !supportsConstraintCapability(resolution.type, checker, requiredCapability)) {
2710
- const actualType = checker.typeToString(resolution.type, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
2711
- return [
2712
- makeDiagnostic(
2713
- "TYPE_MISMATCH",
2714
- `Target "${target.rawText}": constraint "${tagName}" is only valid on ${capabilityLabel(requiredCapability)} targets, but field type is "${actualType}"`,
2715
- provenance
2716
- )
2717
- ];
2835
+ evaluatedType = resolution.type;
2836
+ targetLabel = target.rawText;
2837
+ }
2838
+ const hasBroadening = (() => {
2839
+ if (target === null) {
2840
+ return hasBuiltinConstraintBroadening(tagName, options);
2718
2841
  }
2719
- } else if (!hasBroadening) {
2842
+ const registry = options?.extensionRegistry;
2843
+ if (registry === void 0) return false;
2844
+ const resolved = resolveCustomTypeFromTsType(evaluatedType, checker, registry);
2845
+ return resolved !== null && registry.findBuiltinConstraintBroadening(customTypeIdFromLookup(resolved), tagName) !== void 0;
2846
+ })();
2847
+ if (!hasBroadening) {
2720
2848
  const requiredCapability = definition.capabilities[0];
2721
- if (requiredCapability !== void 0 && !supportsConstraintCapability(subjectType, checker, requiredCapability)) {
2722
- const actualType = checker.typeToString(subjectType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
2723
- const baseMessage = `Target "${node.getText(sourceFile)}": constraint "${tagName}" is only valid on ${capabilityLabel(requiredCapability)} targets, but field type is "${actualType}"`;
2724
- const hint = buildPathTargetHint(
2849
+ if (requiredCapability !== void 0 && !supportsConstraintCapability(evaluatedType, checker, requiredCapability)) {
2850
+ const actualType = checker.typeToString(evaluatedType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
2851
+ const baseMessage = `Target "${targetLabel}": constraint "${tagName}" is only valid on ${capabilityLabel(requiredCapability)} targets, but field type is "${actualType}"`;
2852
+ const hint = target === null ? buildPathTargetHint(
2725
2853
  subjectType,
2726
2854
  checker,
2727
2855
  requiredCapability,
2728
2856
  tagName,
2729
2857
  parsedTag?.argumentText
2730
- );
2858
+ ) : null;
2731
2859
  return [
2732
2860
  makeDiagnostic(
2733
2861
  "TYPE_MISMATCH",
@@ -2860,12 +2988,12 @@ function parseTSDocTags(node, file = "", options) {
2860
2988
  const sourceText = sourceFile.getFullText();
2861
2989
  const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
2862
2990
  const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
2863
- const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
2991
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
2864
2992
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
2865
2993
  const extensionTagNames = getExtensionTagNames(options);
2866
2994
  if (commentRanges) {
2867
2995
  for (const range of commentRanges) {
2868
- if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
2996
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) {
2869
2997
  continue;
2870
2998
  }
2871
2999
  const commentText = sourceText.substring(range.pos, range.end);
@@ -3022,10 +3150,10 @@ function extractDisplayNameMetadata(node) {
3022
3150
  const memberDisplayNames = /* @__PURE__ */ new Map();
3023
3151
  const sourceFile = node.getSourceFile();
3024
3152
  const sourceText = sourceFile.getFullText();
3025
- const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
3153
+ const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
3026
3154
  if (commentRanges) {
3027
3155
  for (const range of commentRanges) {
3028
- if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
3156
+ if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) continue;
3029
3157
  const commentText = sourceText.substring(range.pos, range.end);
3030
3158
  if (!commentText.startsWith("/**")) continue;
3031
3159
  const unified = parseUnifiedComment(commentText);
@@ -3050,7 +3178,7 @@ function extractDisplayNameMetadata(node) {
3050
3178
  }
3051
3179
  function collectRawTextFallbacks(node, file) {
3052
3180
  const fallbacks = /* @__PURE__ */ new Map();
3053
- for (const tag of ts.getJSDocTags(node)) {
3181
+ for (const tag of ts3.getJSDocTags(node)) {
3054
3182
  const tagName = normalizeConstraintTagName2(tag.tagName.text);
3055
3183
  if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
3056
3184
  const commentText = getTagCommentText(tag)?.trim() ?? "";
@@ -3105,13 +3233,14 @@ function getTagCommentText(tag) {
3105
3233
  if (typeof tag.comment === "string") {
3106
3234
  return tag.comment;
3107
3235
  }
3108
- return ts.getTextOfJSDocComment(tag.comment);
3236
+ return ts3.getTextOfJSDocComment(tag.comment);
3109
3237
  }
3110
3238
  var SYNTHETIC_TYPE_FORMAT_FLAGS, MAX_HINT_CANDIDATES, MAX_HINT_DEPTH, parseResultCache;
3111
3239
  var init_tsdoc_parser = __esm({
3112
3240
  "src/analyzer/tsdoc-parser.ts"() {
3113
3241
  "use strict";
3114
- SYNTHETIC_TYPE_FORMAT_FLAGS = ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
3242
+ init_resolve_custom_type();
3243
+ SYNTHETIC_TYPE_FORMAT_FLAGS = ts3.TypeFormatFlags.NoTruncation | ts3.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
3115
3244
  MAX_HINT_CANDIDATES = 5;
3116
3245
  MAX_HINT_DEPTH = 3;
3117
3246
  parseResultCache = /* @__PURE__ */ new Map();
@@ -3119,7 +3248,7 @@ var init_tsdoc_parser = __esm({
3119
3248
  });
3120
3249
 
3121
3250
  // src/analyzer/jsdoc-constraints.ts
3122
- import * as ts2 from "typescript";
3251
+ import * as ts4 from "typescript";
3123
3252
  function extractJSDocParseResult(node, file = "", options) {
3124
3253
  return parseTSDocTags(node, file, options);
3125
3254
  }
@@ -3134,18 +3263,18 @@ function extractJSDocAnnotationNodes(node, file = "", options) {
3134
3263
  function extractDefaultValueAnnotation(initializer, file = "") {
3135
3264
  if (!initializer) return null;
3136
3265
  let value;
3137
- if (ts2.isStringLiteral(initializer)) {
3266
+ if (ts4.isStringLiteral(initializer)) {
3138
3267
  value = initializer.text;
3139
- } else if (ts2.isNumericLiteral(initializer)) {
3268
+ } else if (ts4.isNumericLiteral(initializer)) {
3140
3269
  value = Number(initializer.text);
3141
- } else if (initializer.kind === ts2.SyntaxKind.TrueKeyword) {
3270
+ } else if (initializer.kind === ts4.SyntaxKind.TrueKeyword) {
3142
3271
  value = true;
3143
- } else if (initializer.kind === ts2.SyntaxKind.FalseKeyword) {
3272
+ } else if (initializer.kind === ts4.SyntaxKind.FalseKeyword) {
3144
3273
  value = false;
3145
- } else if (initializer.kind === ts2.SyntaxKind.NullKeyword) {
3274
+ } else if (initializer.kind === ts4.SyntaxKind.NullKeyword) {
3146
3275
  value = null;
3147
- } else if (ts2.isPrefixUnaryExpression(initializer)) {
3148
- if (initializer.operator === ts2.SyntaxKind.MinusToken && ts2.isNumericLiteral(initializer.operand)) {
3276
+ } else if (ts4.isPrefixUnaryExpression(initializer)) {
3277
+ if (initializer.operator === ts4.SyntaxKind.MinusToken && ts4.isNumericLiteral(initializer.operand)) {
3149
3278
  value = -Number(initializer.operand.text);
3150
3279
  }
3151
3280
  }
@@ -3172,99 +3301,44 @@ var init_jsdoc_constraints = __esm({
3172
3301
  });
3173
3302
 
3174
3303
  // src/analyzer/class-analyzer.ts
3175
- import * as ts3 from "typescript";
3304
+ import * as ts5 from "typescript";
3176
3305
  import {
3177
3306
  analyzeMetadataForNodeWithChecker,
3178
3307
  parseCommentBlock
3179
3308
  } from "@formspec/analysis/internal";
3180
3309
  function isObjectType(type) {
3181
- return !!(type.flags & ts3.TypeFlags.Object);
3310
+ return !!(type.flags & ts5.TypeFlags.Object);
3182
3311
  }
3183
3312
  function isIntersectionType(type) {
3184
- return !!(type.flags & ts3.TypeFlags.Intersection);
3185
- }
3186
- function collectBrandIdentifiers(type) {
3187
- if (!type.isIntersection()) {
3188
- return [];
3189
- }
3190
- const brands = [];
3191
- for (const prop of type.getProperties()) {
3192
- const decl = prop.valueDeclaration ?? prop.declarations?.[0];
3193
- if (decl === void 0) continue;
3194
- if (!ts3.isPropertySignature(decl) && !ts3.isPropertyDeclaration(decl)) continue;
3195
- if (!ts3.isComputedPropertyName(decl.name)) continue;
3196
- if (!ts3.isIdentifier(decl.name.expression)) continue;
3197
- brands.push(decl.name.expression.text);
3198
- }
3199
- return brands;
3200
- }
3201
- function resolveCanonicalSymbol(type, checker) {
3202
- const raw = type.aliasSymbol ?? type.getSymbol();
3203
- if (raw === void 0) return void 0;
3204
- return raw.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(raw) : raw;
3205
- }
3206
- function resolveSymbolBasedCustomType(type, extensionRegistry, checker) {
3207
- if (extensionRegistry === void 0) {
3208
- return null;
3209
- }
3210
- const canonical = resolveCanonicalSymbol(type, checker);
3211
- if (canonical === void 0) {
3212
- return null;
3213
- }
3214
- const registration = extensionRegistry.findTypeBySymbol(canonical);
3215
- if (registration === void 0) {
3216
- return null;
3217
- }
3218
- return {
3219
- kind: "custom",
3220
- typeId: `${registration.extensionId}/${registration.registration.typeName}`,
3221
- payload: null
3222
- };
3313
+ return !!(type.flags & ts5.TypeFlags.Intersection);
3223
3314
  }
3224
3315
  function isIntegerBrandedType(type) {
3225
3316
  if (!type.isIntersection()) {
3226
3317
  return false;
3227
3318
  }
3228
- const hasNumberBase = type.types.some((member) => !!(member.flags & ts3.TypeFlags.Number));
3319
+ const hasNumberBase = type.types.some((member) => !!(member.flags & ts5.TypeFlags.Number));
3229
3320
  if (!hasNumberBase) {
3230
3321
  return false;
3231
3322
  }
3232
3323
  return collectBrandIdentifiers(type).includes("__integerBrand");
3233
3324
  }
3234
- function resolveBrandedCustomType(type, extensionRegistry) {
3235
- if (extensionRegistry === void 0) {
3236
- return null;
3237
- }
3238
- for (const brand of collectBrandIdentifiers(type)) {
3239
- const registration = extensionRegistry.findTypeByBrand(brand);
3240
- if (registration === void 0) {
3241
- continue;
3242
- }
3243
- return {
3244
- kind: "custom",
3245
- typeId: `${registration.extensionId}/${registration.registration.typeName}`,
3246
- payload: null
3247
- };
3248
- }
3249
- return null;
3250
- }
3251
3325
  function isResolvableObjectLikeAliasTypeNode(typeNode) {
3252
- if (ts3.isParenthesizedTypeNode(typeNode)) {
3326
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3253
3327
  return isResolvableObjectLikeAliasTypeNode(typeNode.type);
3254
3328
  }
3255
- if (ts3.isTypeLiteralNode(typeNode) || ts3.isTypeReferenceNode(typeNode)) {
3329
+ if (ts5.isTypeLiteralNode(typeNode) || ts5.isTypeReferenceNode(typeNode)) {
3256
3330
  return true;
3257
3331
  }
3258
- return ts3.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
3332
+ return ts5.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
3259
3333
  }
3260
3334
  function isSemanticallyPlainObjectLikeType(type, checker) {
3261
3335
  if (isIntersectionType(type)) {
3262
3336
  return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
3263
3337
  }
3264
- return isObjectType(type) && checker.getSignaturesOfType(type, ts3.SignatureKind.Call).length === 0 && checker.getSignaturesOfType(type, ts3.SignatureKind.Construct).length === 0 && !checker.isArrayType(type) && !checker.isTupleType(type);
3338
+ 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);
3265
3339
  }
3266
3340
  function isTypeReference(type) {
3267
- return !!(type.flags & ts3.TypeFlags.Object) && !!(type.objectFlags & ts3.ObjectFlags.Reference);
3341
+ return !!(type.flags & ts5.TypeFlags.Object) && !!(type.objectFlags & ts5.ObjectFlags.Reference);
3268
3342
  }
3269
3343
  function makeParseOptions(extensionRegistry, fieldType, checker, subjectType, hostType) {
3270
3344
  if (extensionRegistry === void 0 && fieldType === void 0 && checker === void 0 && subjectType === void 0 && hostType === void 0) {
@@ -3324,7 +3398,7 @@ function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node,
3324
3398
  function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRegistry, metadataPolicy) {
3325
3399
  const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
3326
3400
  const declarationType = checker.getTypeAtLocation(declaration);
3327
- const logicalName = ts3.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
3401
+ const logicalName = ts5.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
3328
3402
  const docResult = extractJSDocParseResult(
3329
3403
  declaration,
3330
3404
  file,
@@ -3372,7 +3446,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3372
3446
  const instanceMethods = [];
3373
3447
  const staticMethods = [];
3374
3448
  for (const member of classDecl.members) {
3375
- if (ts3.isPropertyDeclaration(member)) {
3449
+ if (ts5.isPropertyDeclaration(member)) {
3376
3450
  const fieldNode = analyzeFieldToIR(
3377
3451
  member,
3378
3452
  checker,
@@ -3388,10 +3462,10 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3388
3462
  fields.push(fieldNode);
3389
3463
  fieldLayouts.push({});
3390
3464
  }
3391
- } else if (ts3.isMethodDeclaration(member)) {
3465
+ } else if (ts5.isMethodDeclaration(member)) {
3392
3466
  const methodInfo = analyzeMethod(member, checker);
3393
3467
  if (methodInfo) {
3394
- const isStatic = member.modifiers?.some((m) => m.kind === ts3.SyntaxKind.StaticKeyword);
3468
+ const isStatic = member.modifiers?.some((m) => m.kind === ts5.SyntaxKind.StaticKeyword);
3395
3469
  if (isStatic) {
3396
3470
  staticMethods.push(methodInfo);
3397
3471
  } else {
@@ -3454,7 +3528,7 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3454
3528
  diagnostics.push(...interfaceDoc.diagnostics);
3455
3529
  const visiting = /* @__PURE__ */ new Set();
3456
3530
  for (const member of interfaceDecl.members) {
3457
- if (ts3.isPropertySignature(member)) {
3531
+ if (ts5.isPropertySignature(member)) {
3458
3532
  const fieldNode = analyzeInterfacePropertyToIR(
3459
3533
  member,
3460
3534
  checker,
@@ -3512,7 +3586,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3512
3586
  if (members === null) {
3513
3587
  const sourceFile = typeAlias.getSourceFile();
3514
3588
  const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
3515
- const kindDesc = ts3.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3589
+ const kindDesc = ts5.SyntaxKind[typeAlias.type.kind] ?? "unknown";
3516
3590
  return {
3517
3591
  ok: false,
3518
3592
  kind: "not-object-like",
@@ -3547,7 +3621,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3547
3621
  diagnostics.push(...typeAliasDoc.diagnostics);
3548
3622
  const visiting = /* @__PURE__ */ new Set();
3549
3623
  for (const member of members) {
3550
- if (ts3.isPropertySignature(member)) {
3624
+ if (ts5.isPropertySignature(member)) {
3551
3625
  const fieldNode = analyzeInterfacePropertyToIR(
3552
3626
  member,
3553
3627
  checker,
@@ -3614,13 +3688,13 @@ function makeAnalysisDiagnostic(code, message, primaryLocation, relatedLocations
3614
3688
  function getLeadingParsedTags(node) {
3615
3689
  const sourceFile = node.getSourceFile();
3616
3690
  const sourceText = sourceFile.getFullText();
3617
- const commentRanges = ts3.getLeadingCommentRanges(sourceText, node.getFullStart());
3691
+ const commentRanges = ts5.getLeadingCommentRanges(sourceText, node.getFullStart());
3618
3692
  if (commentRanges === void 0) {
3619
3693
  return [];
3620
3694
  }
3621
3695
  const parsedTags = [];
3622
3696
  for (const range of commentRanges) {
3623
- if (range.kind !== ts3.SyntaxKind.MultiLineCommentTrivia) {
3697
+ if (range.kind !== ts5.SyntaxKind.MultiLineCommentTrivia) {
3624
3698
  continue;
3625
3699
  }
3626
3700
  const commentText = sourceText.slice(range.pos, range.end);
@@ -3638,19 +3712,19 @@ function resolveDiscriminatorProperty(node, checker, fieldName) {
3638
3712
  return null;
3639
3713
  }
3640
3714
  const declaration = propertySymbol.valueDeclaration ?? propertySymbol.declarations?.find(
3641
- (candidate) => ts3.isPropertyDeclaration(candidate) || ts3.isPropertySignature(candidate)
3715
+ (candidate) => ts5.isPropertyDeclaration(candidate) || ts5.isPropertySignature(candidate)
3642
3716
  ) ?? propertySymbol.declarations?.[0];
3643
3717
  return {
3644
3718
  declaration,
3645
3719
  type: checker.getTypeOfSymbolAtLocation(propertySymbol, declaration ?? node),
3646
- optional: !!(propertySymbol.flags & ts3.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
3720
+ optional: !!(propertySymbol.flags & ts5.SymbolFlags.Optional) || declaration !== void 0 && "questionToken" in declaration && declaration.questionToken !== void 0
3647
3721
  };
3648
3722
  }
3649
3723
  function isLocalTypeParameterName(node, typeParameterName) {
3650
3724
  return node.typeParameters?.some((typeParameter) => typeParameter.name.text === typeParameterName) ?? false;
3651
3725
  }
3652
3726
  function isNullishSemanticType(type) {
3653
- if (type.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined | ts3.TypeFlags.Void | ts3.TypeFlags.Unknown | ts3.TypeFlags.Any)) {
3727
+ if (type.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined | ts5.TypeFlags.Void | ts5.TypeFlags.Unknown | ts5.TypeFlags.Any)) {
3654
3728
  return true;
3655
3729
  }
3656
3730
  return type.isUnion() && type.types.some((member) => isNullishSemanticType(member));
@@ -3660,7 +3734,7 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
3660
3734
  return false;
3661
3735
  }
3662
3736
  seen.add(type);
3663
- if (type.flags & ts3.TypeFlags.StringLike) {
3737
+ if (type.flags & ts5.TypeFlags.StringLike) {
3664
3738
  return true;
3665
3739
  }
3666
3740
  if (type.isUnion()) {
@@ -3673,13 +3747,13 @@ function isStringLikeSemanticType(type, checker, seen = /* @__PURE__ */ new Set(
3673
3747
  return false;
3674
3748
  }
3675
3749
  function getObjectLikeTypeAliasMembers(typeNode) {
3676
- if (ts3.isParenthesizedTypeNode(typeNode)) {
3750
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
3677
3751
  return getObjectLikeTypeAliasMembers(typeNode.type);
3678
3752
  }
3679
- if (ts3.isTypeLiteralNode(typeNode)) {
3753
+ if (ts5.isTypeLiteralNode(typeNode)) {
3680
3754
  return [...typeNode.members];
3681
3755
  }
3682
- if (ts3.isIntersectionTypeNode(typeNode)) {
3756
+ if (ts5.isIntersectionTypeNode(typeNode)) {
3683
3757
  const members = [];
3684
3758
  for (const intersectionMember of typeNode.types) {
3685
3759
  const resolvedMembers = getObjectLikeTypeAliasMembers(intersectionMember);
@@ -3842,7 +3916,7 @@ function resolveLiteralDiscriminatorPropertyValue(boundType, propertyName, check
3842
3916
  }
3843
3917
  if (propertyType.isUnion()) {
3844
3918
  const nonNullMembers = propertyType.types.filter(
3845
- (member) => !(member.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined))
3919
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
3846
3920
  );
3847
3921
  if (nonNullMembers.length > 0 && nonNullMembers.every((member) => member.isStringLiteral())) {
3848
3922
  diagnostics.push(
@@ -3891,13 +3965,13 @@ function resolveNamedDiscriminatorDeclaration(type, checker, seen = /* @__PURE__
3891
3965
  seen.add(type);
3892
3966
  const symbol = type.aliasSymbol ?? type.getSymbol();
3893
3967
  if (symbol !== void 0) {
3894
- const aliased = symbol.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
3968
+ const aliased = symbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : void 0;
3895
3969
  const targetSymbol = aliased ?? symbol;
3896
3970
  const declaration = targetSymbol.declarations?.find(
3897
- (candidate) => ts3.isClassDeclaration(candidate) || ts3.isInterfaceDeclaration(candidate) || ts3.isTypeAliasDeclaration(candidate) || ts3.isEnumDeclaration(candidate)
3971
+ (candidate) => ts5.isClassDeclaration(candidate) || ts5.isInterfaceDeclaration(candidate) || ts5.isTypeAliasDeclaration(candidate) || ts5.isEnumDeclaration(candidate)
3898
3972
  );
3899
3973
  if (declaration !== void 0) {
3900
- if (ts3.isTypeAliasDeclaration(declaration) && ts3.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
3974
+ if (ts5.isTypeAliasDeclaration(declaration) && ts5.isTypeReferenceNode(declaration.type) && checker.getTypeFromTypeNode(declaration.type) !== type) {
3901
3975
  return resolveNamedDiscriminatorDeclaration(
3902
3976
  checker.getTypeFromTypeNode(declaration.type),
3903
3977
  checker,
@@ -3925,7 +3999,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
3925
3999
  }
3926
4000
  if (boundType.isUnion()) {
3927
4001
  const nonNullMembers = boundType.types.filter(
3928
- (member) => !(member.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined))
4002
+ (member) => !(member.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
3929
4003
  );
3930
4004
  if (nonNullMembers.every((member) => member.isStringLiteral())) {
3931
4005
  diagnostics.push(
@@ -3970,7 +4044,7 @@ function resolveDiscriminatorValue(boundType, fieldName, checker, provenance, di
3970
4044
  return null;
3971
4045
  }
3972
4046
  function getDeclarationName(node) {
3973
- if (ts3.isClassDeclaration(node) || ts3.isInterfaceDeclaration(node) || ts3.isTypeAliasDeclaration(node) || ts3.isEnumDeclaration(node)) {
4047
+ if (ts5.isClassDeclaration(node) || ts5.isInterfaceDeclaration(node) || ts5.isTypeAliasDeclaration(node) || ts5.isEnumDeclaration(node)) {
3974
4048
  return node.name?.text ?? "anonymous";
3975
4049
  }
3976
4050
  return "anonymous";
@@ -4025,11 +4099,11 @@ function extractReferenceTypeArguments(type, checker, file, typeRegistry, visiti
4025
4099
  if (sourceTypeNode === void 0) {
4026
4100
  return [];
4027
4101
  }
4028
- const unwrapParentheses = (typeNode) => ts3.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
4102
+ const unwrapParentheses = (typeNode) => ts5.isParenthesizedTypeNode(typeNode) ? unwrapParentheses(typeNode.type) : typeNode;
4029
4103
  const directTypeNode = unwrapParentheses(sourceTypeNode);
4030
- const referenceTypeNode = ts3.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
4104
+ const referenceTypeNode = ts5.isTypeReferenceNode(directTypeNode) ? directTypeNode : (() => {
4031
4105
  const resolvedTypeNode = resolveAliasedTypeNode(directTypeNode, checker);
4032
- return ts3.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
4106
+ return ts5.isTypeReferenceNode(resolvedTypeNode) ? resolvedTypeNode : null;
4033
4107
  })();
4034
4108
  if (referenceTypeNode?.typeArguments === void 0) {
4035
4109
  return [];
@@ -4084,7 +4158,7 @@ function applyDiscriminatorToObjectProperties(properties, node, subjectType, che
4084
4158
  );
4085
4159
  }
4086
4160
  function analyzeFieldToIR(prop, checker, file, typeRegistry, visiting, diagnostics, hostType, metadataPolicy, extensionRegistry) {
4087
- if (!ts3.isIdentifier(prop.name)) {
4161
+ if (!ts5.isIdentifier(prop.name)) {
4088
4162
  return null;
4089
4163
  }
4090
4164
  const name = prop.name.text;
@@ -4211,7 +4285,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
4211
4285
  const seen = /* @__PURE__ */ new Set();
4212
4286
  const duplicates = /* @__PURE__ */ new Set();
4213
4287
  for (const member of members) {
4214
- if (!ts3.isPropertySignature(member)) {
4288
+ if (!ts5.isPropertySignature(member)) {
4215
4289
  continue;
4216
4290
  }
4217
4291
  const name = getAnalyzableObjectLikePropertyName(member.name);
@@ -4227,7 +4301,7 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
4227
4301
  return [...duplicates].sort();
4228
4302
  }
4229
4303
  function getAnalyzableObjectLikePropertyName(name) {
4230
- if (ts3.isIdentifier(name) || ts3.isStringLiteral(name) || ts3.isNumericLiteral(name)) {
4304
+ if (ts5.isIdentifier(name) || ts5.isStringLiteral(name) || ts5.isNumericLiteral(name)) {
4231
4305
  return name.text;
4232
4306
  }
4233
4307
  return null;
@@ -4294,74 +4368,20 @@ function parseEnumMemberDisplayName(value) {
4294
4368
  if (label === "") return null;
4295
4369
  return { value: match[1], label };
4296
4370
  }
4297
- function resolveRegisteredCustomType(sourceNode, extensionRegistry, checker) {
4298
- if (sourceNode === void 0 || extensionRegistry === void 0) {
4299
- return null;
4300
- }
4301
- const typeNode = extractTypeNodeFromSource(sourceNode);
4302
- if (typeNode === void 0) {
4303
- return null;
4304
- }
4305
- return resolveRegisteredCustomTypeFromTypeNode(typeNode, extensionRegistry, checker);
4306
- }
4307
- function resolveRegisteredCustomTypeFromTypeNode(typeNode, extensionRegistry, checker) {
4308
- if (ts3.isParenthesizedTypeNode(typeNode)) {
4309
- return resolveRegisteredCustomTypeFromTypeNode(typeNode.type, extensionRegistry, checker);
4310
- }
4311
- const typeName = getTypeNodeRegistrationName(typeNode);
4312
- if (typeName === null) {
4313
- return null;
4314
- }
4315
- const registration = extensionRegistry.findTypeByName(typeName);
4316
- if (registration !== void 0) {
4371
+ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4372
+ const customTypeLookup = resolveCustomTypeFromTsType(
4373
+ type,
4374
+ checker,
4375
+ extensionRegistry,
4376
+ sourceNode
4377
+ );
4378
+ if (customTypeLookup !== null) {
4317
4379
  return {
4318
4380
  kind: "custom",
4319
- typeId: `${registration.extensionId}/${registration.registration.typeName}`,
4381
+ typeId: customTypeIdFromLookup(customTypeLookup),
4320
4382
  payload: null
4321
4383
  };
4322
4384
  }
4323
- if (ts3.isTypeReferenceNode(typeNode) && ts3.isIdentifier(typeNode.typeName)) {
4324
- const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4325
- if (aliasDecl !== void 0) {
4326
- return resolveRegisteredCustomTypeFromTypeNode(aliasDecl.type, extensionRegistry, checker);
4327
- }
4328
- }
4329
- return null;
4330
- }
4331
- function extractTypeNodeFromSource(sourceNode) {
4332
- if (ts3.isPropertyDeclaration(sourceNode) || ts3.isPropertySignature(sourceNode) || ts3.isParameter(sourceNode) || ts3.isTypeAliasDeclaration(sourceNode)) {
4333
- return sourceNode.type;
4334
- }
4335
- if (ts3.isTypeNode(sourceNode)) {
4336
- return sourceNode;
4337
- }
4338
- return void 0;
4339
- }
4340
- function getTypeNodeRegistrationName(typeNode) {
4341
- if (ts3.isTypeReferenceNode(typeNode)) {
4342
- return ts3.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : typeNode.typeName.right.text;
4343
- }
4344
- if (ts3.isParenthesizedTypeNode(typeNode)) {
4345
- return getTypeNodeRegistrationName(typeNode.type);
4346
- }
4347
- if (typeNode.kind === ts3.SyntaxKind.BigIntKeyword || typeNode.kind === ts3.SyntaxKind.StringKeyword || typeNode.kind === ts3.SyntaxKind.NumberKeyword || typeNode.kind === ts3.SyntaxKind.BooleanKeyword) {
4348
- return typeNode.getText();
4349
- }
4350
- return null;
4351
- }
4352
- function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4353
- const customType = resolveRegisteredCustomType(sourceNode, extensionRegistry, checker);
4354
- if (customType) {
4355
- return customType;
4356
- }
4357
- const symbolCustomType = resolveSymbolBasedCustomType(type, extensionRegistry, checker);
4358
- if (symbolCustomType) {
4359
- return symbolCustomType;
4360
- }
4361
- const brandedCustomType = resolveBrandedCustomType(type, extensionRegistry);
4362
- if (brandedCustomType) {
4363
- return brandedCustomType;
4364
- }
4365
4385
  const primitiveAlias = tryResolveNamedPrimitiveAlias(
4366
4386
  type,
4367
4387
  checker,
@@ -4379,25 +4399,25 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4379
4399
  if (isIntegerBrandedType(type)) {
4380
4400
  return { kind: "primitive", primitiveKind: "integer" };
4381
4401
  }
4382
- if (type.flags & ts3.TypeFlags.String) {
4402
+ if (type.flags & ts5.TypeFlags.String) {
4383
4403
  return { kind: "primitive", primitiveKind: "string" };
4384
4404
  }
4385
- if (type.flags & ts3.TypeFlags.Number) {
4405
+ if (type.flags & ts5.TypeFlags.Number) {
4386
4406
  return { kind: "primitive", primitiveKind: "number" };
4387
4407
  }
4388
- if (type.flags & (ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral)) {
4408
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
4389
4409
  return { kind: "primitive", primitiveKind: "bigint" };
4390
4410
  }
4391
- if (type.flags & ts3.TypeFlags.Boolean) {
4411
+ if (type.flags & ts5.TypeFlags.Boolean) {
4392
4412
  return { kind: "primitive", primitiveKind: "boolean" };
4393
4413
  }
4394
- if (type.flags & ts3.TypeFlags.Null) {
4414
+ if (type.flags & ts5.TypeFlags.Null) {
4395
4415
  return { kind: "primitive", primitiveKind: "null" };
4396
4416
  }
4397
- if (type.flags & ts3.TypeFlags.Undefined) {
4417
+ if (type.flags & ts5.TypeFlags.Undefined) {
4398
4418
  return { kind: "primitive", primitiveKind: "null" };
4399
4419
  }
4400
- if (type.flags & ts3.TypeFlags.Void) {
4420
+ if (type.flags & ts5.TypeFlags.Void) {
4401
4421
  return { kind: "primitive", primitiveKind: "null" };
4402
4422
  }
4403
4423
  if (type.isStringLiteral()) {
@@ -4484,10 +4504,10 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4484
4504
  return { kind: "primitive", primitiveKind: "string" };
4485
4505
  }
4486
4506
  function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4487
- if (!(type.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
4507
+ if (!(type.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
4488
4508
  return null;
4489
4509
  }
4490
- const aliasDecl = type.aliasSymbol?.declarations?.find(ts3.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
4510
+ const aliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
4491
4511
  if (!aliasDecl) {
4492
4512
  return null;
4493
4513
  }
@@ -4537,14 +4557,14 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
4537
4557
  return { kind: "reference", name: aliasName, typeArguments: [] };
4538
4558
  }
4539
4559
  function getReferencedTypeAliasDeclaration(sourceNode, checker) {
4540
- const typeNode = sourceNode && (ts3.isPropertyDeclaration(sourceNode) || ts3.isPropertySignature(sourceNode) || ts3.isParameter(sourceNode)) ? sourceNode.type : void 0;
4541
- if (!typeNode || !ts3.isTypeReferenceNode(typeNode)) {
4560
+ const typeNode = sourceNode && (ts5.isPropertyDeclaration(sourceNode) || ts5.isPropertySignature(sourceNode) || ts5.isParameter(sourceNode)) ? sourceNode.type : void 0;
4561
+ if (!typeNode || !ts5.isTypeReferenceNode(typeNode)) {
4542
4562
  return void 0;
4543
4563
  }
4544
4564
  return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4545
4565
  }
4546
4566
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4547
- if (!ts3.isTypeReferenceNode(typeNode)) {
4567
+ if (!ts5.isTypeReferenceNode(typeNode)) {
4548
4568
  return false;
4549
4569
  }
4550
4570
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -4552,10 +4572,10 @@ function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4552
4572
  return false;
4553
4573
  }
4554
4574
  const resolved = checker.getTypeFromTypeNode(aliasDecl.type);
4555
- return !!(resolved.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null));
4575
+ return !!(resolved.flags & (ts5.TypeFlags.String | ts5.TypeFlags.Number | ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral | ts5.TypeFlags.Boolean | ts5.TypeFlags.Null));
4556
4576
  }
4557
4577
  function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics, visitedAliases = /* @__PURE__ */ new Set()) {
4558
- const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts3.isTypeAliasDeclaration);
4578
+ const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts5.isTypeAliasDeclaration);
4559
4579
  if (nestedAliasDecl !== void 0 && !visitedAliases.has(nestedAliasDecl)) {
4560
4580
  visitedAliases.add(nestedAliasDecl);
4561
4581
  return resolveAliasedPrimitiveTarget(
@@ -4573,19 +4593,19 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
4573
4593
  if (isIntegerBrandedType(type)) {
4574
4594
  return { kind: "primitive", primitiveKind: "integer" };
4575
4595
  }
4576
- if (type.flags & ts3.TypeFlags.String) {
4596
+ if (type.flags & ts5.TypeFlags.String) {
4577
4597
  return { kind: "primitive", primitiveKind: "string" };
4578
4598
  }
4579
- if (type.flags & ts3.TypeFlags.Number) {
4599
+ if (type.flags & ts5.TypeFlags.Number) {
4580
4600
  return { kind: "primitive", primitiveKind: "number" };
4581
4601
  }
4582
- if (type.flags & (ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral)) {
4602
+ if (type.flags & (ts5.TypeFlags.BigInt | ts5.TypeFlags.BigIntLiteral)) {
4583
4603
  return { kind: "primitive", primitiveKind: "bigint" };
4584
4604
  }
4585
- if (type.flags & ts3.TypeFlags.Boolean) {
4605
+ if (type.flags & ts5.TypeFlags.Boolean) {
4586
4606
  return { kind: "primitive", primitiveKind: "boolean" };
4587
4607
  }
4588
- if (type.flags & ts3.TypeFlags.Null) {
4608
+ if (type.flags & ts5.TypeFlags.Null) {
4589
4609
  return { kind: "primitive", primitiveKind: "null" };
4590
4610
  }
4591
4611
  return resolveTypeNode(
@@ -4612,13 +4632,13 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4612
4632
  (memberTypeNode) => !isNullishTypeNode(resolveAliasedTypeNode(memberTypeNode, checker))
4613
4633
  );
4614
4634
  const nonNullTypes = allTypes.filter(
4615
- (memberType) => !(memberType.flags & (ts3.TypeFlags.Null | ts3.TypeFlags.Undefined))
4635
+ (memberType) => !(memberType.flags & (ts5.TypeFlags.Null | ts5.TypeFlags.Undefined))
4616
4636
  );
4617
4637
  const nonNullMembers = nonNullTypes.map((memberType, index) => ({
4618
4638
  memberType,
4619
4639
  sourceNode: nonNullSourceNodes.length === nonNullTypes.length ? nonNullSourceNodes[index] : void 0
4620
4640
  }));
4621
- const hasNull = allTypes.some((t) => t.flags & ts3.TypeFlags.Null);
4641
+ const hasNull = allTypes.some((t) => t.flags & ts5.TypeFlags.Null);
4622
4642
  const memberDisplayNames = /* @__PURE__ */ new Map();
4623
4643
  if (namedDecl) {
4624
4644
  for (const [value, label] of extractDisplayNameMetadata(namedDecl).memberDisplayNames) {
@@ -4661,7 +4681,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4661
4681
  const displayName = memberDisplayNames.get(String(value));
4662
4682
  return displayName !== void 0 ? { value, displayName } : { value };
4663
4683
  });
4664
- const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts3.TypeFlags.BooleanLiteral);
4684
+ const isBooleanUnion2 = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts5.TypeFlags.BooleanLiteral);
4665
4685
  if (isBooleanUnion2) {
4666
4686
  const boolNode = { kind: "primitive", primitiveKind: "boolean" };
4667
4687
  const result = hasNull ? {
@@ -4753,7 +4773,7 @@ function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metad
4753
4773
  if (type.getProperties().length > 0) {
4754
4774
  return null;
4755
4775
  }
4756
- const indexInfo = checker.getIndexInfoOfType(type, ts3.IndexKind.String);
4776
+ const indexInfo = checker.getIndexInfoOfType(type, ts5.IndexKind.String);
4757
4777
  if (!indexInfo) {
4758
4778
  return null;
4759
4779
  }
@@ -4801,10 +4821,10 @@ function shouldEmitResolvedObjectProperty(property, declaration) {
4801
4821
  }
4802
4822
  if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
4803
4823
  const name = declaration.name;
4804
- if (ts3.isComputedPropertyName(name) || ts3.isPrivateIdentifier(name)) {
4824
+ if (ts5.isComputedPropertyName(name) || ts5.isPrivateIdentifier(name)) {
4805
4825
  return false;
4806
4826
  }
4807
- if (!ts3.isIdentifier(name) && !ts3.isStringLiteral(name) && !ts3.isNumericLiteral(name)) {
4827
+ if (!ts5.isIdentifier(name) && !ts5.isStringLiteral(name) && !ts5.isNumericLiteral(name)) {
4808
4828
  return false;
4809
4829
  }
4810
4830
  }
@@ -4930,7 +4950,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
4930
4950
  if (!declaration) continue;
4931
4951
  if (!shouldEmitResolvedObjectProperty(prop, declaration)) continue;
4932
4952
  const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);
4933
- const optional = !!(prop.flags & ts3.SymbolFlags.Optional);
4953
+ const optional = !!(prop.flags & ts5.SymbolFlags.Optional);
4934
4954
  const propTypeNode = resolveTypeNode(
4935
4955
  propType,
4936
4956
  checker,
@@ -4943,7 +4963,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
4943
4963
  collectedDiagnostics
4944
4964
  );
4945
4965
  const fieldNodeInfo = fieldInfoMap?.get(prop.name);
4946
- const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts3.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
4966
+ const inlineFieldNodeInfo = fieldNodeInfo === void 0 ? ts5.isPropertySignature(declaration) ? analyzeInterfacePropertyToIR(
4947
4967
  declaration,
4948
4968
  checker,
4949
4969
  file,
@@ -4953,7 +4973,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
4953
4973
  type,
4954
4974
  metadataPolicy,
4955
4975
  extensionRegistry
4956
- ) : ts3.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
4976
+ ) : ts5.isPropertyDeclaration(declaration) ? analyzeFieldToIR(
4957
4977
  declaration,
4958
4978
  checker,
4959
4979
  file,
@@ -4981,7 +5001,7 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
4981
5001
  visiting.delete(type);
4982
5002
  const objectNode = {
4983
5003
  kind: "object",
4984
- properties: namedDecl !== void 0 && (ts3.isClassDeclaration(namedDecl) || ts3.isInterfaceDeclaration(namedDecl) || ts3.isTypeAliasDeclaration(namedDecl)) ? applyDiscriminatorToObjectProperties(
5004
+ properties: namedDecl !== void 0 && (ts5.isClassDeclaration(namedDecl) || ts5.isInterfaceDeclaration(namedDecl) || ts5.isTypeAliasDeclaration(namedDecl)) ? applyDiscriminatorToObjectProperties(
4985
5005
  properties,
4986
5006
  namedDecl,
4987
5007
  type,
@@ -5029,12 +5049,12 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5029
5049
  for (const symbol of symbols) {
5030
5050
  const declarations = symbol.declarations;
5031
5051
  if (!declarations) continue;
5032
- const classDecl = declarations.find(ts3.isClassDeclaration);
5052
+ const classDecl = declarations.find(ts5.isClassDeclaration);
5033
5053
  if (classDecl) {
5034
5054
  const map = /* @__PURE__ */ new Map();
5035
5055
  const hostType = checker.getTypeAtLocation(classDecl);
5036
5056
  for (const member of classDecl.members) {
5037
- if (ts3.isPropertyDeclaration(member) && ts3.isIdentifier(member.name)) {
5057
+ if (ts5.isPropertyDeclaration(member) && ts5.isIdentifier(member.name)) {
5038
5058
  const fieldNode = analyzeFieldToIR(
5039
5059
  member,
5040
5060
  checker,
@@ -5058,7 +5078,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5058
5078
  }
5059
5079
  return map;
5060
5080
  }
5061
- const interfaceDecl = declarations.find(ts3.isInterfaceDeclaration);
5081
+ const interfaceDecl = declarations.find(ts5.isInterfaceDeclaration);
5062
5082
  if (interfaceDecl) {
5063
5083
  return buildFieldNodeInfoMap(
5064
5084
  interfaceDecl.members,
@@ -5072,7 +5092,7 @@ function getNamedTypeFieldNodeInfoMap(type, checker, file, typeRegistry, visitin
5072
5092
  extensionRegistry
5073
5093
  );
5074
5094
  }
5075
- const typeAliasDecl = declarations.find(ts3.isTypeAliasDeclaration);
5095
+ const typeAliasDecl = declarations.find(ts5.isTypeAliasDeclaration);
5076
5096
  const typeAliasMembers = typeAliasDecl === void 0 ? null : getObjectLikeTypeAliasMembers(typeAliasDecl.type);
5077
5097
  if (typeAliasDecl && typeAliasMembers !== null) {
5078
5098
  return buildFieldNodeInfoMap(
@@ -5096,10 +5116,10 @@ function extractArrayElementTypeNode(sourceNode, checker) {
5096
5116
  return void 0;
5097
5117
  }
5098
5118
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
5099
- if (ts3.isArrayTypeNode(resolvedTypeNode)) {
5119
+ if (ts5.isArrayTypeNode(resolvedTypeNode)) {
5100
5120
  return resolvedTypeNode.elementType;
5101
5121
  }
5102
- if (ts3.isTypeReferenceNode(resolvedTypeNode) && ts3.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
5122
+ if (ts5.isTypeReferenceNode(resolvedTypeNode) && ts5.isIdentifier(resolvedTypeNode.typeName) && resolvedTypeNode.typeName.text === "Array" && resolvedTypeNode.typeArguments?.[0]) {
5103
5123
  return resolvedTypeNode.typeArguments[0];
5104
5124
  }
5105
5125
  return void 0;
@@ -5110,13 +5130,13 @@ function extractUnionMemberTypeNodes(sourceNode, checker) {
5110
5130
  return [];
5111
5131
  }
5112
5132
  const resolvedTypeNode = resolveAliasedTypeNode(typeNode, checker);
5113
- return ts3.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
5133
+ return ts5.isUnionTypeNode(resolvedTypeNode) ? [...resolvedTypeNode.types] : [];
5114
5134
  }
5115
5135
  function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new Set()) {
5116
- if (ts3.isParenthesizedTypeNode(typeNode)) {
5136
+ if (ts5.isParenthesizedTypeNode(typeNode)) {
5117
5137
  return resolveAliasedTypeNode(typeNode.type, checker, visited);
5118
5138
  }
5119
- if (!ts3.isTypeReferenceNode(typeNode) || !ts3.isIdentifier(typeNode.typeName)) {
5139
+ if (!ts5.isTypeReferenceNode(typeNode) || !ts5.isIdentifier(typeNode.typeName)) {
5120
5140
  return typeNode;
5121
5141
  }
5122
5142
  const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
@@ -5127,15 +5147,15 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
5127
5147
  return resolveAliasedTypeNode(aliasDecl.type, checker, visited);
5128
5148
  }
5129
5149
  function isNullishTypeNode(typeNode) {
5130
- if (typeNode.kind === ts3.SyntaxKind.NullKeyword || typeNode.kind === ts3.SyntaxKind.UndefinedKeyword) {
5150
+ if (typeNode.kind === ts5.SyntaxKind.NullKeyword || typeNode.kind === ts5.SyntaxKind.UndefinedKeyword) {
5131
5151
  return true;
5132
5152
  }
5133
- return ts3.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts3.SyntaxKind.NullKeyword || typeNode.literal.kind === ts3.SyntaxKind.UndefinedKeyword);
5153
+ return ts5.isLiteralTypeNode(typeNode) && (typeNode.literal.kind === ts5.SyntaxKind.NullKeyword || typeNode.literal.kind === ts5.SyntaxKind.UndefinedKeyword);
5134
5154
  }
5135
5155
  function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, metadataPolicy, hostType, diagnostics, extensionRegistry) {
5136
5156
  const map = /* @__PURE__ */ new Map();
5137
5157
  for (const member of members) {
5138
- if (ts3.isPropertySignature(member)) {
5158
+ if (ts5.isPropertySignature(member)) {
5139
5159
  const fieldNode = analyzeInterfacePropertyToIR(
5140
5160
  member,
5141
5161
  checker,
@@ -5160,17 +5180,16 @@ function buildFieldNodeInfoMap(members, checker, file, typeRegistry, visiting, m
5160
5180
  return map;
5161
5181
  }
5162
5182
  function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegistry, depth = 0) {
5163
- if (!ts3.isTypeReferenceNode(typeNode)) return [];
5183
+ if (!ts5.isTypeReferenceNode(typeNode)) return [];
5164
5184
  if (depth >= MAX_ALIAS_CHAIN_DEPTH) {
5165
5185
  const aliasName = typeNode.typeName.getText();
5166
5186
  throw new Error(
5167
5187
  `Type alias chain exceeds maximum depth of ${String(MAX_ALIAS_CHAIN_DEPTH)} at alias "${aliasName}" in ${file}. Simplify the alias chain or check for circular references.`
5168
5188
  );
5169
5189
  }
5170
- const symbol = checker.getSymbolAtLocation(typeNode.typeName);
5171
- const aliasDecl = getAliasedTypeAliasDeclaration(symbol, checker);
5190
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
5172
5191
  if (!aliasDecl) return [];
5173
- if (ts3.isTypeLiteralNode(aliasDecl.type)) return [];
5192
+ if (ts5.isTypeLiteralNode(aliasDecl.type)) return [];
5174
5193
  const aliasFieldType = resolveTypeNode(
5175
5194
  checker.getTypeAtLocation(aliasDecl.type),
5176
5195
  checker,
@@ -5191,18 +5210,6 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
5191
5210
  );
5192
5211
  return constraints;
5193
5212
  }
5194
- function getAliasedSymbol(symbol, checker) {
5195
- if (symbol === void 0) {
5196
- return void 0;
5197
- }
5198
- return symbol.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
5199
- }
5200
- function getAliasedTypeAliasDeclaration(symbol, checker) {
5201
- return getAliasedSymbol(symbol, checker)?.declarations?.find(ts3.isTypeAliasDeclaration);
5202
- }
5203
- function getTypeAliasDeclarationFromTypeReference(typeNode, checker) {
5204
- return getAliasedTypeAliasDeclaration(checker.getSymbolAtLocation(typeNode.typeName), checker);
5205
- }
5206
5213
  function provenanceForNode(node, file) {
5207
5214
  const sourceFile = node.getSourceFile();
5208
5215
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
@@ -5226,14 +5233,14 @@ function getNamedTypeName(type) {
5226
5233
  const symbol = type.getSymbol();
5227
5234
  if (symbol?.declarations) {
5228
5235
  const decl = symbol.declarations[0];
5229
- if (decl && (ts3.isClassDeclaration(decl) || ts3.isInterfaceDeclaration(decl) || ts3.isTypeAliasDeclaration(decl))) {
5230
- const name = ts3.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
5236
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
5237
+ const name = ts5.isClassDeclaration(decl) ? decl.name?.text : decl.name.text;
5231
5238
  if (name) return name;
5232
5239
  }
5233
5240
  }
5234
5241
  const aliasSymbol = type.aliasSymbol;
5235
5242
  if (aliasSymbol?.declarations) {
5236
- const aliasDecl = aliasSymbol.declarations.find(ts3.isTypeAliasDeclaration);
5243
+ const aliasDecl = aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
5237
5244
  if (aliasDecl) {
5238
5245
  return aliasDecl.name.text;
5239
5246
  }
@@ -5244,24 +5251,24 @@ function getNamedTypeDeclaration(type) {
5244
5251
  const symbol = type.getSymbol();
5245
5252
  if (symbol?.declarations) {
5246
5253
  const decl = symbol.declarations[0];
5247
- if (decl && (ts3.isClassDeclaration(decl) || ts3.isInterfaceDeclaration(decl) || ts3.isTypeAliasDeclaration(decl))) {
5254
+ if (decl && (ts5.isClassDeclaration(decl) || ts5.isInterfaceDeclaration(decl) || ts5.isTypeAliasDeclaration(decl))) {
5248
5255
  return decl;
5249
5256
  }
5250
5257
  }
5251
5258
  const aliasSymbol = type.aliasSymbol;
5252
5259
  if (aliasSymbol?.declarations) {
5253
- return aliasSymbol.declarations.find(ts3.isTypeAliasDeclaration);
5260
+ return aliasSymbol.declarations.find(ts5.isTypeAliasDeclaration);
5254
5261
  }
5255
5262
  return void 0;
5256
5263
  }
5257
5264
  function analyzeMethod(method, checker) {
5258
- if (!ts3.isIdentifier(method.name)) {
5265
+ if (!ts5.isIdentifier(method.name)) {
5259
5266
  return null;
5260
5267
  }
5261
5268
  const name = method.name.text;
5262
5269
  const parameters = [];
5263
5270
  for (const param of method.parameters) {
5264
- if (ts3.isIdentifier(param.name)) {
5271
+ if (ts5.isIdentifier(param.name)) {
5265
5272
  const paramInfo = analyzeParameter(param, checker);
5266
5273
  parameters.push(paramInfo);
5267
5274
  }
@@ -5272,7 +5279,7 @@ function analyzeMethod(method, checker) {
5272
5279
  return { name, parameters, returnTypeNode, returnType };
5273
5280
  }
5274
5281
  function analyzeParameter(param, checker) {
5275
- const name = ts3.isIdentifier(param.name) ? param.name.text : "param";
5282
+ const name = ts5.isIdentifier(param.name) ? param.name.text : "param";
5276
5283
  const typeNode = param.type;
5277
5284
  const type = checker.getTypeAtLocation(param);
5278
5285
  const formSpecExportName = detectFormSpecReference(typeNode);
@@ -5281,15 +5288,15 @@ function analyzeParameter(param, checker) {
5281
5288
  }
5282
5289
  function detectFormSpecReference(typeNode) {
5283
5290
  if (!typeNode) return null;
5284
- if (!ts3.isTypeReferenceNode(typeNode)) return null;
5285
- const typeName = ts3.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts3.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
5291
+ if (!ts5.isTypeReferenceNode(typeNode)) return null;
5292
+ const typeName = ts5.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : ts5.isQualifiedName(typeNode.typeName) ? typeNode.typeName.right.text : null;
5286
5293
  if (typeName !== "InferSchema" && typeName !== "InferFormSchema") return null;
5287
5294
  const typeArg = typeNode.typeArguments?.[0];
5288
- if (!typeArg || !ts3.isTypeQueryNode(typeArg)) return null;
5289
- if (ts3.isIdentifier(typeArg.exprName)) {
5295
+ if (!typeArg || !ts5.isTypeQueryNode(typeArg)) return null;
5296
+ if (ts5.isIdentifier(typeArg.exprName)) {
5290
5297
  return typeArg.exprName.text;
5291
5298
  }
5292
- if (ts3.isQualifiedName(typeArg.exprName)) {
5299
+ if (ts5.isQualifiedName(typeArg.exprName)) {
5293
5300
  return typeArg.exprName.right.text;
5294
5301
  }
5295
5302
  return null;
@@ -5300,6 +5307,8 @@ var init_class_analyzer = __esm({
5300
5307
  "use strict";
5301
5308
  init_jsdoc_constraints();
5302
5309
  init_tsdoc_parser();
5310
+ init_resolve_custom_type();
5311
+ init_ts_type_utils();
5303
5312
  init_metadata();
5304
5313
  RESOLVING_TYPE_PLACEHOLDER = {
5305
5314
  kind: "object",
@@ -5311,7 +5320,7 @@ var init_class_analyzer = __esm({
5311
5320
  });
5312
5321
 
5313
5322
  // src/analyzer/program.ts
5314
- import * as ts4 from "typescript";
5323
+ import * as ts6 from "typescript";
5315
5324
  import * as path from "path";
5316
5325
  function createProgramContextFromProgram(program, filePath) {
5317
5326
  const absolutePath = path.resolve(filePath);
@@ -5328,23 +5337,23 @@ function createProgramContextFromProgram(program, filePath) {
5328
5337
  function createProgramContext(filePath, additionalFiles) {
5329
5338
  const absolutePath = path.resolve(filePath);
5330
5339
  const fileDir = path.dirname(absolutePath);
5331
- const configPath = ts4.findConfigFile(fileDir, ts4.sys.fileExists.bind(ts4.sys), "tsconfig.json");
5340
+ const configPath = ts6.findConfigFile(fileDir, ts6.sys.fileExists.bind(ts6.sys), "tsconfig.json");
5332
5341
  let compilerOptions;
5333
5342
  let fileNames;
5334
5343
  if (configPath) {
5335
- const configFile = ts4.readConfigFile(configPath, ts4.sys.readFile.bind(ts4.sys));
5344
+ const configFile = ts6.readConfigFile(configPath, ts6.sys.readFile.bind(ts6.sys));
5336
5345
  if (configFile.error) {
5337
5346
  throw new Error(
5338
- `Error reading tsconfig.json: ${ts4.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
5347
+ `Error reading tsconfig.json: ${ts6.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
5339
5348
  );
5340
5349
  }
5341
- const parsed = ts4.parseJsonConfigFileContent(
5350
+ const parsed = ts6.parseJsonConfigFileContent(
5342
5351
  configFile.config,
5343
- ts4.sys,
5352
+ ts6.sys,
5344
5353
  path.dirname(configPath)
5345
5354
  );
5346
5355
  if (parsed.errors.length > 0) {
5347
- const errorMessages = parsed.errors.map((e) => ts4.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
5356
+ const errorMessages = parsed.errors.map((e) => ts6.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n");
5348
5357
  throw new Error(`Error parsing tsconfig.json: ${errorMessages}`);
5349
5358
  }
5350
5359
  compilerOptions = parsed.options;
@@ -5352,9 +5361,9 @@ function createProgramContext(filePath, additionalFiles) {
5352
5361
  fileNames = [.../* @__PURE__ */ new Set([...parsed.fileNames, absolutePath, ...normalizedAdditional])];
5353
5362
  } else {
5354
5363
  compilerOptions = {
5355
- target: ts4.ScriptTarget.ES2022,
5356
- module: ts4.ModuleKind.NodeNext,
5357
- moduleResolution: ts4.ModuleResolutionKind.NodeNext,
5364
+ target: ts6.ScriptTarget.ES2022,
5365
+ module: ts6.ModuleKind.NodeNext,
5366
+ moduleResolution: ts6.ModuleResolutionKind.NodeNext,
5358
5367
  strict: true,
5359
5368
  skipLibCheck: true,
5360
5369
  declaration: true
@@ -5362,7 +5371,7 @@ function createProgramContext(filePath, additionalFiles) {
5362
5371
  const normalizedAdditional = (additionalFiles ?? []).map((f) => path.resolve(f));
5363
5372
  fileNames = [.../* @__PURE__ */ new Set([absolutePath, ...normalizedAdditional])];
5364
5373
  }
5365
- const program = ts4.createProgram(fileNames, compilerOptions);
5374
+ const program = ts6.createProgram(fileNames, compilerOptions);
5366
5375
  const sourceFile = program.getSourceFile(absolutePath);
5367
5376
  if (!sourceFile) {
5368
5377
  throw new Error(`Could not find source file: ${absolutePath}`);
@@ -5381,19 +5390,19 @@ function findNodeByName(sourceFile, name, predicate, getName) {
5381
5390
  result = node;
5382
5391
  return;
5383
5392
  }
5384
- ts4.forEachChild(node, visit);
5393
+ ts6.forEachChild(node, visit);
5385
5394
  }
5386
5395
  visit(sourceFile);
5387
5396
  return result;
5388
5397
  }
5389
5398
  function findClassByName(sourceFile, className) {
5390
- return findNodeByName(sourceFile, className, ts4.isClassDeclaration, (n) => n.name?.text);
5399
+ return findNodeByName(sourceFile, className, ts6.isClassDeclaration, (n) => n.name?.text);
5391
5400
  }
5392
5401
  function findInterfaceByName(sourceFile, interfaceName) {
5393
- return findNodeByName(sourceFile, interfaceName, ts4.isInterfaceDeclaration, (n) => n.name.text);
5402
+ return findNodeByName(sourceFile, interfaceName, ts6.isInterfaceDeclaration, (n) => n.name.text);
5394
5403
  }
5395
5404
  function findTypeAliasByName(sourceFile, aliasName) {
5396
- return findNodeByName(sourceFile, aliasName, ts4.isTypeAliasDeclaration, (n) => n.name.text);
5405
+ return findNodeByName(sourceFile, aliasName, ts6.isTypeAliasDeclaration, (n) => n.name.text);
5397
5406
  }
5398
5407
  function getResolvedObjectRootType(rootType, typeRegistry) {
5399
5408
  if (rootType.kind === "object") {
@@ -5433,22 +5442,22 @@ function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInf
5433
5442
  };
5434
5443
  }
5435
5444
  function containsTypeReferenceInObjectLikeAlias(typeNode) {
5436
- if (ts4.isParenthesizedTypeNode(typeNode)) {
5445
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
5437
5446
  return containsTypeReferenceInObjectLikeAlias(typeNode.type);
5438
5447
  }
5439
- if (ts4.isTypeReferenceNode(typeNode)) {
5448
+ if (ts6.isTypeReferenceNode(typeNode)) {
5440
5449
  return true;
5441
5450
  }
5442
- return ts4.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5451
+ return ts6.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
5443
5452
  }
5444
5453
  function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5445
- if (ts4.isParenthesizedTypeNode(typeNode)) {
5454
+ if (ts6.isParenthesizedTypeNode(typeNode)) {
5446
5455
  return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
5447
5456
  }
5448
- if (ts4.isTypeLiteralNode(typeNode)) {
5457
+ if (ts6.isTypeLiteralNode(typeNode)) {
5449
5458
  const propertyNames = [];
5450
5459
  for (const member of typeNode.members) {
5451
- if (!ts4.isPropertySignature(member)) {
5460
+ if (!ts6.isPropertySignature(member)) {
5452
5461
  continue;
5453
5462
  }
5454
5463
  const propertyName = getAnalyzableObjectLikePropertyName(member.name);
@@ -5458,13 +5467,13 @@ function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
5458
5467
  }
5459
5468
  return propertyNames;
5460
5469
  }
5461
- if (ts4.isTypeReferenceNode(typeNode)) {
5470
+ if (ts6.isTypeReferenceNode(typeNode)) {
5462
5471
  return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
5463
5472
  }
5464
5473
  return null;
5465
5474
  }
5466
5475
  function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
5467
- if (!ts4.isIntersectionTypeNode(typeNode)) {
5476
+ if (!ts6.isIntersectionTypeNode(typeNode)) {
5468
5477
  return [];
5469
5478
  }
5470
5479
  const seen = /* @__PURE__ */ new Set();
@@ -5671,7 +5680,7 @@ var init_program = __esm({
5671
5680
  });
5672
5681
 
5673
5682
  // src/extensions/symbol-registry.ts
5674
- import * as ts5 from "typescript";
5683
+ import * as ts7 from "typescript";
5675
5684
  import * as path2 from "path";
5676
5685
  function buildSymbolMapFromConfig(configPath, program, checker, extensionRegistry) {
5677
5686
  const symbolMap = /* @__PURE__ */ new Map();
@@ -5681,10 +5690,10 @@ function buildSymbolMapFromConfig(configPath, program, checker, extensionRegistr
5681
5690
  return symbolMap;
5682
5691
  }
5683
5692
  function visit(node) {
5684
- if (ts5.isCallExpression(node) && isDefineCustomTypeCall(node, checker)) {
5693
+ if (ts7.isCallExpression(node) && isDefineCustomTypeCall(node, checker)) {
5685
5694
  processDefineCustomTypeCall(node);
5686
5695
  }
5687
- ts5.forEachChild(node, visit);
5696
+ ts7.forEachChild(node, visit);
5688
5697
  }
5689
5698
  function processDefineCustomTypeCall(call) {
5690
5699
  const typeArgNode = call.typeArguments?.[0];
@@ -5692,7 +5701,7 @@ function buildSymbolMapFromConfig(configPath, program, checker, extensionRegistr
5692
5701
  return;
5693
5702
  }
5694
5703
  const resolvedType = checker.getTypeFromTypeNode(typeArgNode);
5695
- const canonical = resolveCanonicalSymbol2(resolvedType, checker);
5704
+ const canonical = resolveCanonicalSymbol(resolvedType, checker);
5696
5705
  if (canonical === void 0) {
5697
5706
  return;
5698
5707
  }
@@ -5721,7 +5730,7 @@ function isDefineCustomTypeCall(node, checker) {
5721
5730
  if (node.typeArguments === void 0 || node.typeArguments.length === 0) return false;
5722
5731
  const callSymbol = checker.getSymbolAtLocation(node.expression);
5723
5732
  if (callSymbol !== void 0) {
5724
- const resolved = callSymbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
5733
+ const resolved = callSymbol.flags & ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
5725
5734
  const decl = resolved.declarations?.[0];
5726
5735
  if (decl !== void 0) {
5727
5736
  const sourceFile = decl.getSourceFile().fileName.replace(/\\/g, "/");
@@ -5729,29 +5738,24 @@ function isDefineCustomTypeCall(node, checker) {
5729
5738
  (sourceFile.includes("@formspec/core") || sourceFile.includes("/packages/core/"));
5730
5739
  }
5731
5740
  }
5732
- return ts5.isIdentifier(node.expression) && node.expression.text === "defineCustomType";
5733
- }
5734
- function resolveCanonicalSymbol2(type, checker) {
5735
- const raw = type.aliasSymbol ?? type.getSymbol();
5736
- if (raw === void 0) return void 0;
5737
- return raw.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(raw) : raw;
5741
+ return ts7.isIdentifier(node.expression) && node.expression.text === "defineCustomType";
5738
5742
  }
5739
5743
  function extractTypeNameFromCallArg(call) {
5740
5744
  const arg = call.arguments[0];
5741
- if (arg === void 0 || !ts5.isObjectLiteralExpression(arg)) {
5745
+ if (arg === void 0 || !ts7.isObjectLiteralExpression(arg)) {
5742
5746
  return null;
5743
5747
  }
5744
5748
  const typeNameProp = arg.properties.find(
5745
- (p) => ts5.isPropertyAssignment(p) && ts5.isIdentifier(p.name) && p.name.text === "typeName"
5749
+ (p) => ts7.isPropertyAssignment(p) && ts7.isIdentifier(p.name) && p.name.text === "typeName"
5746
5750
  );
5747
- if (typeNameProp === void 0 || !ts5.isStringLiteral(typeNameProp.initializer)) {
5751
+ if (typeNameProp === void 0 || !ts7.isStringLiteral(typeNameProp.initializer)) {
5748
5752
  return null;
5749
5753
  }
5750
5754
  return typeNameProp.initializer.text;
5751
5755
  }
5752
5756
  function extractEnclosingExtensionId(call, checker) {
5753
- for (let node = call.parent; !ts5.isSourceFile(node); node = node.parent) {
5754
- if (ts5.isCallExpression(node) && isDefineExtensionCall(node, checker)) {
5757
+ for (let node = call.parent; !ts7.isSourceFile(node); node = node.parent) {
5758
+ if (ts7.isCallExpression(node) && isDefineExtensionCall(node, checker)) {
5755
5759
  return extractExtensionIdFromCallArg(node);
5756
5760
  }
5757
5761
  }
@@ -5760,24 +5764,24 @@ function extractEnclosingExtensionId(call, checker) {
5760
5764
  function isDefineExtensionCall(node, checker) {
5761
5765
  const callSymbol = checker.getSymbolAtLocation(node.expression);
5762
5766
  if (callSymbol !== void 0) {
5763
- const resolved = callSymbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
5767
+ const resolved = callSymbol.flags & ts7.SymbolFlags.Alias ? checker.getAliasedSymbol(callSymbol) : callSymbol;
5764
5768
  const decl = resolved.declarations?.[0];
5765
5769
  if (decl !== void 0) {
5766
5770
  const sourceFile = decl.getSourceFile().fileName.replace(/\\/g, "/");
5767
5771
  return resolved.name === "defineExtension" && (sourceFile.includes("@formspec/core") || sourceFile.includes("/packages/core/"));
5768
5772
  }
5769
5773
  }
5770
- return ts5.isIdentifier(node.expression) && node.expression.text === "defineExtension";
5774
+ return ts7.isIdentifier(node.expression) && node.expression.text === "defineExtension";
5771
5775
  }
5772
5776
  function extractExtensionIdFromCallArg(call) {
5773
5777
  const arg = call.arguments[0];
5774
- if (arg === void 0 || !ts5.isObjectLiteralExpression(arg)) {
5778
+ if (arg === void 0 || !ts7.isObjectLiteralExpression(arg)) {
5775
5779
  return null;
5776
5780
  }
5777
5781
  const prop = arg.properties.find(
5778
- (p) => ts5.isPropertyAssignment(p) && ts5.isIdentifier(p.name) && p.name.text === "extensionId"
5782
+ (p) => ts7.isPropertyAssignment(p) && ts7.isIdentifier(p.name) && p.name.text === "extensionId"
5779
5783
  );
5780
- if (prop === void 0 || !ts5.isStringLiteral(prop.initializer)) {
5784
+ if (prop === void 0 || !ts7.isStringLiteral(prop.initializer)) {
5781
5785
  return null;
5782
5786
  }
5783
5787
  return prop.initializer.text;
@@ -5798,6 +5802,7 @@ function findRegistrationByTypeName(registry, typeName) {
5798
5802
  var init_symbol_registry = __esm({
5799
5803
  "src/extensions/symbol-registry.ts"() {
5800
5804
  "use strict";
5805
+ init_ts_type_utils();
5801
5806
  }
5802
5807
  });
5803
5808
 
@@ -5888,7 +5893,7 @@ var init_validate = __esm({
5888
5893
  });
5889
5894
 
5890
5895
  // src/generators/class-schema.ts
5891
- import * as ts6 from "typescript";
5896
+ import * as ts8 from "typescript";
5892
5897
  function generateClassSchemas(analysis, source, options) {
5893
5898
  const result = generateClassSchemasDetailed(analysis, source, options);
5894
5899
  if (!result.ok || result.jsonSchema === void 0 || result.uiSchema === void 0) {
@@ -6058,7 +6063,7 @@ function generateSchemasBatch(options) {
6058
6063
  return options.targets.map((target) => {
6059
6064
  let ctx;
6060
6065
  try {
6061
- const cacheKey = ts6.sys.useCaseSensitiveFileNames ? target.filePath : target.filePath.toLowerCase();
6066
+ const cacheKey = ts8.sys.useCaseSensitiveFileNames ? target.filePath : target.filePath.toLowerCase();
6062
6067
  const cachedContext = contextCache.get(cacheKey);
6063
6068
  if (cachedContext === void 0) {
6064
6069
  const additionalFiles = options.configPath !== void 0 ? [options.configPath] : void 0;
@@ -6227,7 +6232,7 @@ var init_class_schema = __esm({
6227
6232
  });
6228
6233
 
6229
6234
  // src/static-build.ts
6230
- import * as ts7 from "typescript";
6235
+ import * as ts9 from "typescript";
6231
6236
  function toStaticBuildContext(context) {
6232
6237
  return context;
6233
6238
  }
@@ -6242,7 +6247,7 @@ function getModuleSymbol(context) {
6242
6247
  return context.checker.getSymbolAtLocation(context.sourceFile) ?? sourceFileWithSymbol.symbol;
6243
6248
  }
6244
6249
  function isSchemaSourceDeclaration(declaration) {
6245
- return ts7.isClassDeclaration(declaration) || ts7.isInterfaceDeclaration(declaration) || ts7.isTypeAliasDeclaration(declaration);
6250
+ return ts9.isClassDeclaration(declaration) || ts9.isInterfaceDeclaration(declaration) || ts9.isTypeAliasDeclaration(declaration);
6246
6251
  }
6247
6252
  function resolveModuleExport(context, exportName = "default") {
6248
6253
  const moduleSymbol = getModuleSymbol(context);
@@ -6253,7 +6258,7 @@ function resolveModuleExport(context, exportName = "default") {
6253
6258
  if (exportSymbol === null) {
6254
6259
  return null;
6255
6260
  }
6256
- return exportSymbol.flags & ts7.SymbolFlags.Alias ? context.checker.getAliasedSymbol(exportSymbol) : exportSymbol;
6261
+ return exportSymbol.flags & ts9.SymbolFlags.Alias ? context.checker.getAliasedSymbol(exportSymbol) : exportSymbol;
6257
6262
  }
6258
6263
  function resolveModuleExportDeclaration(context, exportName = "default") {
6259
6264
  return resolveModuleExport(context, exportName)?.declarations?.find(isSchemaSourceDeclaration) ?? null;
@@ -6266,7 +6271,7 @@ var init_static_build = __esm({
6266
6271
  });
6267
6272
 
6268
6273
  // src/generators/discovered-schema.ts
6269
- import * as ts8 from "typescript";
6274
+ import * as ts10 from "typescript";
6270
6275
  import { analyzeMetadataForNodeWithChecker as analyzeMetadataForNodeWithChecker2 } from "@formspec/analysis/internal";
6271
6276
  import { IR_VERSION as IR_VERSION3 } from "@formspec/core/internals";
6272
6277
  function toDiscoveredTypeSchemas(result, resolvedMetadata) {
@@ -6276,17 +6281,17 @@ function toDiscoveredTypeSchemas(result, resolvedMetadata) {
6276
6281
  };
6277
6282
  }
6278
6283
  function isNamedTypeDeclaration(declaration) {
6279
- return ts8.isClassDeclaration(declaration) || ts8.isInterfaceDeclaration(declaration) || ts8.isTypeAliasDeclaration(declaration);
6284
+ return ts10.isClassDeclaration(declaration) || ts10.isInterfaceDeclaration(declaration) || ts10.isTypeAliasDeclaration(declaration);
6280
6285
  }
6281
6286
  function hasConcreteTypeArguments(type, checker) {
6282
6287
  if ("aliasTypeArguments" in type && Array.isArray(type.aliasTypeArguments) && type.aliasTypeArguments.length > 0) {
6283
6288
  return true;
6284
6289
  }
6285
- if ((type.flags & ts8.TypeFlags.Object) === 0) {
6290
+ if ((type.flags & ts10.TypeFlags.Object) === 0) {
6286
6291
  return false;
6287
6292
  }
6288
6293
  const objectType = type;
6289
- if ((objectType.objectFlags & ts8.ObjectFlags.Reference) === 0) {
6294
+ if ((objectType.objectFlags & ts10.ObjectFlags.Reference) === 0) {
6290
6295
  return false;
6291
6296
  }
6292
6297
  return checker.getTypeArguments(objectType).length > 0;
@@ -6299,13 +6304,13 @@ function getNamedTypeDeclaration2(type) {
6299
6304
  return declaration;
6300
6305
  }
6301
6306
  }
6302
- const aliasDeclaration = type.aliasSymbol?.declarations?.find(ts8.isTypeAliasDeclaration);
6307
+ const aliasDeclaration = type.aliasSymbol?.declarations?.find(ts10.isTypeAliasDeclaration);
6303
6308
  return aliasDeclaration;
6304
6309
  }
6305
6310
  function getFallbackName(sourceNode, fallback = "AnonymousType") {
6306
6311
  if (sourceNode !== void 0 && "name" in sourceNode) {
6307
6312
  const namedNode = sourceNode;
6308
- if (namedNode.name !== void 0 && ts8.isIdentifier(namedNode.name)) {
6313
+ if (namedNode.name !== void 0 && ts10.isIdentifier(namedNode.name)) {
6309
6314
  return namedNode.name.text;
6310
6315
  }
6311
6316
  }
@@ -6527,7 +6532,7 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
6527
6532
  function generateSchemasFromDeclaration(options) {
6528
6533
  const filePath = options.declaration.getSourceFile().fileName;
6529
6534
  const resolved = resolveStaticOptions(options);
6530
- if (ts8.isClassDeclaration(options.declaration)) {
6535
+ if (ts10.isClassDeclaration(options.declaration)) {
6531
6536
  return generateSchemasFromAnalysis(
6532
6537
  analyzeClassToIR(
6533
6538
  options.declaration,
@@ -6541,7 +6546,7 @@ function generateSchemasFromDeclaration(options) {
6541
6546
  resolved
6542
6547
  );
6543
6548
  }
6544
- if (ts8.isInterfaceDeclaration(options.declaration)) {
6549
+ if (ts10.isInterfaceDeclaration(options.declaration)) {
6545
6550
  return generateSchemasFromAnalysis(
6546
6551
  analyzeInterfaceToIR(
6547
6552
  options.declaration,
@@ -6555,7 +6560,7 @@ function generateSchemasFromDeclaration(options) {
6555
6560
  resolved
6556
6561
  );
6557
6562
  }
6558
- if (ts8.isTypeAliasDeclaration(options.declaration)) {
6563
+ if (ts10.isTypeAliasDeclaration(options.declaration)) {
6559
6564
  const analyzedAlias = analyzeTypeAliasToIR(
6560
6565
  options.declaration,
6561
6566
  options.context.checker,
@@ -6614,7 +6619,7 @@ function generateSchemasFromReturnType(options) {
6614
6619
  const returnType = signature !== void 0 ? options.context.checker.getReturnTypeOfSignature(signature) : options.context.checker.getTypeAtLocation(options.declaration);
6615
6620
  const type = unwrapPromiseType(options.context.checker, returnType);
6616
6621
  const sourceNode = type !== returnType ? unwrapPromiseTypeNode(options.declaration.type) ?? options.declaration.type ?? options.declaration : options.declaration.type ?? options.declaration;
6617
- const fallbackName = options.declaration.name !== void 0 && ts8.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
6622
+ const fallbackName = options.declaration.name !== void 0 && ts10.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
6618
6623
  return generateSchemasFromResolvedType({
6619
6624
  ...options,
6620
6625
  type,
@@ -6661,14 +6666,14 @@ function unwrapPromiseTypeNode(typeNode) {
6661
6666
  if (typeNode === void 0) {
6662
6667
  return void 0;
6663
6668
  }
6664
- if (ts8.isParenthesizedTypeNode(typeNode)) {
6669
+ if (ts10.isParenthesizedTypeNode(typeNode)) {
6665
6670
  const unwrapped = unwrapPromiseTypeNode(typeNode.type);
6666
6671
  return unwrapped ?? typeNode;
6667
6672
  }
6668
6673
  return isPromiseTypeReferenceNode(typeNode) ? typeNode.typeArguments[0] : typeNode;
6669
6674
  }
6670
6675
  function isPromiseTypeReferenceNode(typeNode) {
6671
- return ts8.isTypeReferenceNode(typeNode) && ts8.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
6676
+ return ts10.isTypeReferenceNode(typeNode) && ts10.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
6672
6677
  }
6673
6678
  var init_discovered_schema = __esm({
6674
6679
  "src/generators/discovered-schema.ts"() {