Skip to content

Conversation

hansemannn
Copy link
Contributor

This pull request improves the TypeScript code generation in the documentation generator by enhancing type handling, especially for generics and union types. The changes ensure that generated TypeScript code is more accurate and syntactically correct, particularly when dealing with complex types like generics, union types involving functions, and Promises.

Type handling improvements:

  • Updated DocsParser to correctly extract the base type name before generics (e.g., strips <T> from Type<T>) when splitting namespaces, preventing issues with generic type names.
  • Modified GlobalTemplateWriter to parenthesize function types within union types, preventing TypeScript syntax errors (e.g., outputs (a: string) => void | number as ((a: string) => void) | number).
  • Enhanced generic type support in GlobalTemplateWriter by adding explicit handling for Promise<T> types, ensuring standard TypeScript generic syntax is used for Promises.

@hansemannn hansemannn requested a review from cb1kenobi August 19, 2025 08:26
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