Skip to content

Commit

Permalink
chore(gatsby): migrate schema reducer to TypeScript
Browse files Browse the repository at this point in the history
This commit implements the migration of the schema reducer to
TypeScript by adding the SET_SCHEMA action to the ActionsUnion and
by adding the basic types from the IGatsbyState.
  • Loading branch information
hiwelo committed Apr 29, 2020
1 parent d41ce6f commit b8e03b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/gatsby/src/redux/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const reduxNodes = require(`./nodes`)
const lokiNodes = require(`../../db/loki/nodes`).reducer
import { redirectsReducer } from "./redirects"
import { schemaReducer } from "./schema"
import { staticQueryComponentsReducer } from "./static-query-components"
import { statusReducer } from "./status"
import { webpackReducer } from "./webpack"
Expand Down Expand Up @@ -56,7 +57,7 @@ module.exports = {
flattenedPlugins: require(`./flattened-plugins`),
config: require(`./config`),
pages: require(`./pages`),
schema: require(`./schema`),
schema: schemaReducer,
status: statusReducer,
componentDataDependencies: require(`./component-data-dependencies`),
components: require(`./components`),
Expand Down
8 changes: 0 additions & 8 deletions packages/gatsby/src/redux/reducers/schema.js

This file was deleted.

13 changes: 13 additions & 0 deletions packages/gatsby/src/redux/reducers/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ActionsUnion, IGatsbyState } from "../types"

export const schemaReducer = (
state: IGatsbyState["schema"] | {} = {},
action: ActionsUnion
): IGatsbyState["schema"] | {} => {
switch (action.type) {
case `SET_SCHEMA`:
return action.payload
default:
return state
}
}
6 changes: 6 additions & 0 deletions packages/gatsby/src/redux/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export type ActionsUnion =
| IReplaceWebpackConfigAction
| ISetPluginStatusAction
| ISetProgramStatusAction
| ISetSchemaAction
| ISetWebpackCompilationHashAction
| ISetWebpackConfigAction
| IUpdatePluginsHashAction
Expand Down Expand Up @@ -411,3 +412,8 @@ export interface ISetWebpackConfigAction {
type: `SET_WEBPACK_CONFIG`
payload: Partial<IGatsbyState["webpack"]>
}

export interface ISetSchemaAction {
type: `SET_SCHEMA`
payload: IGatsbyState["schema"]
}

0 comments on commit b8e03b7

Please sign in to comment.