Skip to content

Commit cddc252

Browse files
pajosiegserhalp
andauthored
fix(gatsby-link): fix navigate method type
* Fixes type of navigate method The usage of the original navigation function type created problems when using spreaded parameters. Since the navigate implementation in gatsby does not have the same call signature as @reach/router anyways (the promise returned by @reach/router is ignored), it is easier to define our own interface than to overwrite the types from @reach/router. * Replace interface and define parameter overloading inline; --------- Co-authored-by: Philippe Serhal <[email protected]>
1 parent 75e0dd6 commit cddc252

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/gatsby-link/index.d.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react"
2-
import { NavigateFn, LinkProps } from "@reach/router" // These come from `@types/reach__router`
2+
import { NavigateOptions, LinkProps } from "@reach/router" // These come from `@types/reach__router`
33

44
// eslint-disable-next-line @typescript-eslint/naming-convention
55
export interface GatsbyLinkProps<TState> extends LinkProps<TState> {
@@ -33,7 +33,10 @@ export class Link<TState> extends React.Component<
3333
* Sometimes you need to navigate to pages programmatically, such as during form submissions. In these
3434
* cases, `Link` won’t work.
3535
*/
36-
export const navigate: (...args: Parameters<NavigateFn>) => void;
36+
export const navigate: {
37+
(to: string, options?: NavigateOptions<{}>): void
38+
(to: number): void
39+
}
3740

3841
/**
3942
* It is common to host sites in a sub-directory of a site. Gatsby lets you set the path prefix for your site.

0 commit comments

Comments
 (0)