Skip to content

Commit

Permalink
migrate reducers/themes to TypeScript (#23716)
Browse files Browse the repository at this point in the history
Co-authored-by: tae <taeshindefv@gmailcom>
  • Loading branch information
taejs and tae authored May 4, 2020
1 parent 80e8f8b commit 2a586c9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion packages/gatsby/src/redux/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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`),
Expand Down
12 changes: 0 additions & 12 deletions packages/gatsby/src/redux/reducers/themes.js

This file was deleted.

17 changes: 17 additions & 0 deletions packages/gatsby/src/redux/reducers/themes.ts
Original file line number Diff line number Diff line change
@@ -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
}
}
5 changes: 5 additions & 0 deletions packages/gatsby/src/redux/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ export interface ICreateRedirectAction {
payload: IRedirect
}

export interface ISetResolvedThemesAction {
type: `SET_RESOLVED_THEMES`
payload: IRedirect
}

export interface IDeleteCacheAction {
type: `DELETE_CACHE`
}
Expand Down

0 comments on commit 2a586c9

Please sign in to comment.