Michael Hilus Michael Hilus - 1 year ago 67
Javascript Question

How to handle @types/any when it is only a stub types definition correctly?

Say, I want to use date-fns in my typescript project. Usually, I grab the typings of such a library by installing it's type definitions:

npm install @types/date-fns --save-dev


But sometimes, ony stubs are available. In the case of date-fsn it says
date-fns provides its own type definitions, so you don't need @types/date-fns installed!


However, how do I integrate those typing files then into my project? Do I really need to put all those
*.d.ts
files into the
files
section of my
tscofig.json
or is there a better approach?

Answer Source

However, how do I integrate those typing files then into my project?

When the project ships with type definitions you don't need to install @types. The project should work out of the box with TypeScript.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download