【发布时间】:2018-12-22 06:59:23
【问题描述】:
我正在使用 JSDoc 形式的 TypeScript,并尝试使用扩展对象的泛型。我的编辑器给我一个 TypeScript 错误 index.js 代码声明 typeMyInterface<T> 的参数,说 Type 'T' does not satisfy the constraint '{ a: number; }'.
如何指定我接受在 JSDoc TypeScript 中约束对象的通用参数?
// index.d.ts
declare interface MyInterface<T extends {a: number}> {
b: string;
}
// index.js
/**
* @template T
* @param {MyInterface<T>} impl
*/
function doStuff(impl) {
console.log(impl);
}
【问题讨论】:
标签: typescript jsdoc