TypeScript: cannot turn off type definitions for one special library

TypeScript Version: 2.4.1

For example, I want to use a library from npm called awesome-lib

. This library already comes with a TypeScript type definition, but this one is deprecated and buggy. The library author does not update this file.

I tried to completely disable this type definition in my own file declarations.d.ts

in my project:

declare module 'awesome-lib';

      

Unfortunately, TypeScript reads the library's type definition first and throws some errors. Therefore, it is impossible for me to disable / hide this library for my project.

Does anyone know how to disable type checking for a custom one custom library?

+3


source to share


2 answers


Perhaps you can try using require instead of import:

/* tslint:disable:no-var-requires */
const awesomeLib: any = require("awesome-lib");
/* tslint:enable:no-var-requires */

      



The downside is that you don't have type checking or intellisense.

+1


source


This may not be a real solution, but if a library is abandoned and broken, you can fork that library, change its typing, and use it in your project.



0


source







All Articles