Reputation: 6137
I tried to create the following d.ts file but the type for the created element is any
:
declare module 'jszip' {
interface JSZip {
(): void
file ( name: string, data: string, opts: any ): void
folder ( name: string ): JSZip
}
const dummy: JSZip
export = dummy
}
When using it:
import * as JSZip from 'jszip'
const zip = new JSZip ()
// zip type === any
What is the proper way to do this ?
Upvotes: 5
Views: 1986
Reputation: 7133
You must declare your module as interface with constructor declaration.
declare module 'jszip' {
interface JSZipInterface {
(): void
file ( name: string, data: string, opts: any ): void
folder ( name: string ): JSZipInterface
}
interface JSZipConstructor {
new (): JSZipInterface
}
const module: JSZipConstructor
export = module
}
Upvotes: 7