I'm trying to enhance a third-party js library with typing.
Consider the following structure of the js library:
'use strict';
var AutoModel = AutoModel || {};
if (typeof AutoModel.constructed === "undefined") {
(function (o) {
function open() {
...
}
o.Motor = new function() {
function start()...
}
...
o.constructed = true;
})(AutoModel);
}
The js is loaded in the <script> section and in my ts file it would use it like:
declare const AutoModel: any;
export class TestClass {
doSomething(): void {
AutoModel.open();
AutoModel.Motor.start();
}
}
How can I write a d.ts that gives me typing and code completion for 'AutoModel'? Would be cool if I could omit the redeclaration completely.
I've already tried a lot of different approaches but none leads to a completely satisfying solution.