How to declare, a module.export which exports an array, in a .d.ts file

515 Views Asked by At

I have a node js file that exports an array like

const foobar = [{
  foo: "bar"
}]
module.export = foobar

How do I write a .d.ts file for this? I tried

export declare const foobar: Ifoobar[];
interface Ifoobar {
  foo: string
}

But that isn't what is being exported... Declaring it as export default also doesn't do the job

Is there any way I can achieve this specific kind of type annotation? Sadly I can't change the nodejs file...

1

There are 1 best solutions below

0
archuser On BEST ANSWER

Welp, I found the answer myself, in case anybody else has the same problem as me, I fixed it by

export = foobar;
declare const foobar: Ifoobar[];
interface Ifoobar {
  foo: string
}