Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript: can't disable type definitions for one special library

Tags:

typescript

TypeScript Version: 2.4.1

For example I want to consume a library from npm called awesome-lib. This library already ships with a TypeScript type definition but this one is outdated and buggy. The author of the library doesn't update this one.

I've tried to disable that type definition completely in my own declarations.d.ts file in my project:

declare module 'awesome-lib';

Unfortunately TypeScript reads first the type definition in the library and throws some errors. So it is not possible for me to disable / hide this library for my project.

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

like image 386
LongFlick Avatar asked Nov 08 '22 19:11

LongFlick


1 Answers

Maybe you could try to use require instead of import:

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

the downside is you have no type checking nor intellisense.

like image 137
José Quinto Zamora Avatar answered Nov 15 '22 11:11

José Quinto Zamora