0
我正在尝试将类型化操作引入到我的应用程序中。我试过这两个类的声明。第一个工作正常,但第二个导致我的IDE(WebStorm)抱怨信息Unresolved variable payload
。它只是我的IDE是愚蠢的还是它正确地报告问题?我更喜欢后一种解决方案,因为我觉得它更加明确,使开发人员更清楚知道创建有效操作需要什么。Typescript手动属性分配导致键入类型为ngrx动作的类型错误
工作:
export class OrdersGetAction implements Action {
type = ActionTypes.ORDERS_GET;
constructor(public payload: number) {}
}
不工作 - Unresolved variable payload
:
export class OrdersGetAction implements Action {
public payload;
public type = ActionTypes.ORDERS_GET;
constructor(clientId: number) {
this.payload = clientId;
}
}
任何意见将不胜感激。