Skip to content

Commit

Permalink
fix(gatsby): fix onCreatePage typings (#20871)
Browse files Browse the repository at this point in the history
  • Loading branch information
cainlevy authored Jan 31, 2020
1 parent 1f0793c commit 26e0cbc
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/gatsby/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ export interface GatsbyNode {
* See the guide [Creating and Modifying Pages](https://www.gatsbyjs.org/docs/creating-and-modifying-pages/)
* for more on this API.
*/
onCreatePage?<TNode extends object = {}>(
args: CreatePageArgs<TNode>,
onCreatePage?<TContext = Record<string, unknown>>(
args: CreatePageArgs<TContext>,
options?: PluginOptions,
callback?: PluginCallback
): void
Expand Down Expand Up @@ -671,9 +671,9 @@ export interface CreateNodeArgs<TNode extends object = {}>
}
}

export interface CreatePageArgs<TNode extends object = {}>
export interface CreatePageArgs<TContext = Record<string, unknown>>
extends ParentSpanPluginArgs {
page: Node & TNode
page: Page<TContext>
traceId: string
}

Expand Down Expand Up @@ -878,12 +878,7 @@ export interface Actions {

/** @see https://www.gatsbyjs.org/docs/actions/#createPage */
createPage<TContext = Record<string, unknown>>(
args: {
path: string
matchPath?: string
component: string
context: TContext
},
args: Page<TContext>,
plugin?: ActionPlugin,
option?: ActionOptions
): void
Expand Down Expand Up @@ -1284,3 +1279,10 @@ export interface Node extends NodeInput {
}
[key: string]: unknown
}

export interface Page<TContext = Record<string, unknown>> {
path: string
matchPath?: string
component: string
context: TContext
}

0 comments on commit 26e0cbc

Please sign in to comment.