I'm trying to integrate a JavaScript library (bricks.js) that has no publicly available type definition.
Basically, what the library is exporting is something like this:
export default (config) => {
const instance = SomeConstructorFunction(config);
return instance;
}
I cannot figure out how to correctly create a type definition (.d.ts) for this function; either tsc compiles when I import, I get undefined or tsc won't compile.
For this instance .d.ts compiles:
declare module 'bricks.js' {
export class Bricks {
constructor(config: any);
pack(); // some function available on the instance
}
}
But if I import like this, inside my AngularJs 2 component:
import { Bricks } from 'bricks.js';
this.bricks = new Bricks({//some config here});
Then Bricks is undefined, hence an error is thrown :-).
I don't get exactly how to build a .d.ts for that library; furthermore, the library is compiled using Babel, and I suspect Babel does something with arrow function default exports...
$()..