Sharing code is a good practice. It allows you to build and test once, and then build on top of the code in many other projects. TypeScript uses modules and namespaces to share code, as well as definition files.

Namespace: A fading concept

The concept of namespaces in TypeScript is fading away with the second, more powerful way to share code: a module. A namespace is a basic object assigned to the global space. The object, named after the name of the namespace, holds the functions created within this one.

Get hands-on with 1200+ tech skills courses.