8

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?

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Another solution might be to use lib like core-js. which has all the required polyfils for ES6. Note: you will also will need to add the core-js tsd file to your tsds.

Hope it helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.