Does TypeScript support namespace?

后端 未结 5 973
无人共我
无人共我 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:28

    Here is a TypeScript namespace example:

    ///
    ///
    
    module MyNamespace
    {
        import ClassOne = AnotherNamespace.ClassOne;
        import ClassTwo = AnotherNamespace.ClassTwo;
    
        export class Main
        {
            private _classOne:ClassOne;
            private _classTwo:ClassTwo;
    
            constructor()
            {
                this._classOne = new ClassOne();
                this._classTwo = new ClassTwo();
            }
        }
    }
    

    You can check out more here:http://www.codebelt.com/typescript/javascript-namespacing-with-typescript-internal-modules/

提交回复
热议问题