gpt4 book ai didi

javascript - Angular ngrx Prop 中没有重载匹配此调用

转载 作者:行者123 更新时间:2023-12-04 01:30:13 25 4
gpt4 key购买 nike

在定义 Action 和使用 Prop 时的 Angular 应用程序中,我在 Prop 上得到“没有重载匹配此调用......”

import { createAction, props } from "@ngrx/store";
export const storeCurrentDashboard = createAction(
"[effect] store current dashboard in state",
props<Dashboard>()// here i get the error
);

仪表板类如下
export class Dashboard {
id: number;
title: string;
type: DashboardType; // the problem is this property
blocks?: any[];
}
export enum DashboardType {
Private = "Private",
Shared = "Shared",
...
}

如果我删除作为枚举的“类型”属性,一切都可以。
为什么 Prop 有枚举类型的问题?

编译器错误:
   ERROR in ...: error TS2345: Argument of type '"type property is not allowed in action creators"'
is not assignable to parameter of type 'FunctionWithParametersType<any[], object>'.

最佳答案

and if i remove "type" property which is an enum every thing is ok. why props have problem with enum types?



type就像 NgRx 的保留字,在 createAction调用,它匹配第一个参数。

关于javascript - Angular ngrx Prop 中没有重载匹配此调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61185269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com