TypeScript declaration files were introduced in the Declaration files and JavaScript libraries section of Chapter 3, DOM Manipulation, as a way to describe types of libraries that are only available in JavaScript. That section covered where to find them and how to use them. This section, instead, gives some more details on how to write them in case they are not already available somewhere.
The rule of thumb for deciding how to declare entities in declaration file is as follows:
Declarations contain just the structure of objects without the code that implements their behavior. Declarations of entities that require memory allocation must be preceded by the declare keyword.
Type aliases are declared as they are, since they are already pure declarations:
type size = "small"|"average"|"large";
Since interfaces do not contain...