class Point {
x: number;
y: number;
private myAdd = function(x: string, y: string): void { console.log(x + y); }
Invoke(x, y) { this.myAdd(x, y) }
}
let point:Point = {x:0,y:10,
myAdd (x: string, y: string): void { console.log(x + y); },
Invoke(x, y) { this.myAdd(x, y) }};
报错信息:error TS2322: Type '{ x: number; y: number; myAdd(x: string, y: string): void; Invoke(x: any, y: any): void; }' is not assignable to type 'Point'.
Property 'myAdd' is private in type 'Point' but not in type '{ x: number; y: number; myAdd(x: string, y: string): void; Invoke(x: any, y: any): void; }'.
这种带有私有property/function的类只能用构造函数声明对象吗?