What is the story for creating and consuming TypeScript libraries?

前端 未结 2 1449
Happy的楠姐
Happy的楠姐 2021-02-06 05:15

I\'ve been using TypeScript here and there for web applications and have referenced public type definitions made available through Definitely Typed but one thing that has always

2条回答
  •  暖寄归人
    2021-02-06 05:26

    well, I think that you can use modules for this purpose, modules is like namespace in c#, e.g.

    //File Utils.ts
    module Utils
    {
        export class UtilsClass
        {
            do(param: string)
            {
                //do something
            }
        }
    }
    
    //Another ts file
    var formatter = new Utils.UtilsClass();
    formatter.do("str");
    

    Regards,

提交回复
热议问题