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

265
Views
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 answers
Answer question

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 Report

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 Report
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!