Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
How to import vanilla JavaScript objects in TypeScript

I have a traditional JavaScript file, say abc.js that does something like this:

// abc.js
if (typeof ABC !== "object") {
    ABC = {};
}
(function () {
   // ... construct the ABC object
})

This is a 3rd-party dependency that I cannot touch.

Then, in my TypeScript file, say main.ts, I want to include the ABC object defined in abc.js so that the TypeScript checker can understand it.

Ideally I would like to end up with a single .js file after the compilation. What's the correct way of doing it?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can access to the JavaScript Object through window For example: import "spotlight" window.Spotlight.show(...) How to import Vanilla JS ES6 modules in TypeScript?

about 4 years ago · Juan Pablo Isaza Relatório

0

You might need to tweak tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false,
  }
}

and import in main.ts:

import * as ABC from './abc';
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda