【发布时间】:2019-02-03 07:07:35
【问题描述】:
我有一个代码库,希望慢慢迁移到 Typescript。这意味着我使用 Node 中的 util.inherits 以非 ES6 方式创建类,并且希望使用 JSDoc 类型注释而不是此时转换为 Typescript。
但是我在输入类时遇到问题:
var util = require("util");
function Base() {
}
/**
* @constructor
* @param {string} arg
*/
function Thing(arg) {
Thing.super_.call(this);
this.x = arg;
}
util.inherits(Thing, Base);
var thing = new Thing("test");
运行 Typescript 时会给出以下输出:
$ tsc --noEmit --allowJs --checkJs .\test.js
test.js:11:15 - error TS2339: Property 'super_' does not exist on type 'typeof Thing'.
11 Thing.super_.call(this);
~~~~~~
有没有办法使用 JSDoc 记录 inherits 创建的 super_ 属性?
【问题讨论】:
标签: javascript typescript jsdoc