Skip to content

fix(schema | api-ref): improve variable declaration extraction, internal type-ref resolution, module indexing, and includeFiles glob support#10043

Merged
luvkapur merged 15 commits intomasterfrom
fix-api-ref-module-exports-param-name
Nov 14, 2025
Merged

fix(schema | api-ref): improve variable declaration extraction, internal type-ref resolution, module indexing, and includeFiles glob support#10043
luvkapur merged 15 commits intomasterfrom
fix-api-ref-module-exports-param-name

Conversation

@luvkapur
Copy link
Member

@luvkapur luvkapur commented Oct 16, 2025

This PR improves schema extraction accuracy, module indexing, and internal module resolution across several core parts 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 + recursive type-ref closure

Major overhaul of how internal (non-exported) modules are discovered, walked, and materialized.

Key changes:

  • Introduces context.buildTopLevelNameIndex() to efficiently map names → top-level declarations.

  • Internal modules now derive solely from identifiers not exported via the main entry point.

  • Avoids any reprocessing of exported symbols handled by ExportDeclarationTransformer.

  • Adds recursive closure over internal type references inside the same file:

    • collectSameFileInternalTypeRefs() walks the generated schema graph and finds all internal TypeRefSchema nodes belonging to the same file.
    • computeInternalModules() now performs a BFS:
      • root internal names (non-exported)
      • ALL internal names they reference transitively

Result: internal types are now fully resolved, transitive, and correctly represented.

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
@luvkapur luvkapur changed the title fix(schema | api-ref): improve variable declaration extraction, internal module indexing, and includeFiles glob resolution fix(schema | api-ref): improve variable declaration extraction, internal type-ref resolution, module indexing, and includeFiles glob support Nov 13, 2025
@luvkapur luvkapur merged commit aa01a89 into master Nov 14, 2025
11 checks passed
@luvkapur luvkapur deleted the fix-api-ref-module-exports-param-name branch November 14, 2025 17:04
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

Comments