我有一个代码库,希望能慢慢迁移到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);
~~~~~~
是否可以记录由super_
使用JSDoc创建的inherits
属性?
答案 0 :(得分:1)
这似乎可行:
/** @type {typeof Base} */
Thing.super_;