【问题标题】:ERROR: Unable to parse " ": Unexpected token (JSDoc)错误:无法解析“”:意外的令牌(JSDoc)
【发布时间】:2017-01-31 18:11:44
【问题描述】:

我已经根据 JsDoc 的文档定义了类、属性、方法,但我得到的错误是:无法解析“/somePath”:意外的令牌。我的类定义如下:-

/**
 * class representing Lab testResults
 * @param {object} props: contain all the property
 */
class LabTestResult extends Component {
    constructor(props) {
        super(props);
        this.state = {
            loading: true,
        }
        this.collapseButton = this.collapseButton.bind(this);
    }
    state = {
        open: false,
    };
}

为什么我会收到此错误?我该如何解决这个问题?请帮助我。

【问题讨论】:

  • state = {open: false}; 在 ES6 中无效。我不希望 jsdoc 支持所有实验性功能。

标签: reactjs ecmascript-6 jsdoc


【解决方案1】:

如果这是 2015 年的香草课程,这里有一个示例(来自文档)。我不认为“类”注释需要参数。无论如何,这就是它所说的“记录一个简单的 es2015 类”的方式。请注意,参数位于构造函数之上,而不是类。我从来都不是 JSDoc 向导,但这看起来不正确。

从这里:http://usejsdoc.org/howto-es2015-classes.html

/**
 * Class representing a dot.
 * @extends Point
 */
class Dot extends Point {
    /**
     * Create a dot.
     * @param {number} x - The x value.
     * @param {number} y - The y value.
     * @param {number} width - The width of the dot, in pixels.
     */
    constructor(x, y, width) {
        // ...
    }

    /**
     * Get the dot's width.
     * @return {number} The dot's width, in pixels.
     */
    getWidth() {
        // ...
    }
}

【讨论】:

    猜你喜欢
    • 2022-01-02
    • 2019-02-19
    • 2017-11-21
    • 2013-09-26
    • 2018-09-12
    • 2017-07-16
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    相关资源
    最近更新 更多