将流类型包括到JSDoc中 [英] Include Flow Types into JSDoc

查看:77
本文介绍了将流类型包括到JSDoc中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在github和问题 https://github.com/Kegsay/flow-jsdoc"rel =" nofollow noreferrer>项目建立在Flow之上,用于在Flow和JSDoc之间建立桥梁"或仅从Flow类型注释中生成JSDoc

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.

他们都没有回答我有这个简单"的需求:
问:如何将Flow类型包含在JSDoc中?

None of them answered this "simple" need I have:
Q: How to include Flow types into JSDoc?

我不想摆脱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.

这是我想要的:

// @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  
}

总结一下,我想:

  1. 利用流的所有优点(如上面的类型定义)
  2. 使用JSDoc而不是Flow语法注释并注释流类型

这可能吗?怎么样?

推荐答案

超级迟到的响应,但这不是Flow所支持的,并且可能不受支持.如果您想编写自己的转译器以将一些jsdoc注释转换为Flow类型,则可以做到这一点,但这将需要大量工作.

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.

其他一些人已经尝试了这种事情,但似乎不太活跃: https ://github.com/Kegsay/flow-jsdoc

Some others have attempted work on this sort of thing, but it doesn't seem too active: https://github.com/Kegsay/flow-jsdoc

这篇关于将流类型包括到JSDoc中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆