O'Reilly logo

TypeScript Microservices by Parth Ghiya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing your own *.d.ts file

When you are writing your own *.d.ts file, the stakes are very high. Let's create our own *.d.ts file for any module. Say we want to write a module for my-custom-library:

  1. Create one blank file called my-custom-library.d.ts and write the following inside it:
declare module my-library

This will silence the compiler and won't throw any errors.

  1. Next, you need to define all the methods there and what the return type expected out of each method is. You can find several templates here: http://www.typescriptlang.org/docs/handbook/declaration-files/templates.html. Here, we need to define the available methods and what they are returning. For example, take a look at the following code snippet:
declare function myFunction1 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required