【问题标题】:Is custom property documentation in tsx files possible?tsx 文件中的自定义属性文档是否可能?
【发布时间】:2017-12-10 22:57:03
【问题描述】:

类似于当我记录这样的函数时 ide 如何帮助描述。

/**
 * My Test fn
 * @param a - some description here
 */
function Test(a) {}

我希望 ide 在以下场景中显示描述,但除了“(JSX 属性)测试:布尔值”之外,我无法让它说出任何内容

interface TestProps {
    /** Some comment here */
    test: boolean;
}
class TestComp extends React.Component<TestProps, any> {
    render() {
        return <span>{this.props.test}</span>
    }
}

const test = (props) => (
    <div><TestComp test={true} /></div>
)

在帮助测试属性时,有什么方法可以让它显示描述?

示例:

注意底部图片有 - 一些描述和顶部没有

【问题讨论】:

    标签: typescript ecmascript-6 visual-studio-code tsx


    【解决方案1】:

    TypeScript 使用 JSDoc。 /* Some comment here */ 不是有效的 JSDoc。 /** Some comment here */ 是正确的做法。

    VSCode / TypeScript 中的错误

    除了评论错误的事实之外。存在一个错误,无法显示已在 TypeScript / VSCode 中修复的文档。

    更多关于 JSDOC

    http://usejsdoc.org/about-getting-started.html

    【讨论】:

      【解决方案2】:

      TypeScript 2.4 和 VSCode 1.14 已修复此问题:

      VSCode 1.14 附带 TS 2.4。您可以通过检查 VSCode 状态栏右下角的 TS 版本来确保 TS 2.4 处于活动状态

      您也可以关注these instructions在旧版VSCode中使用新版TS

      如果您遇到任何其他问题,请let us know

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-10
      • 1970-01-01
      • 2014-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      相关资源
      最近更新 更多