Does TypeScript support namespace?

后端 未结 5 967
无人共我
无人共我 2021-02-02 05:47

As in the title: does TypeScript support namespaces? If so, how do I use them?

5条回答
  •  执笔经年
    2021-02-02 06:27

    As of version 1.5, Typescript supports namespace keyword. Namespaces are equivalent to internal modules.

    From What's new in Typescript:

    Before:

    module Math {
        export function add(x, y) { ... }
    }
    

    After:

    namespace Math {
        export function add(x, y) { ... }
    }
    

    For defining an internal module, now you can use both module and namespace.

提交回复
热议问题