Omit JSDoc type directives when emitting type declarations with documentation #61664
Open
6 tasks done
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
π Search Terms
"omit typedef", "exclude typedef"
β Viability Checklist
β Suggestion
When emitting type declarations from JavaScript sources, the type is already defined in the TypeScript syntax, so there's no need to copy over any
@type
,@typedef
, or@template
.Types can also be stripped out of
@param
and@returns
directives.This could be taken further, by deleting JSDoc strings altogether if after stripped the types, they become empty.
π Motivating Example
For example, I have the following files:
css-select-adapter.js
tsconfig.json
The emitted type declaration is:
But the types defined in the JSDoc become unnecessary, it could just be:
This could even be taken further, by removing the
@param
and@returns
directives if all of them have no value, and removing the JSDoc outright if after removing empty directives the JSDoc becomes empty:π» Use Cases
In SVGO, we emit type declarations from our JSDocs. However, the type declarations can be quite noisy. It would be valuable if the output was tidied up:
We currently do not do any workarounds. We just publish the additional content to npm.
The text was updated successfully, but these errors were encountered: