Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
How to write a type declaration for UMD global js library

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!