如何使用 JSDoc 在 Typescript 中记录 JS class

How to document a JS class in Typescript with JSDoc

我有一个代码库,希望慢慢迁移到 Typescript。这意味着我使用 util.inherits 从 Node 创建 类 非 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_ 属性?

这似乎有效:

/** @type {typeof Base} */
Thing.super_;