From 2a586c984bd964c7cd65cd3f59ea8f69e496d654 Mon Sep 17 00:00:00 2001 From: tae Date: Mon, 4 May 2020 19:21:46 +0900 Subject: [PATCH] migrate reducers/themes to TypeScript (#23716) Co-authored-by: tae --- packages/gatsby/src/redux/reducers/index.js | 3 ++- packages/gatsby/src/redux/reducers/themes.js | 12 ------------ packages/gatsby/src/redux/reducers/themes.ts | 17 +++++++++++++++++ packages/gatsby/src/redux/types.ts | 5 +++++ 4 files changed, 24 insertions(+), 13 deletions(-) delete mode 100644 packages/gatsby/src/redux/reducers/themes.js create mode 100644 packages/gatsby/src/redux/reducers/themes.ts diff --git a/packages/gatsby/src/redux/reducers/index.js b/packages/gatsby/src/redux/reducers/index.js index 1bc90fd0b9bbd..92319aeabc55b 100644 --- a/packages/gatsby/src/redux/reducers/index.js +++ b/packages/gatsby/src/redux/reducers/index.js @@ -4,6 +4,7 @@ import { redirectsReducer } from "./redirects" import { staticQueryComponentsReducer } from "./static-query-components" import { statusReducer } from "./status" import { webpackReducer } from "./webpack" +import { themesReducer } from "./themes" import { webpackCompilationHashReducer } from "./webpack-compilation-hash" import { reducer as logReducer } from "gatsby-cli/lib/reporter/redux/reducer" @@ -69,7 +70,7 @@ module.exports = { redirects: redirectsReducer, babelrc: require(`./babelrc`), schemaCustomization: require(`./schema-customization`), - themes: require(`./themes`), + themes: themesReducer, logs: logReducer, inferenceMetadata: require(`./inference-metadata`), pageDataStats: require(`./page-data-stats`), diff --git a/packages/gatsby/src/redux/reducers/themes.js b/packages/gatsby/src/redux/reducers/themes.js deleted file mode 100644 index 4f6e52a335f1b..0000000000000 --- a/packages/gatsby/src/redux/reducers/themes.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = (state = {}, action) => { - switch (action.type) { - case `SET_RESOLVED_THEMES`: - return { - ...state, - themes: action.payload, - } - - default: - return state - } -} diff --git a/packages/gatsby/src/redux/reducers/themes.ts b/packages/gatsby/src/redux/reducers/themes.ts new file mode 100644 index 0000000000000..81a5124c64c2a --- /dev/null +++ b/packages/gatsby/src/redux/reducers/themes.ts @@ -0,0 +1,17 @@ +import { IGatsbyState, ISetResolvedThemesAction } from "../types" + +export const themesReducer = ( + state: IGatsbyState["themes"] = {}, + action: ISetResolvedThemesAction +): IGatsbyState["themes"] => { + switch (action.type) { + case `SET_RESOLVED_THEMES`: + return { + ...state, + themes: action.payload, + } + + default: + return state + } +} diff --git a/packages/gatsby/src/redux/types.ts b/packages/gatsby/src/redux/types.ts index 5b0c643d6d8d9..c17f5832b0650 100644 --- a/packages/gatsby/src/redux/types.ts +++ b/packages/gatsby/src/redux/types.ts @@ -380,6 +380,11 @@ export interface ICreateRedirectAction { payload: IRedirect } +export interface ISetResolvedThemesAction { + type: `SET_RESOLVED_THEMES` + payload: IRedirect +} + export interface IDeleteCacheAction { type: `DELETE_CACHE` }