Variables
For example to tell TypeScript about the process
variable you can do:
You don't need to do this for
process
as there is already a community maintainednode.d.ts
.
This allows you to use the process
variable without TypeScript complaining:
We recommend using an interface wherever possible e.g.:
This allows other people to extend the nature of these global variables while still telling TypeScript about such modifications. E.g. consider the following case where we add an exitWithLogging
function to process for our amusement:
Let's look at interfaces in a bit more detail next.
Last updated