Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda