Javascript 如何使用JSDoc在Typescript中记录JS类
我有一个代码库,我正在寻找慢慢迁移到Typescript。这意味着我使用from节点以非ES6方式创建类,并且希望使用JSDoc类型注释,而不是此时转换为Typescript 但我在输入课程时遇到问题:Javascript 如何使用JSDoc在Typescript中记录JS类,javascript,typescript,jsdoc,Javascript,Typescript,Jsdoc,我有一个代码库,我正在寻找慢慢迁移到Typescript。这意味着我使用from节点以非ES6方式创建类,并且希望使用JSDoc类型注释,而不是此时转换为Typescript 但我在输入课程时遇到问题: var util = require("util"); function Base() { } /** * @constructor * @param {string} arg */ function Thing(arg) { Thing.super_.call(this);
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记录由继承创建的super
属性?这似乎有效:
/** @type {typeof Base} */
Thing.super_;