Skip to content

Commit 7edf731

Browse files
cometkimGatsbyJS Bot
authored and
GatsbyJS Bot
committed
chore(gatsby): Add type arguments to <StaticQuery/> to infer prop types (#17491)
* Add type arguments to <StaticQuery/> to infer prop types * Remove duplicated typeDef * fix lint
1 parent 99041cc commit 7edf731

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

packages/gatsby/index.d.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ export {
1414
withAssetPrefix,
1515
} from "gatsby-link"
1616

17-
export interface StaticQueryProps {
18-
query: any
19-
render?: RenderCallback
20-
children?: RenderCallback
21-
}
22-
2317
export const useStaticQuery: <TData = any>(query: any) => TData
2418

2519
export const parsePath: (path: string) => WindowLocation
@@ -40,12 +34,12 @@ export interface PageRendererProps {
4034
*/
4135
export class PageRenderer extends React.Component<PageRendererProps> {}
4236

43-
type RenderCallback = (data: any) => React.ReactNode
37+
type RenderCallback<T = any> = (data: T) => React.ReactNode
4438

45-
export interface StaticQueryProps {
39+
export interface StaticQueryProps<T = any> {
4640
query: any
47-
render?: RenderCallback
48-
children?: RenderCallback
41+
render?: RenderCallback<T>
42+
children?: RenderCallback<T>
4943
}
5044

5145
/**
@@ -58,7 +52,9 @@ export interface StaticQueryProps {
5852
* @see https://www.gatsbyjs.org/docs/static-query/
5953
*/
6054

61-
export class StaticQuery extends React.Component<StaticQueryProps> {}
55+
export class StaticQuery<T = any> extends React.Component<
56+
StaticQueryProps<T>
57+
> {}
6258

6359
/**
6460
* graphql is a tag function. Behind the scenes Gatsby handles these tags in a particular way

0 commit comments

Comments
 (0)