gpt4 book ai didi

ngrx - 选择器没有重载匹配此调用

转载 作者:行者123 更新时间:2023-12-05 09:34:24 25 4
gpt4 key购买 nike

这是我的 selector.ts

export interface ITestState {
value: number;
}
export interface IReduxState {
test: ITestState;
}
export const selectTest = (state: IReduxState) => state.test;
export const selectTestValue = createSelector(
selectTest,
(state: ITestState) => state.value
);

Ï如果我尝试在 app.component.ts 中使用它像这样

  constructor(private store: Store) {
this.vaschal$ = store.select(selectTestValue);
}

出现以下错误

No overload matches this call.
Overload 1 of 9, '(mapFn: (state: object) => number): Observable<number>', gave the following error.
Argument of type 'MemoizedSelector<IReduxState, number, DefaultProjectorFn<number>>' is not assignable to parameter of type '(state: object) => number'.
Types of parameters 'state' and 'state' are incompatible.
Property 'test' is missing in type '{}' but required in type 'IReduxState'.
Overload 2 of 9, '(key: never): Observable<never>', gave the following error.
Argument of type 'MemoizedSelector<IReduxState, number, DefaultProjectorFn<number>>' is not assignable to parameter of type 'never'

角度版本 11.2.4我做错了什么?

最佳答案

您需要通知 Store 根存储状态:

constructor(private store: Store<IReduxState>) {
this.vaschal$ = store.select(selectTestValue);
}

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

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