generator icon indicating copy to clipboard operation
generator copied to clipboard

Discuss duplication of JSDocs across components & potential migration to TypeScript of `@asyncapi/generator-components`

Open Adi-204 opened this issue 3 months ago • 1 comments

  1. JSDoc Duplication: While working with different components, we have noticed that we’re duplicating JSDocs in multiple places. For example, when using the MethodGenerator across other components, the documentation is repeated instead of being shared or derived.

  2. Moving to TypeScript could reduce duplication by enforcing strong typing and auto-generating documentation from type definitions. It would also improve developer experience, ensure better maintainability, and reduce bugs from untyped code.

Adi-204 avatar Sep 22 '25 18:09 Adi-204

While working on issue #1656 to generate the API.md, I noticed a lot of duplicated content, which made it difficult to navigate between components.

That’s why I introduced Handlebars templates to avoid repeating typedefs.

In generator-components, I found multiple occurrences of the same typedef, for example:

/**

  • @typedef {'python' | 'javascript' | 'dart'} SupportedLanguage
  • Supported programming languages for WebSocket connection method generation. */

This exact block appears in several files like HandleMessage.js, connect.js, and onError.js.

There is also a requirement to migrate the components to TypeScript. If we move to TypeScript, generating API.md becomes straightforward, and we won’t need Handlebars templates for that purpose anymore.

batchu5 avatar Nov 23 '25 18:11 batchu5