how create default initials state with {} import type { AccountType } from…
- User
how create default initials state with {} import type { AccountType } from '../../types';
export type AccountTypeStatusStore = AccountTypeStatusState & AccountTypeStatusActions;
export type Status = 'uninitialized' | 'pending' | 'fulfilled' | 'rejected';
export type AccountTypeStatusState = { accountTypeStatus: Record<AccountType, Status>; };
type AccountTypeStatusActions = { setInitStatus: (props: { accountType: AccountType; status: Status }) => void; reset: NoopFn; };
- Assistant
To create a default initial state for your
AccountTypeStatusStatetype, you can simply define a constant that adheres to the structure defined in your type definition. You'll want to initializeaccountTypeStatuswith a default value, which is an object where eachAccountTypehas an initial status.Here is how you can create the default initial state:
typescript - User
i need empty object in initial, maybe correct type&
- Assistant
If you need to initialize the
accountTypeStatuswith an empty object ({}) in your initial state, you can still ensure that the type is correct while avoiding TypeScript errors. Here’s how you can create an initial state with an empty object foraccountTypeStatus, along with the correct types:typescript