Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use TypeScript lib.core.d.ts instead of lib.d.ts

It seems the TypeScript compiler always includes lib.d.ts or lib.es6.d.ts (depending on the compiler target).

In our application we have a WebSocket class that is already defined in lib.d.ts. We're running our application under Node.js and not in a web browser, so we actually don't need all of the definitions from lib.d.ts. Instead lib.core.d.ts would be sufficient for us (and would solve the WebSocket conflict of course).

Is it possible to tell the TypeScript compiler which global type definition file to use?

like image 785
Michel Krämer Avatar asked Jun 14 '15 07:06

Michel Krämer


1 Answers

Use --noLib compiler option to exclude lib.d.ts and then add reference to lib.core.d.ts in your source files.

Equivalent for tsconfig.json would be "noLib": true.

If you only need Node.js definitions, you can also use the Definitely Typed one.

like image 175
zlumer Avatar answered Oct 03 '22 13:10

zlumer