Gatsby: export gatsby page props typescript types

Created on 21 Sep 2018  路  12Comments  路  Source: gatsbyjs/gatsby

It would be cool if Gatsby exported some more types to make working with page props more type safe. Ideally we could import the props that gatsby passes to page components. Something like:

import * as React from "react";
import {PageProps} from 'gatsby';

export class MyPage extends React.PureComponent<PageProps, {}> {
    render() {
        return (
            this.props.location
        );
    }
}



Most helpful comment

Oh, nevermind. Appears gatsby exports PageProps which covers it? Reclosing.

All 12 comments

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.

this would be nice

i agree this would be nice. someone should reopen this and/or add the types

this still does not exist right?

Please re-open!

I went through gatsby and reach router exported types and interfaces but there is none that would cover the real type of page props, which is:

image

It would be cool to have it typed..

Try to use this type: ReplaceComponentRendererArgs['props']

Like this:

const Page: React.FC<ReplaceComponentRendererArgs['props']> = ({ location }) => {
    return (<div>{location.href}</div>)
  }
}

Agree that this would be v nice 馃憣

I don't know if this is cheeky or not but I've reopened the issue since obviously several people want this and it doesn't appear to be stale

Oh, nevermind. Appears gatsby exports PageProps which covers it? Reclosing.

@seaneking: nice find, but is this documented somewhere? I don't see it at https://www.gatsbyjs.org/docs/location-data-from-props/ for example.

AFAIK Gatsby鈥檚 typescript types aren鈥檛 documented anywhere? I just discovered it by playing around with VSCode鈥檚 intellisense importing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KyleAMathews picture KyleAMathews  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

brandonmp picture brandonmp  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

ferMartz picture ferMartz  路  3Comments