TypeScript中的Interface的两个问题。

1。下面这种interface里带new的格式是什么意思?

interface xxx{
    new (str:string):number;
}

没有new的话我知道是限制一个方法的参数和返回值。


2。在一个class里可以使用setter和getter,如何用interface限定某一个class里必须有某个getter?

class xxx{
     private name:string;
     get Name():string{
         return this.name;
     }
}
interface Named{
	get Name():string;//然而这两种格式都不行?
	Name():string;
}


我吃西瓜很快
浏览 2361回答 1
1回答

qq_啊啦嘞_0

问的好
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript