I've been attempting to incorporate a JavaScript library known as bricks.js into my project, but unfortunately, there isn't a publicly available type definition for it.
The library seems to be exporting something along these lines:
export default (config) => {
const instance = SomeConstructorFunction(config);
return instance;
}
I'm having trouble creating an accurate type definition (.d.ts) for this function. When I import it, tsc either compiles with undefined results or fails to compile altogether.
So far, this .d.ts definition has successfully compiled:
declare module 'bricks.js' {
export class Bricks {
constructor(config: any);
pack(); // some function available on the instance
}
}
However, when I try to import it within my AngularJs 2 component like this:
import { Bricks } from 'bricks.js';
this.bricks = new Bricks({//some config here});
The imported Bricks object turns out to be undefined
, resulting in an error being thrown. It's puzzling to me how to create a proper .d.ts file for this library. Additionally, since the library is compiled using Babel, I have a feeling that Babel might be doing something with the arrow function default exports...