47ndr
47ndr

Reputation: 633

How to implement declaration .d.ts file in Typescript

I found a lot of literature on what the declaration .d.ts files are, but not on how to implement them. I understood that they can be auto-generated with the typescript compiler.

So my questions are:

Thank you

Upvotes: 1

Views: 2850

Answers (1)

Mike Hanson
Mike Hanson

Reputation: 306

If you are creating a library with TypeScript I would suggest leaving it to the TS compiler to generate the definition files. By default the compiler creates a d.ts file next to each .ts file.

Typically you would only need to hand craft a .d.ts file when you are using a library that doesn't include type definitions for example some old JavaScript library and you can't find one that someone else has created published to the DefinitelyTyped repo.

If you are writing your own I would suggest you would create a single file.

Upvotes: 1

Related Questions