Skip to content

Commit b8f3ed5

Browse files
d4rekanguokfreiksenet
authored andcommitted
fix(gatsby): various Typescript definitions (#15268)
* fix touchNode def * update createRedirect typings * [gatsby-source-filesystem] fix cache definition in CreateRemoteFileNodeArgs * [gatsby-source-filesystem] add definitions for createFileNodeFromBuffer
1 parent d93e478 commit b8f3ed5

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

packages/gatsby-source-filesystem/index.d.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ export function createRemoteFileNode(
1212
args: CreateRemoteFileNodeArgs
1313
): Promise<FileSystemNode>
1414

15+
/**
16+
* @see https://www.gatsbyjs.org/packages/gatsby-source-filesystem/?=files#createfilenodefrombuffer
17+
*/
18+
export function createFileNodeFromBuffer(
19+
args: CreateFileNodeFromBufferArgs
20+
): Promise<FileSystemNode>
21+
1522
export interface CreateFilePathArgs {
1623
node: Node
1724
getNode: Function
@@ -22,7 +29,7 @@ export interface CreateFilePathArgs {
2229
export interface CreateRemoteFileNodeArgs {
2330
url: string
2431
store: Store
25-
cache: Cache
32+
cache: Cache["cache"]
2633
createNode: Function
2734
createNodeId: Function
2835
parentNodeId?: string
@@ -36,6 +43,18 @@ export interface CreateRemoteFileNodeArgs {
3643
reporter: object
3744
}
3845

46+
export interface CreateFileNodeFromBufferArgs {
47+
buffer: Buffer
48+
store: Store
49+
cache: Cache["cache"]
50+
createNode: Function
51+
createNodeId: Function
52+
parentNodeId?: string
53+
hash?: string
54+
ext?: string
55+
name?: string
56+
}
57+
3958
export interface FileSystemNode extends Node {
4059
absolutePath: string
4160
accessTime: string

packages/gatsby/index.d.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ export interface Actions {
798798
createNode(node: Node, plugin?: ActionPlugin, options?: ActionOptions): void
799799

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

803803
/** @see https://www.gatsbyjs.org/docs/actions/#createNodeField */
804804
createNodeField(
@@ -862,11 +862,12 @@ export interface Actions {
862862
createRedirect(
863863
redirect: {
864864
fromPath: string
865-
isPermanent: boolean
865+
isPermanent?: boolean
866866
toPath: string
867-
redirectInBrowser: boolean
868-
force: boolean
869-
statusCode: number
867+
redirectInBrowser?: boolean
868+
force?: boolean
869+
statusCode?: number
870+
[key: string]: unknown
870871
},
871872
plugin?: ActionPlugin
872873
): void

0 commit comments

Comments
 (0)