Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate types from JSDoc #47

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

mikaelkaron
Copy link
Contributor

@mikaelkaron mikaelkaron commented Jul 26, 2022

Instead of maintaining separate @types/* it would be nice to have types generated and shipped with the package.

This PR adds support for generating *.d.ts from JSDoc style comments.

@mikaelkaron mikaelkaron marked this pull request as draft July 26, 2022 16:53
@mikaelkaron
Copy link
Contributor Author

@fergiemcdowall Is this something you'd be interested in?

At the moment I'm extracting what I can from the docs and code comments where I can find them, but long-term this should be a lot more maintainable (and possibly testable) than a separate @types/* package.

@fergiemcdowall
Copy link
Owner

Yes absolutely 👍👍 (I see that level now includes Typescript definitions)

@mikaelkaron
Copy link
Contributor Author

For some reason I'm not able to output all the types to:

  • one file in dist
  • separate types dir

So for now I'm just using the default (that works) of outputting the *.d.ts file next to the source.

@fergiemcdowall
Copy link
Owner

I havent really been using Typescript lately- what is the best way to verify that the Types are correct? Say we get a PR that breaks a type- how do we run a test that picks that up?

@mikaelkaron
Copy link
Contributor Author

I've completed a first round of types generated from JSDoc now and it would be awesome if someone can help me review that the types I've documented/generated are correct. Generated types are not as good as manually created types, for instance:

  • Generics are not that easy to get right
  • Not able to generate interface - it's always a type
  • Parameter documentation is not extracted to the generated type
  • You are supposed to be able to generate types to a specific types folder and even a separate index.d.ts but I have not been able to do that yet.

It's possible that's due to me not understanding how to do that - if someone knows how to address the above please go for it ;)

I havent really been using Typescript lately- what is the best way to verify that the Types are correct? Say we get a PR that breaks a type- how do we run a test that picks that up?

I think the best we can do is to add tsd tests.

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.

None yet

2 participants