Breeze 구문에 너무 익숙해하지 않지만 "createEntity"는 breeze.Entity 유형을 올바르게 반환합니다. TypeScript를 사용하면 반환 된 객체를 "instance"에 할당 할 수 없습니다.이 객체는 myClass 유형이며 breeze.Entity 인터페이스를 구현합니다. 입력 assignmable되지 않습니다 작동합니다 같은TypeScript 정의 클래스에 Breeze.Entity 지정
이 보인다,하지만 난 오류 "유형 '법인'얻을 'myClass가'. 속성 'ID가'유형 '실체'에 없습니다.
완전히 I 오전 (또는 일반)?
this.instance = EntityManager.createEntity("myClass", myObj); // instance is defined as type 'myType'
나는대로 this.instance를 정의하면 '어떤'모든 것이 작동하지만 다른 곳에서 내 강력한 형식의 개체를 잃게 타이프에 상속 및/또는 인터페이스를 오해.
내 수업을 및 인터페이스 ...
export class myClass extends base implements Interfaces.IMyClass, breeze.Entity {
public id: number;
....
constructor() {
super();
}
}
export class base implements breeze.Entity {
constructor() { }
public entityAspect: breeze.EntityAspect;
public entityType: breeze.EntityType;
}
export interface IMyClass extends breeze.Entity {
id: number;
...
}