Skip to content

Conversation

@luvkapur
Copy link
Member

@luvkapur luvkapur commented Oct 16, 2025

This PR improves schema extraction accuracy and module indexing across several key areas of the API reference pipeline.

1. VariableDeclaration and ObjectLiteral handling

Fixes incorrect schema extraction for VariableDeclaration nodes initialized with object literals that contain identifier references.

Previously:

  • Such cases often produced UnImplementedSchema or inlined FunctionLikeSchema nodes due to QuickInfo-based heuristics misclassifying object literals as arrow functions.

Now:

  • VariableDeclarationTransformer explicitly detects ObjectLiteralExpression initializers and calls computeSchema() to construct accurate nested schemas.
  • ObjectLiteralExpressionTransformer resolves previously unhandled UnImplementedSchema values by inspecting property initializers:
  • Identifier initializers → resolved via getTypeRef() / getTypeRefForExternalNode() to produce proper TypeRefSchemas.
  • Non-identifier initializers → fallback to resolveType() using parsed QuickInfo.
  • SchemaExtractorContext now prioritizes object-literal detection in unknownExactType() before function heuristics, preventing false positives for FunctionLikeSchema.
  • Hardened regex for createFunctionSchema() (^\s*([^)]+)\s*(?:=>|:)\s*(.+)$) to prevent over-matching and ensure stable parsing of function signatures.

2. Internal module extraction overhaul

Refactors how internal (non-exported) modules are detected and materialized:

  • Introduces context.buildTopLevelNameIndex() to index top-level named declarations efficiently.
  • Internal modules are now built exclusively from identifiers not exported in the main module.
  • Avoids reprocessing exported nodes already captured by ExportDeclarationTransformer.
  • Significantly improves accuracy of internal symbol resolution without duplicate schema computation.

3. includeFiles support for explicit internal parsing

Adds the ability for consumers to explicitly include additional files for full schema extraction

Behavior:

  • includeFiles paths (or globs) are fully parsed and merged into internals of the APISchema.

@luvkapur luvkapur changed the title fix(schema | api-ref): variable declaration + object literal handling for component references fix(schema | api-ref): improve variable declaration extraction, internal module indexing, and includeFiles glob resolution Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants