I'm building a website for Beaker Browser using Angular6.
Beaker Browser has a built-in class called DatArchive. I want to create a type-declaration file for it.
When this class was used in only one file, I simply wrote
declare class DatArchive {
static selectArchive(opts: any): Promise<DatArchive>;
static create(opts: any): Promise<DatArchive>;
constructor(datUrl: String);
url: string;
}
in the file and everything worked like a charm. However, when I wanted to extract it into its own file, I tried:
export declare class DatArchive {
static selectArchive(opts: any): Promise<DatArchive>;
static create(opts: any): Promise<DatArchive>;
constructor(datUrl: String);
url: string;
}
...
// in other files
import { DatArchive } from 'dat-archive';
And although it passed compilation, in runtime, seemingly, it was looking for a DatArchive inside a module, but a DatArchive is a top-level (on window object) class.
So, the question:
In Angular/Typescript, how to write a type-declaration file for a class that is NOT part of a module?