Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

angular - Problem with generic type of router state in NGRX/router-store

Using NGRX/router-store 9.2

This code (root.reducer.ts):

export interface State {
  [fromRouter.DEFAULT_ROUTER_FEATURENAME]: fromRouter.RouterReducerState<any>;
}

const rootReducer = combineReducers({
  [fromRouter.DEFAULT_ROUTER_FEATURENAME]: fromRouter.routerReducer,
});

export function reducers(state: State | undefined, action: Action) {
  return rootReducer(state, action);
}

builds into this type def (root.reducer.d.ts):

export interface State {
    [fromRouter.DEFAULT_ROUTER_FEATURENAME]: fromRouter.RouterReducerState<any>;
}
export declare function reducers(state: State | undefined, action: Action): {
    router: fromRouter.RouterReducerState<T>;
};
export { fromRouter };

With the error being Cannot find name 'T'.

Shouldn't the build have included the generic typings?

What am I doing wrong?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...