我有一门课叫
ClassA
它有10个道具。现在在我的课堂上,我想有一个
甲级
添加一个叫做
isValid
但我不想创建一个新类并扩展它
export class ClassA {
constructor(
public active: boolean,
public createdBy: string,
public createdTimestamp: Date,
public entityState: string,
public scopeType: string,
public scopeValue: string,
public tableDescription: string,
public tableId: number,
public tableName: string,
public changeHistoryPreserveDays = 0,
public createdString: string
) { }
}
在我的组件中:
myInstance : any = {
isValid : true
}
foo(classA: ClassA) {
this.myInstance = {...myInstance, ...classA};
}
然后使用
any
我要取消打字检查。
我的问题是,有没有快速的方法来扩展一个类,而不定义一个新的类