Skip to content

Commit 98e5b4b

Browse files
authored
chore(gatsby): add types for SliceComponentProps, rename SliceProps to SlicePlaceholderProps, add jsdocs for those types (#36786)
1 parent 5c173d2 commit 98e5b4b

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

patches/v5/4-slices-api.patch

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/packages/gatsby/cache-dir/gatsby-browser-entry.js b/packages/gatsby/cache-dir/gatsby-browser-entry.js
2-
index 9e0f1205bf..f0a7dcb841 100644
2+
index c2bfd3e2b7..65218f2784 100644
33
--- a/packages/gatsby/cache-dir/gatsby-browser-entry.js
44
+++ b/packages/gatsby/cache-dir/gatsby-browser-entry.js
55
@@ -23,4 +23,5 @@ export {
@@ -9,10 +9,10 @@ index 9e0f1205bf..f0a7dcb841 100644
99
+export { Slice } from "./slice"
1010
export * from "gatsby-script"
1111
diff --git a/packages/gatsby/index.d.ts b/packages/gatsby/index.d.ts
12-
index db2b6a78c1..f0e7745e01 100644
12+
index 57c92929c1..c3dea75e6b 100644
1313
--- a/packages/gatsby/index.d.ts
1414
+++ b/packages/gatsby/index.d.ts
15-
@@ -182,6 +182,30 @@ export type HeadFC<DataType = object, PageContextType = object> = (
15+
@@ -182,6 +182,47 @@ export type HeadFC<DataType = object, PageContextType = object> = (
1616
props: HeadProps<DataType, PageContextType>
1717
) => JSX.Element
1818

@@ -29,21 +29,38 @@ index db2b6a78c1..f0e7745e01 100644
2929
+ [key: string]: SerializableProps
3030
+}
3131
+
32-
+export interface SliceProps {
32+
+/**
33+
+ * A props object for [slice placholder](https://v5.gatsbyjs.com/docs/reference/built-in-components/gatsby-slice/)
34+
+ */
35+
+export interface SlicePlaceholderProps {
3336
+ alias: string
3437
+ allowEmpty?: boolean
38+
+ children?: React.ReactNode
3539
+ [key: string]: SerializableProps
3640
+}
3741
+
3842
+/**
39-
+ * TODO
43+
+ * Component used as a slice placholder, to mark a place in the page where a [slice](https://v5.gatsbyjs.com/docs/reference/built-in-components/gatsby-slice/) should be inserted.
44+
+ */
45+
+export declare function Slice(props: SlicePlaceholderProps): JSX.Element
46+
+
47+
+/**
48+
+ * A props object for [slice component](https://v5.gatsbyjs.com/docs/reference/built-in-components/gatsby-slice/)
4049
+ */
41-
+export const Slice = (props: SliceProps) => JSX.Element
50+
+export type SliceComponentProps<
51+
+ DataType = object,
52+
+ SliceContextType = object,
53+
+ AdditionalSerializableProps extends ISerializableObject = object
54+
+> = {
55+
+ data: DataType
56+
+ sliceContext: SliceContextType
57+
+ children?: React.ReactNode
58+
+} & AdditionalSerializableProps
4259
+
4360
/**
4461
* Props object passed into the [getServerData](https://www.gatsbyjs.com/docs/reference/rendering-options/server-side-rendering/) function.
4562
*/
46-
@@ -1207,6 +1231,14 @@ export interface Actions {
63+
@@ -1227,6 +1268,14 @@ export interface Actions {
4764
option?: ActionOptions
4865
): void
4966

@@ -58,7 +75,7 @@ index db2b6a78c1..f0e7745e01 100644
5875
/** @see https://www.gatsbyjs.com/docs/actions/#deleteNode */
5976
deleteNode(node: NodeInput, plugin?: ActionPlugin): void
6077

61-
@@ -1642,6 +1674,13 @@ export interface Page<TContext = Record<string, unknown>> {
78+
@@ -1662,6 +1711,13 @@ export interface Page<TContext = Record<string, unknown>> {
6279
context?: TContext
6380
ownerNodeId?: string
6481
defer?: boolean

0 commit comments

Comments
 (0)