Skip to content

Commit

Permalink
fix(gatsby): various Typescript definitions (#15268)
Browse files Browse the repository at this point in the history
* fix touchNode def

* update createRedirect typings

* [gatsby-source-filesystem] fix cache definition in CreateRemoteFileNodeArgs

* [gatsby-source-filesystem] add definitions for createFileNodeFromBuffer
  • Loading branch information
d4rekanguok authored and freiksenet committed Jul 2, 2019
1 parent d93e478 commit b8f3ed5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
21 changes: 20 additions & 1 deletion packages/gatsby-source-filesystem/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ export function createRemoteFileNode(
args: CreateRemoteFileNodeArgs
): Promise<FileSystemNode>

/**
* @see https://www.gatsbyjs.org/packages/gatsby-source-filesystem/?=files#createfilenodefrombuffer
*/
export function createFileNodeFromBuffer(
args: CreateFileNodeFromBufferArgs
): Promise<FileSystemNode>

export interface CreateFilePathArgs {
node: Node
getNode: Function
Expand All @@ -22,7 +29,7 @@ export interface CreateFilePathArgs {
export interface CreateRemoteFileNodeArgs {
url: string
store: Store
cache: Cache
cache: Cache["cache"]
createNode: Function
createNodeId: Function
parentNodeId?: string
Expand All @@ -36,6 +43,18 @@ export interface CreateRemoteFileNodeArgs {
reporter: object
}

export interface CreateFileNodeFromBufferArgs {
buffer: Buffer
store: Store
cache: Cache["cache"]
createNode: Function
createNodeId: Function
parentNodeId?: string
hash?: string
ext?: string
name?: string
}

export interface FileSystemNode extends Node {
absolutePath: string
accessTime: string
Expand Down
11 changes: 6 additions & 5 deletions packages/gatsby/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ export interface Actions {
createNode(node: Node, plugin?: ActionPlugin, options?: ActionOptions): void

/** @see https://www.gatsbyjs.org/docs/actions/#touchNode */
touchNode(node: { nodeId: string; plugin?: ActionPlugin }): void
touchNode(node: { nodeId: string }, plugin?: ActionPlugin): void

/** @see https://www.gatsbyjs.org/docs/actions/#createNodeField */
createNodeField(
Expand Down Expand Up @@ -862,11 +862,12 @@ export interface Actions {
createRedirect(
redirect: {
fromPath: string
isPermanent: boolean
isPermanent?: boolean
toPath: string
redirectInBrowser: boolean
force: boolean
statusCode: number
redirectInBrowser?: boolean
force?: boolean
statusCode?: number
[key: string]: unknown
},
plugin?: ActionPlugin
): void
Expand Down

0 comments on commit b8f3ed5

Please sign in to comment.