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

Generation strategy : what is documented vs what is actually exported #100

Open
alxroyer opened this issue Sep 2, 2019 · 2 comments
Open

Comments

@alxroyer
Copy link
Contributor

alxroyer commented Sep 2, 2019

While working on PR#98 for 'export default' support, I wondered what would be the best strategy:

  • generate declarations for everything documented with jsdoc in the input source code?
  • or generate declarations from what is actually exported by the module?

My feeling is that it would be better to have tsd-jsdoc be based on what is exported:

  • it would fix undesired effects as noticed in issue#99,
  • it would avoid exposing symbols in the types.d.ts generated file that the js module does not actually export.
  • it could avoid requiring an explicite jsdoc comment on module.exports for the following common export pattern:
exports = module.exports = myExport

issue#96 / PR#98 would be a prerequisite for this kind of evolution.

@englercj
Copy link
Owner

englercj commented Sep 2, 2019

I'd also prefer that, in previous versions of jsdoc it hasn't been very good at getting "what is exported" correct.

We'd also need to extrapolate from what is exported, other things that should be exported.

For example, consider a function that takes an interface as an arg. The function will be marked as exported, but the interface likely won't be. In the TS definitions, both should be exported.

I'd love to rework the logic to work this way instead, and if you are up for it I'm happy to accept a PR.

@alxroyer
Copy link
Contributor Author

alxroyer commented Sep 3, 2019

Sure, I'll try to implement such a backward walk from exports.

Actually, assuming this strategy could help with the handling of exports = module.exports = myExport patterns for issue#96, so I may give it a try in PR#98.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants