From c51441c02678dcc93777c84848510b62f3867dd9 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 4 Apr 2022 12:44:05 -0500 Subject: [PATCH] TypeScript: reducers/me --- app/soapbox/reducers/{me.js => me.ts} | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) rename app/soapbox/reducers/{me.js => me.ts} (64%) diff --git a/app/soapbox/reducers/me.js b/app/soapbox/reducers/me.ts similarity index 64% rename from app/soapbox/reducers/me.js rename to app/soapbox/reducers/me.ts index 9f0796a85..e36897785 100644 --- a/app/soapbox/reducers/me.js +++ b/app/soapbox/reducers/me.ts @@ -10,17 +10,21 @@ import { ME_PATCH_SUCCESS, } from '../actions/me'; -const initialState = null; +import type { AxiosError } from 'axios'; +import type { AnyAction } from 'redux'; +import type { Me } from 'soapbox/types/soapbox'; -const handleForbidden = (state, error) => { - if ([401, 403].includes(error.response?.status)) { +const initialState: Me = null; + +const handleForbidden = (state: Me, error: AxiosError) => { + if (([401, 403] as any[]).includes(error.response?.status)) { return false; } else { return state; } }; -export default function me(state = initialState, action) { +export default function me(state: Me = initialState, action: AnyAction): Me { switch(action.type) { case ME_FETCH_SUCCESS: case ME_PATCH_SUCCESS: