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

fix(deps): update typescript #31152

Merged
merged 5 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@types/signal-exit": "^3.0.0",
"@types/stack-trace": "^0.0.29",
"@types/webpack-merge": "^4.1.5",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.22.0",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"babel-jest": "^24.9.0",
"chalk": "^4.1.1",
"chokidar": "^3.5.1",
Expand Down Expand Up @@ -88,7 +88,7 @@
"rimraf": "^3.0.2",
"svgo": "1.3.2",
"ts-jest": "^22",
"typescript": "^4.1.5",
"typescript": "^4.3.5",
"unified": "^9.2.0",
"yargs": "^15.4.1"
},
Expand Down
1 change: 0 additions & 1 deletion packages/create-gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"string-length": "^4.0.2",
"terminal-link": "^2.1.1",
"tiny-spin": "^1.0.2",
"typescript": "^4.1.5",
"uuid": "3.4.0"
},
"repository": {
Expand Down
5 changes: 2 additions & 3 deletions packages/gatsby-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@feedback-fish/react": "^1.2.1",
"@types/react-instantsearch-dom": "^5.2.6",
"@types/socket.io-client": "^1.4.35",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"csstype": "^2.6.14",
"formik": "^2.2.6",
"gatsby": "^3.10.0-next.1",
Expand Down Expand Up @@ -45,7 +45,6 @@
"strict-ui": "^0.2.0-0",
"subscriptions-transport-ws": "^0.9.18",
"theme-ui": "^0.4.0-rc.14",
"typescript": "^4.1.5",
"urql": "^1.11.6",
"yup": "^0.32.8"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"rollup": "^2.34.2",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-internal": "^1.0.0",
"typescript": "^4.1.5"
"typescript": "^4.3.5"
},
"files": [
"lib/",
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby-cli/src/reporter/redux/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createStore, combineReducers } from "redux"
import { createStore, combineReducers, Store } from "redux"
import { reducer } from "./reducer"
import { ActionsUnion, ISetLogs } from "./types"
import { ActionsUnion, ISetLogs, IGatsbyCLIState } from "./types"
import { isInternalAction } from "./utils"
import { createStructuredLoggingDiagnosticsMiddleware } from "./diagnostics"
import { Actions } from "../constants"

let store = createStore(
let store: Store<{ logs: IGatsbyCLIState }> = createStore(
combineReducers({
logs: reducer,
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-core-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@types/ci-info": "2.0.0",
"babel-preset-gatsby-package": "^1.10.0-next.0",
"cross-env": "^7.0.3",
"typescript": "^4.1.5"
"typescript": "^4.3.5"
},
"engines": {
"node": ">=12.13.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-page-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"babel-preset-gatsby-package": "^1.10.0-next.0",
"cross-env": "^7.0.3",
"rimraf": "^3.0.2",
"typescript": "^4.1.5"
"typescript": "^4.3.5"
},
"files": [
"dist/"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"npm-run-all": "^4.1.5",
"postcss": "^8.2.9",
"terser": "^5.3.8",
"typescript": "^4.1.5"
"typescript": "^4.3.5"
},
"peerDependencies": {
"@babel/core": "^7.12.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"babel-preset-gatsby-package": "^1.10.0-next.0",
"cross-env": "^7.0.3",
"rimraf": "^3.0.2",
"typescript": "^4.1.5"
"typescript": "^4.3.5"
},
"peerDependencies": {
"gatsby": "^3.0.0-next.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-shopify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"prettier": "^2.2.1",
"prettier-check": "^2.0.0",
"tsc-watch": "^4.2.9",
"typescript": "^4.2.3"
"typescript": "^4.3.5"
},
"peerDependencies": {
"gatsby-plugin-image": "^1.1.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"jest-cli": "^24.9.0",
"jest-junit": "^6.4.0",
"rimraf": "^3.0.2",
"typescript": "^4.1.5"
"typescript": "^4.3.5"
},
"files": [
"lib/",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"babel-preset-gatsby-package": "^1.10.0-next.0",
"cross-env": "^7.0.3",
"rimraf": "^3.0.2",
"typescript": "^4.1.5"
"typescript": "^4.3.5"
},
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-worker#readme",
"keywords": [
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@nodelib/fs.walk": "^1.2.4",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
"@types/http-proxy": "^1.17.4",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"address": "1.1.2",
"anser": "^2.0.1",
"autoprefixer": "^10.2.4",
Expand Down Expand Up @@ -184,7 +184,7 @@
"react": "^16.12.0",
"react-dom": "^16.12.0",
"rimraf": "^3.0.2",
"typescript": "^4.1.5",
"typescript": "^4.3.5",
"xhr-mock": "^2.5.1",
"zipkin": "^0.22.0",
"zipkin-javascript-opentracing": "^3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby/src/bootstrap/__tests__/remove-stale-jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe(`remove-stale-jobs`, () => {

isJobStale.mockReturnValue(true)

expect(removeStaleJobs(state)).toMatchSnapshot()
expect(removeStaleJobs(state.jobsV2)).toMatchSnapshot()
expect(internalActions.removeStaleJob).toHaveBeenCalledTimes(1)
expect(internalActions.removeStaleJob).toHaveBeenCalledWith(`1234`)
expect(internalActions.createJobV2FromInternalJob).not.toHaveBeenCalled()
Expand All @@ -50,7 +50,7 @@ describe(`remove-stale-jobs`, () => {

isJobStale.mockReturnValue(true)

expect(removeStaleJobs(state)).toMatchSnapshot()
expect(removeStaleJobs(state.jobsV2)).toMatchSnapshot()
expect(internalActions.removeStaleJob).toHaveBeenCalledTimes(1)
expect(internalActions.removeStaleJob).toHaveBeenCalledWith(`1234`)
expect(internalActions.createJobV2FromInternalJob).not.toHaveBeenCalled()
Expand All @@ -72,7 +72,7 @@ describe(`remove-stale-jobs`, () => {
// we need it to return a promise so createJobV2FromInternalJob action creator works correctly
enqueueJob.mockReturnValue(Promise.resolve({ result: true }))

const toDispatch = removeStaleJobs(state)
const toDispatch = removeStaleJobs(state.jobsV2)
const dispatchedActions = []
for (const actionOrThunk of toDispatch) {
if (typeof actionOrThunk === `function`) {
Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby/src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import { globalTracer } from "opentracing"
import type { GatsbyWorkerPool } from "../utils/worker/pool"
import { handleStalePageData } from "../utils/page-data"
import { saveStateForWorkers } from "../redux"
import { IProgram } from "../commands/types"

const tracer = globalTracer()

export async function bootstrap(
initialContext: Partial<IBuildContext>
initialContext: Partial<IBuildContext> & { program: IProgram }
): Promise<{
gatsbyNodeGraphQLFunction: Runner
workerPool: GatsbyWorkerPool
Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby/src/bootstrap/load-plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from "lodash"

import { store } from "../../redux"
import { IGatsbyState } from "../../redux/types"
import * as nodeAPIs from "../../utils/api-node-docs"
import * as browserAPIs from "../../utils/api-browser-docs"
import ssrAPIs from "../../../cache-dir/api-ssr-docs"
Expand Down Expand Up @@ -122,7 +123,7 @@ export async function loadPlugins(
// If we get this far, everything looks good. Update the store
store.dispatch({
type: `SET_SITE_FLATTENED_PLUGINS`,
payload: flattenedPlugins,
payload: flattenedPlugins as IGatsbyState["flattenedPlugins"],
})

// And let plugins initialize if they want to
Expand Down
22 changes: 9 additions & 13 deletions packages/gatsby/src/bootstrap/remove-stale-jobs.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
import {
IGatsbyState,
IRemoveStaleJobAction,
IRemoveStaleJobV2Action,
ICreateJobV2FromInternalAction,
IGatsbyIncompleteJobV2,
IGatsbyCompleteJobV2,
} from "../redux/types"

import { isJobStale } from "../utils/jobs-manager"
import { internalActions } from "../redux/actions"

export const removeStaleJobs = (
state: IGatsbyState
): Array<IRemoveStaleJobAction | ICreateJobV2FromInternalAction> => {
jobs: IGatsbyState["jobsV2"]
): Array<IRemoveStaleJobV2Action | ICreateJobV2FromInternalAction> => {
const actions: Array<
IRemoveStaleJobAction | ICreateJobV2FromInternalAction
IRemoveStaleJobV2Action | ICreateJobV2FromInternalAction
> = []

// If any of our finished jobs are stale we remove them to keep our cache small
state.jobsV2.complete.forEach(
(job: IGatsbyCompleteJobV2, contentDigest: string): void => {
if (isJobStale(job)) {
actions.push(internalActions.removeStaleJob(contentDigest))
}
jobs.complete.forEach((job, contentDigest) => {
if (isJobStale(job)) {
actions.push(internalActions.removeStaleJob(contentDigest))
}
)
})

// If any of our pending jobs do not have an existing inputPath or the inputPath changed
// we remove it from the queue as they would fail anyway
state.jobsV2.incomplete.forEach(({ job }: IGatsbyIncompleteJobV2): void => {
jobs.incomplete.forEach(({ job }): void => {
if (isJobStale(job)) {
actions.push(internalActions.removeStaleJob(job.contentDigest))
} else {
Expand Down
17 changes: 10 additions & 7 deletions packages/gatsby/src/commands/build-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from "fs-extra"
import reporter from "gatsby-cli/lib/reporter"
import { createErrorFromString } from "gatsby-cli/lib/reporter/errors"
import { chunk } from "lodash"
import webpack from "webpack"
import webpack, { Stats } from "webpack"
import * as path from "path"

import { emitter, store } from "../redux"
Expand Down Expand Up @@ -59,7 +59,7 @@ const runWebpack = (
directory,
parentSpan?: Span
): Bluebird<{
stats: webpack.Stats | undefined
stats: Stats
waitForCompilerClose: Promise<void>
}> =>
new Bluebird((resolve, reject) => {
Expand Down Expand Up @@ -91,7 +91,7 @@ const runWebpack = (
if (err) {
return reject(err)
} else {
return resolve({ stats, waitForCompilerClose })
return resolve({ stats: stats as Stats, waitForCompilerClose })
}
})
} else if (
Expand Down Expand Up @@ -126,7 +126,10 @@ const runWebpack = (

oldHash = newHash

return resolve({ stats, waitForCompilerClose: Promise.resolve() })
return resolve({
stats: stats as Stats,
waitForCompilerClose: Promise.resolve(),
})
}
}
) as IWebpackWatchingPauseResume
Expand All @@ -145,17 +148,17 @@ const doBuildRenderer = async (
directory,
parentSpan
)
if (stats?.hasErrors()) {
if (stats.hasErrors()) {
reporter.panic(structureWebpackErrors(stage, stats.compilation.errors))
}

if (
stage === `build-html` &&
store.getState().html.ssrCompilationHash !== stats?.hash
store.getState().html.ssrCompilationHash !== stats.hash
) {
store.dispatch({
type: `SET_SSR_WEBPACK_COMPILATION_HASH`,
payload: stats?.hash,
payload: stats.hash as string,
})
}

Expand Down
5 changes: 4 additions & 1 deletion packages/gatsby/src/redux/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
DeepPartial,
Middleware,
ReducersMapObject,
Store,
} from "redux"
import _ from "lodash"
import telemetry from "gatsby-telemetry"
Expand Down Expand Up @@ -78,7 +79,9 @@ const multi: Middleware<IMultiDispatch> = ({ dispatch }) => next => (
// We're using the inferred type here because manually typing it would be very complicated
// and error-prone. Instead we'll make use of the createStore return value, and export that type.
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const configureStore = (initialState: IGatsbyState) =>
export const configureStore = (
initialState: IGatsbyState
): Store<IGatsbyState> =>
createStore(
combineReducers<IGatsbyState>({ ...reducers }),
initialState,
Expand Down
15 changes: 12 additions & 3 deletions packages/gatsby/src/redux/reducers/jobsv2.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {
ActionsUnion,
ICreateJobV2Action,
IRemoveStaleJobV2Action,
IEndJobV2Action,
IGatsbyState,
IGatsbyIncompleteJobV2,
IGatsbyCompleteJobV2,
IDeleteCacheAction,
} from "../types"

const initialState = (): IGatsbyState["jobsV2"] => {
Expand All @@ -14,11 +17,17 @@ const initialState = (): IGatsbyState["jobsV2"] => {

export const jobsV2Reducer = (
state = initialState(),
action: ActionsUnion
action:
| ICreateJobV2Action
| IRemoveStaleJobV2Action
| IEndJobV2Action
| IDeleteCacheAction
): IGatsbyState["jobsV2"] => {
switch (action.type) {
case `DELETE_CACHE`:
return action.cacheIsCorrupt ? initialState() : state
return (action as IDeleteCacheAction).cacheIsCorrupt
? initialState()
: state

case `CREATE_JOB_V2`: {
const { job } = action.payload
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/redux/reducers/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const initialState: IStateProgram = {
host: `localhost`,
sitePackageJson: {},
extensions: [],
browserslist: [],
report: reporter,
}

Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby/src/redux/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ type BabelStageKeys =

export interface IStateProgram extends IProgram {
extensions: Array<string>
browserslist: Array<string>
}

export interface IQueryState {
Expand Down Expand Up @@ -401,6 +402,7 @@ export type ActionsUnion =
| IGeneratedHtml
| IMarkHtmlDirty
| ISSRUsedUnsafeBuiltin
| ISetSiteConfig

export interface IApiFinishedAction {
type: `API_FINISHED`
Expand Down
Loading