Skip to content

Fix/types preserve ts semantics#33

Closed
jay7-tech wants to merge 3 commits intowebpack:mainfrom
jay7-tech:fix/types-preserve-ts-semantics
Closed

Fix/types preserve ts semantics#33
jay7-tech wants to merge 3 commits intowebpack:mainfrom
jay7-tech:fix/types-preserve-ts-semantics

Conversation

@jay7-tech
Copy link

This PR fixes #30 by correcting how

resolve()
in
plugins/theme/partials/types.mjs
handles the TypeDoc AST. The previous implementation collapsed TypeScript semantics (e.g., stripping generic arguments, converting tuples to unions).

The updated resolver properly maps the AST to preserve syntax:

Generics: Preserves typeArguments.
Tuples: Renders bracket notation [A, B] instead of unions.
Conditionals: Preserves the T extends U ? X : Y structure.
Reflections: Attempts call-signature and property-bag rendering.
Edge cases: Adds explicit handling for predicate, rest, named-tuple-member, and query.
Additionally, this adds a structural guard to

generate-md.mjs
to warn developers if the sibling ./webpack checkout is missing, avoiding a cryptic stack trace.

What kind of change does this PR introduce?
Fix

Did you add tests for your changes?
N/A - The markdown generation logic currently lacks an automated test suite. Output was manually verified against webpack.d.ts to ensure complex types (like fileTimestamps and Record<K,V>) render correctly.

Does this PR introduce a breaking change?
No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?
N/A

Use of AI

I used an LLM strictly as a search tool to reference specific TypeDoc AST property names for edge cases and better understand flows, as a huge spectrum of the project, . The actual AST traversal logic, implementation, and type mapping were written manually..

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 22, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, doc-kit only supports types and generics.

Most of these changes will not be supported by doc-kit, and thus cannot land.

However, either:

  • doc-kit support for these types should be added
  • rewrite these types as generics

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avivkeller
Thanks for the context on doc-kit...... That makes sense.

I just pushed an update following your advice:

Stripped out all the unsupported AST types to keep things safe.
Re, wrote tuples into Tuple<...> generics so doc-kit can natively render them.
Reverted the

generate md.mjs
change entirely to keep the PR focused.

Let me know if this version is good to go for the pipeline!

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.

Custom type renderer is losing TypeScript semantics in generated docs

2 participants