docs-devkit
docs-devkit copied to clipboard
fix: properly handle promise generics
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
DocsParserto correctly extract the base type name before generics (e.g., strips<T>fromType<T>) when splitting namespaces, preventing issues with generic type names. - Modified
GlobalTemplateWriterto parenthesize function types within union types, preventing TypeScript syntax errors (e.g., outputs(a: string) => void | numberas((a: string) => void) | number). - Enhanced generic type support in
GlobalTemplateWriterby adding explicit handling forPromise<T>types, ensuring standard TypeScript generic syntax is used for Promises.