简体   繁体   中英

How to write a typings file for exported javascript object

I have a javascript file file that looks like this:

// 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.

I have tried:

// methodHelpers.d.ts
export interface methodHelpers {
  refetchData(): void;
}

But the completions are still missing.

您需要export default该接口的export default ,而不仅仅是export 'ing 它,因为它是原始文件中的默认导出。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM