0
打字稿,如何添加一個方法的類定義打字稿 - 如何添加類定義之外的方法
我嘗試添加它的原型之外,但錯誤
B.ts
export class B{
name: string = 'sam.sha'
}
//Error:(21, 13) TS2339: Property 'say' does not exist on type 'B'.
B.prototype.say = function(){
console.log('define method in prototype')
}