Creating a Namespace in TypeScript Declaration Files
Explore how to create namespaces in TypeScript declaration files to organize class functions and properties. Understand defining interfaces for precise typing and how detailed declaration files improve IDE support by enforcing strict type rules.
We'll cover the following...
When writing declaration files, we need a way of grouping functions and properties
of classes under the class name. TypeScript uses the module keyword as a means of creating a namespace so that all functions or properties of a class can be grouped together within the class namespace.
Creating a namespace
Let’s take a look at the first version of a declaration file for our ErrorHelper JavaScript
class in the file named globals.d.ts:
Here, we use the declare keyword combined with the module keyword to
define a namespace named ErrorHelper on ...