TypeScript: declare a variable that is a function named “new”

后端 未结 1 1180
清歌不尽
清歌不尽 2021-01-27 09:30

Let\'s say I want to write TypeScript definitions of a modules where it\'s JavaScript equivalent is the following:

var service = {};
service.new = function (name         


        
相关标签:
1条回答
  • 2021-01-27 10:16

    In certain contexts you can quote identifier names:

    interface MyModule {
        "new"(name: string, options: Options): NewService;
    }
    
    declare const m: MyModule;
    export = m;
    
    0 讨论(0)
提交回复
热议问题