oxygen
oxygen

Reputation: 113

How to import a js Module as any. (Without any declaration file (d.ts))

So I want to import a js module in my ts app.

Is there a way to do this without making a d.ts file or if not how to declare it as any in the d.ts file?

I am currently just ignoring this error with //@ts-ignore.

Thanks!

Upvotes: 0

Views: 522

Answers (1)

Kelvin Schoofs
Kelvin Schoofs

Reputation: 8718

There are two cases here:

  • You are using ESM modules, and only have import(...) available
const module = (await import('module')) as any;
  • You aren't using ESM modules, therefore you have access to require(...)
const module = require('module') as any;

Upvotes: 1

Related Questions