Repository: gatsbyjs/gatsby
File: packages/gatsby/index.d.ts (TypeScript)

Code before:

export const useScrollRestoration: (
  key: string
) => {
  ref: React.MutableRefObject<HTMLElement | undefined>
  onScroll(): void
}

export const useStaticQuery: <TData = any>(query: any) => TData

export const parsePath: (path: string) => WindowLocation

export const prefetchPathname: (path: string) => void

/**
 * A props object for adding type safety to your Gatsby pages, can be
 * extended with both the query response shape, and the page context.
 *
 * @example
 * // When typing a default page from the ./pages dir
 *
 * import {PageProps} from "gatsby"
 * export default (props: PageProps) => {
 *
 * @example
 * // When adding types for both pageContext (represended by LocaleLookUpInfo)
 * // and GraphQL query data (represented by IndexQueryProps)
 *
 * import {PageProps} from "gatsby"
 *
 * type IndexQueryProps = { downloadCount: number }
 * type LocaleLookUpInfo = { translationStrings: any } & { langKey: string, slug: string }
 * type IndexPageProps = PageProps<IndexQueryProps, LocaleLookUpInfo>
 *
 * export default (props: IndexPageProps) => {
 *   ..
 */
export type PageProps<
  DataType = object,
  PageContextType = object,
  LocationState = WindowLocation["state"]
> = {
  /** The path for this current page */
  path: string
  /** The URI for the current page */
  uri: string
  /** An extended version of window.document which comes from @react/router */
  location: WindowLocation<LocationState>
  /** A way to handle programmatically controlling navigation */
  navigate: NavigateFn
  /** You can't get passed children as this is the root user-land component */

Review comment (suggestion):
```suggestion
 * // When adding types for both pageContext (represented by LocaleLookUpInfo)
```

Might as well fix a typo while we're in here.

Code after:

export const useScrollRestoration: (
  key: string
) => {
  ref: React.MutableRefObject<HTMLElement | undefined>
  onScroll(): void
}

export const useStaticQuery: <TData = any>(query: any) => TData

export const parsePath: (path: string) => WindowLocation

export const prefetchPathname: (path: string) => void

/**
 * A props object for adding type safety to your Gatsby pages, can be
 * extended with both the query response shape, and the page context.
 *
 * @example
 * // When typing a default page from the ./pages dir
 *
 * import {PageProps} from "gatsby"
 * export default (props: PageProps) => {
 *
 * @example
 * // When adding types for both pageContext (represented by LocaleLookUpInfo)
 * // and GraphQL query data (represented by IndexQueryProps)
 *
 * import {PageProps} from "gatsby"
 *
 * type IndexQueryProps = { downloadCount: number }
 * type LocaleLookUpInfo = { translationStrings: any } & { langKey: string, slug: string }
 * type IndexPageProps = PageProps<IndexQueryProps, LocaleLookUpInfo>
 *
 * export default (props: IndexPageProps) => {
 *   ..
 */
export type PageProps<
  DataType = object,
  PageContextType = object,
  LocationState = WindowLocation["state"]
> = {
  /** The path for this current page */
  path: string
  /** The URI for the current page */
  uri: string
  /** An extended version of window.document which comes from @react/router */
  location: WindowLocation<LocationState>
  /** A way to handle programmatically controlling navigation */
  navigate: NavigateFn
  /** You can't get passed children as this is the root user-land component */