[英]How to write a typings file for exported javascript object
I have a javascript file file that looks like this:我有一个看起来像这样的 javascript 文件:
// methodHelpers.js
export default {
refetchData: function() {
// do some data refetching
}
};
Now I would like to have a typings file (methodHelpers.d.ts) that would allow me to get code editing completions for the methods on the object I am importing.现在我想要一个类型文件 (methodHelpers.d.ts),它允许我为我正在导入的对象上的方法获取代码编辑完成。
I have tried:我试过了:
// methodHelpers.d.ts
export interface methodHelpers {
refetchData(): void;
}
But the completions are still missing.但完成工作仍然缺失。
您需要export default
该接口的export default
,而不仅仅是export
'ing 它,因为它是原始文件中的默认导出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.