Reputation: 170
My codebase is a mix of typescript + javascript. When importing a javascript library into a typescript library, i just use the // @ts-ignore. But i'm using this javascript library quite frequently and it's been tedious to constantly put //@ts-ignore on top of the import. Is there a way to globally ignore the non-ts libraries?
//@ts-ignore
import jsLibraryThing from "@jsLibraryThing"
Upvotes: 2
Views: 2175
Reputation: 250416
You can create a declaration file for this library that just exports any
. This will allow you to import it without any error and the import will be typed as any
so you can use it almost like in JS
// jsLibraryThing.d.ts
declare module '@jsLibraryThing' {
const e: any;
export default e
}
//usage.ts
import jsLibraryThing from "@jsLibraryThing"
jsLibraryThing.something // all fine
Upvotes: 2