I've been reading some issues on github and projects built on top of Flow for creating 'a bridge' between Flow and JSDoc or for simply generating JSDoc from Flow types annotation.
None of them answered this "simple" need I have:
Q: How to include Flow types into JSDoc?
I don't want to get rid of JSDoc comment blocks because they are not only meant for type checking but also for documentation and explaining the code to others or your future self.
What I want is this:
// @flow
// This file should be parsed by flow
// 1) Use all the advantages of flow
type MyObject = {
foo: number,
bar: boolean,
baz: string,
};
// later..
// 2) Comment AND annotate FLOW TYPE using JSDoc, not the Flow syntax
/**
* Make super complex thing
* @param {MyObject} val an object of type MyObject
* @returns {String} an interesting value
*/
function superComplexThingy(val) {
return val.baz
}
To summarise, I'd like to:
Is this possible? How?
Super late response, but this isn't something that's supported by Flow, and it likely will not be supported. If you want to write your own transpiler to convert some jsdoc comments to Flow types, you might be able to do it, but it would take a lot of work.
Some others have attempted work on this sort of thing, but it doesn't seem too active: https://github.com/Kegsay/flow-jsdoc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With