Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add types
  • Loading branch information
Xavier Lozano Carreras committed Nov 12, 2024
commit 28dc1189601442c64b01e67191a5964b6103c829
4 changes: 3 additions & 1 deletion packages/data-stores/src/analyzer/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const analyzer: Reducer< ColorsState, Action > = ( state = {}, action ) => {
return state;
};

const reducers = combineReducers( { analyzer } );
const reducers: Reducer< { analyzer: ColorsState }, Action > = combineReducers( {
analyzer,
} );

export type State = ReturnType< typeof reducers >;

Expand Down
2 changes: 1 addition & 1 deletion packages/data-stores/src/analyzer/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { State } from './reducers';

export const getState = ( state: State ) => state;
export const getState = ( state: State ): State => state;
export const isSiteColorsInAnalysis = ( state: State ) => state.analyzer.analyzing;
export const getSiteColors = ( state: State, url: null | string ) => {
if ( ! url ) {
Expand Down
9 changes: 8 additions & 1 deletion packages/data-stores/src/domain-suggestions/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ const availability: Reducer< DomainAvailabilities, Action > = ( state = {}, acti
return state;
};

const reducer = combineReducers( { categories, domainSuggestions, availability } );
const reducer: Reducer<
{
availability: DomainAvailabilities;
categories: DomainCategory[];
domainSuggestions: DomainSuggestionState;
},
Action
> = combineReducers( { categories, domainSuggestions, availability } );

export type State = ReturnType< typeof reducer >;

Expand Down
22 changes: 21 additions & 1 deletion packages/data-stores/src/help-center/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,27 @@ const odieBotNameSlug: Reducer< string | undefined, HelpCenterAction > = ( state
return state;
};

const reducer = combineReducers( {
const reducer: Reducer<
{
currentSupportInteraction: SupportInteraction | undefined;
showHelpCenter: boolean | undefined;
showMessagingLauncher: boolean | undefined;
showMessagingWidget: boolean | undefined;
subject: string | undefined;
message: string | undefined;
userDeclaredSite: SiteDetails | undefined;
userDeclaredSiteUrl: string | undefined;
hasSeenWhatsNewModal: boolean | undefined;
isMinimized: boolean;
isChatLoaded: boolean;
zendeskClientId: string;
unreadCount: number;
navigateToRoute: string | undefined;
odieInitialPromptText: string | undefined;
odieBotNameSlug: string | undefined;
},
HelpCenterAction
> = combineReducers( {
currentSupportInteraction,
showHelpCenter,
showMessagingLauncher,
Expand Down
8 changes: 7 additions & 1 deletion packages/data-stores/src/launchpad-navigator/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ const checklistsSlug: Reducer< string[], LaunchpadNavigatorAction > = ( state =
return state;
};

const reducer = combineReducers( {
const reducer: Reducer<
{
activeChecklistSlug: string | null | undefined;
checklistsSlug: string[];
},
LaunchpadNavigatorAction
> = combineReducers( {
activeChecklistSlug,
checklistsSlug,
} );
Expand Down
55 changes: 54 additions & 1 deletion packages/data-stores/src/onboard/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,60 @@ const signupDomainOrigin: Reducer< string | undefined, OnboardAction > = (
return state;
};

const reducer = combineReducers( {
const reducer: Reducer<
{
domain: DomainSuggestion | undefined;
domainCartItem: MinimalRequestCartProduct | undefined;
domainSearch: string;
domainCategory: string | undefined;
domainForm: DomainForm;
siteUrl: string | undefined;
isRedirecting: boolean;
hasUsedDomainsStep: boolean;
hasUsedPlansStep: boolean;
selectedFeatures: FeatureId[];
domainTransferNames: DomainTransferNames | undefined;
domainTransferAuthCodes: DomainTransferAuthCodes | undefined;
shouldImportDomainTransferDnsRecords: boolean;
storeType: string;
selectedDesign: Design | undefined;
selectedStyleVariation: StyleVariation | undefined;
selectedSite: number | undefined;
siteTitle: string;
showSignupDialog: boolean;
planProductId: number | undefined;
randomizedDesigns: { featured: Design[] };
hasOnboardingStarted: boolean;
lastLocation: string;
intent: string;
startingPoint: string;
pendingAction: undefined | ( () => Promise< any > );
progress: number;
progressTitle: string | undefined;
goals: SiteGoal[];
hideFreePlan: boolean;
hidePlansFeatureComparison: boolean;
siteDescription: string;
siteLogo: null | string;
siteAccentColor: string;
readymadeTemplate: ReadymadeTemplate | undefined;
verticalId: string;
storeLocationCountryCode: string;
ecommerceFlowRecurType: string;
couponCode: string;
storageAddonSlug: string;
planCartItem: MinimalRequestCartProduct | null;
productCartItems: MinimalRequestCartProduct[] | null;
isMigrateFromWp: boolean;
domainCartItems: MinimalRequestCartProduct[] | undefined;
pluginsToVerify: string[] | undefined;
profilerData: ProfilerData | undefined;
paidSubscribers: boolean;
partnerBundle: string | null;
signupDomainOrigin: string | undefined;
},
OnboardAction
> = combineReducers( {
domain,
domainCartItem,
domainSearch,
Expand Down
2 changes: 1 addition & 1 deletion packages/data-stores/src/onboard/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const getStoreLocationCountryCode = ( state: State ) => state.storeLocati
export const getEcommerceFlowRecurType = ( state: State ) => state.ecommerceFlowRecurType;
export const getCouponCode = ( state: State ) => state.couponCode;
export const getStorageAddonSlug = ( state: State ) => state.storageAddonSlug;
export const getState = ( state: State ) => state;
export const getState = ( state: State ): State => state;
export const hasPaidDesign = ( state: State ): boolean => {
if ( ! state.selectedDesign ) {
return false;
Expand Down
10 changes: 9 additions & 1 deletion packages/data-stores/src/plans/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ export const planProducts: Reducer< PlanProduct[], PlanAction > = ( state = [],
}
};

const reducer = combineReducers( {
const reducer: Reducer<
{
features: Record< Locale, Record< string, PlanFeature > >;
featuresByType: Record< Locale, Array< FeaturesByType > >;
planProducts: PlanProduct[];
plans: Record< Locale, Plan[] >;
},
PlanAction
> = combineReducers( {
features,
featuresByType,
planProducts,
Expand Down
8 changes: 7 additions & 1 deletion packages/data-stores/src/products-list/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ export const isFetchingProductsList: Reducer< boolean | undefined, Action > = (
return state;
};

const reducer = combineReducers( {
const reducer: Reducer<
{
isFetchingProductsList: boolean | undefined;
productsList: RawAPIProductsList | undefined;
},
Action
> = combineReducers( {
isFetchingProductsList,
productsList,
} );
Expand Down
28 changes: 27 additions & 1 deletion packages/data-stores/src/site/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,33 @@ const newSite = combineReducers( {
isFetching: isFetchingSite,
} );

const reducer = combineReducers( {
const reducer: Reducer<
{
isFetchingSiteDetails: boolean | undefined;
newSite: {
data: NewSiteBlogDetails | undefined;
error: NewSiteErrorResponse | undefined;
isFetching: boolean | undefined;
};
fetchingSiteError: SiteError | undefined;
sites: { [ key: number | string ]: SiteDetails | undefined };
launchStatus: { [ key: number ]: SiteLaunchState };
sitesDomains: { [ key: number ]: Domain[] };
sitesSettings: { [ key: number ]: SiteSettings };
siteTheme: { [ key: number ]: CurrentTheme };
sitesGlobalStyles: { [ key: number ]: GlobalStyles };
siteSetupErrors: {
error?: string;
message?: string;
};
atomicTransferStatus: { [ key: number ]: AtomicTransferState };
latestAtomicTransferStatus: { [ key: number ]: LatestAtomicTransferState };
atomicSoftwareStatus: { [ key: number ]: AtomicSoftwareStatusState };
atomicSoftwareInstallStatus: { [ key: number ]: AtomicSoftwareInstallState };
bundledPluginSlug: { [ key: string ]: string | undefined };
},
Action
> = combineReducers( {
isFetchingSiteDetails,
newSite,
fetchingSiteError,
Expand Down
7 changes: 6 additions & 1 deletion packages/data-stores/src/stepper-internal/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export const stepData: Reducer< StepData | null, StepperInternalAction > = (
return state;
};

const reducer = combineReducers( {
const reducer: Reducer<
{
stepData: StepData | null;
},
StepperInternalAction
> = combineReducers( {
stepData,
} );

Expand Down
7 changes: 6 additions & 1 deletion packages/data-stores/src/subscriber/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ export const subscriber: Reducer< SubscriberState, Action > = ( state = {}, acti
return state;
};

const reducers = combineReducers( { subscriber } );
const reducers: Reducer<
{
subscriber: SubscriberState;
},
Action
> = combineReducers( { subscriber } );

export type State = ReturnType< typeof reducers >;

Expand Down
7 changes: 6 additions & 1 deletion packages/data-stores/src/user/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export const currentUser: Reducer< CurrentUser | null | undefined, Action > = (
return state;
};

const reducer = combineReducers( { currentUser } );
const reducer: Reducer<
{
currentUser: CurrentUser | null | undefined;
},
Action
> = combineReducers( { currentUser } );
export type State = ReturnType< typeof reducer >;

export default reducer;
8 changes: 7 additions & 1 deletion packages/data-stores/src/wpcom-plans-ui/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const selectedStorageOptionForPlan: Reducer<
return state;
};

const reducer = combineReducers( {
const reducer: Reducer<
{
showDomainUpsellDialog: boolean | undefined;
selectedStorageOptionForPlan: SelectedStorageOptionForPlan | undefined;
},
WpcomPlansUIAction
> = combineReducers( {
showDomainUpsellDialog,
selectedStorageOptionForPlan,
} );
Expand Down