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

Infer types from JSDoc comments #5670

Open
kripod opened this issue Jan 16, 2018 · 6 comments
Open

Infer types from JSDoc comments #5670

kripod opened this issue Jan 16, 2018 · 6 comments

Comments

@kripod
Copy link
Contributor

kripod commented Jan 16, 2018

I think it would be nice to infer types from JSDoc comments in Flow-enabled files (or add an option to do so). Developers would not have to rely on transpilers or type-only comments to use Flow. The current type notation should still be preferred if present.

@jeffbski
Copy link

I agree. I learned yesterday that TypeScript has recently added support for this. It can infer the types and check against from the jsdoc comments. I hope flow can add this so we can use flow instead. It makes sense since you normally want more info along with the type like a comment explaining use. jsdoc supports this and if flow can just use the types from here it wouldnt require diplication and existing jsdoc'd cod would just work.

There is a tool that regenerates flow files as preprocessor cli app https://github.com/Kegsay/flow-jsdoc but it would be nice to pull this into the pipeline so not hitting disk with intermediate files.

@moqmar
Copy link

moqmar commented Oct 16, 2018

This would be awesome for another reason: many features of Flow could be used for projects without requiring a transpiler, as types could be defined in a comment.

@ArmorDarks
Copy link

That would be a great thing. Otherwise, you're forced to duplicate type declarations anyway, since for most cases function argument need to have proper descriptions too.

@jakesylvestre
Copy link

jakesylvestre commented Oct 19, 2018

This was discussed pretty heavily in #3, #43 #555 and is of particular interest as I've been looking at adding flow support to adonis/discussion#65. The biggest issue with adding flow to the core is the need to use babel, but this would negate that. It is true, as @mroch pointed out in #555 that you can use comment type annotations, but IMO they're just not clean. This would also go nicely with documentation generation (#352) since this would make moving styles quite easy.

@jeffbski I've looked pretty heavily at Kegsay/flow-jsdoc and unfortunately it's just not being updated. It looks like the last update was over a year ago in November of 2017 kegsay/flow-jsdoc#20. It's also lacking some pretty important functionality like @static (discussed in Kegsay/flow-jsdoc/issues#4 ) and @typedef (discussed in kegsay/flow-jsdoc#22 ).

@Ryuno-Ki
Copy link

Ryuno-Ki commented Nov 7, 2018

Hi @jakesyl,
sounds like we should support @kegsay with PRs then?
From what I've seen, some changes should be straightforward.
I mean, the code traverses the AST (using esprima) and manipulates it.
Doesn't sound too hard for adding some things.

This way you would scratching an itch :-D

@kegsay
Copy link

kegsay commented Nov 8, 2018

I'm more than happy to hand ownership of flow-jsdoc to someone who is interested in actively maintaining it. I've fully moved over to Typescript at this point and so have little reason to actively develop this and scratch my own itch. I'll happily look at any PRs.

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

9 participants