Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gatsby): convert components to typescript #24045

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const normalize = require(`normalize-path`)
const { interpret } = require(`xstate`)
import normalize from "normalize-path"
import { interpret } from "xstate"

import { componentMachine } from "../machines/page-component"
import { IGatsbyState, ActionsUnion } from "../types"

const services = new Map()
let programStatus = `BOOTSTRAPPING`

module.exports = (state = new Map(), action) => {
export const componentsReducer = (
state: IGatsbyState["components"] = new Map(),
action: ActionsUnion
): IGatsbyState["components"] => {
switch (action.type) {
case `DELETE_CACHE`:
return new Map()
Expand Down
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 @@ -12,6 +12,7 @@ import { webpackCompilationHashReducer } from "./webpack-compilation-hash"
import { reducer as logReducer } from "gatsby-cli/lib/reporter/redux/reducer"
import { lastAction } from "./last-action"
import { jobsV2Reducer } from "./jobsv2"
import { componentsReducer } from "./components"

/**
* @property exports.nodesTouched Set<string>
Expand All @@ -29,7 +30,7 @@ module.exports = {
pages: pagesReducer,
status: statusReducer,
componentDataDependencies: require(`./component-data-dependencies`),
components: require(`./components`),
components: componentsReducer,
staticQueryComponents: staticQueryComponentsReducer,
jobs: require(`./jobs`),
jobsV2: jobsV2Reducer,
Expand Down
9 changes: 9 additions & 0 deletions packages/gatsby/src/redux/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export type ActionsUnion =
| ICreateJobV2Action
| IEndJobV2Action
| IRemoveStaleJobV2Action
| IRemoveTemplateComponentAction

export interface ICreateJobV2Action {
type: `CREATE_JOB_V2`
Expand Down Expand Up @@ -419,6 +420,7 @@ export interface ICreatePageAction {
type: `CREATE_PAGE`
payload: IGatsbyPage
plugin?: IGatsbyPlugin
contextModified?: boolean
}

export interface ICreateRedirectAction {
Expand Down Expand Up @@ -450,6 +452,13 @@ export interface ISetPageDataAction {
}
}

export interface IRemoveTemplateComponentAction {
type: `REMOVE_TEMPLATE_COMPONENT`
payload: {
componentPath: string
}
}

export interface IDeletePageAction {
type: `DELETE_PAGE`
payload: IGatsbyPage
Expand Down