0 votes
in TypeScript - JavaScript's Superset by
What is namespace in Typescript? How to declare a namespace in Typescript?

1 Answer

0 votes
by

A namespace is a way that is used for logical grouping of functionalities. Namespaces are used to maintain the legacy code of typescript internally. It encapsulates the features and objects that share certain relationships. A namespace is also known as internal modules. A namespace can also include interfaces, classes, functions, and variables to support a group of related functionalities.

Note: A namespace can be defined in multiple files and allow to keep each file as they were all defined in one place. It makes code easier to maintain.

Synatax for creating namespace

namespace <namespace_name> {    

           export interface I1 { }    

           export class c1{ }    

}    

...