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:
- 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.
- 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 ...