Add JSDoc @export
tag
#60831
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Domain: JSDoc
Relates to JSDoc parsing and type generation
Suggestion
An idea for TypeScript
🔍 Search Terms
jsdoc @export
✅ Viability Checklist
⭐ Suggestion
TypeScript 5.5 added the
@import
JSDoc tag which can be used for type-only imports. It would be useful to add an analogous@export
tag for type-only exports.📃 Motivating Example
Let’s say you maintain a library that contains the following file:
Maybe you want to expose these types in the main entry point. You can now do this with the JSDoc
@export
tag. It works the same as type-only exports in TypeScript files.💻 Use Cases
This is useful to have full control over exports in a library. Also this is just parity between JSDoc based types and TypeScript files.
I can think of 3 workarounds, all of which are not great.
Define a new type in the index file using
@typedef
Pros:
Cons:
In addition to
index.js
, create a TypeScript file, e.g.exports.ts
. Then inexports.ts
write something along the lines of:and in
package.json
, write something like:Pros:
Cons:
index.js
need to be synced toexports.ts
manually.exports.ts
is the main entry, whereas in reality it’sindex.js
Manually write the declaration file.
Pros:
Cons:
The text was updated successfully, but these errors were encountered: