[TypeScript] ReturnType

Constructs a type consisting of the return type of function Type.

https://www.typescriptlang.org/docs/handbook/utility-types.html

import { configureStore } from "@reduxjs/toolkit";
import cartReducer from "../features/cart/cartSlice";
import productsReducer from "../features/products/productsSlice";

export const store = configureStore({
  reducer: {
    cart: cartReducer,
    products: productsReducer,
  },
});

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

 

posted @ 2022-04-22 14:06  Zhentiw  阅读(378)  评论(0编辑  收藏  举报