New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gatsby-plugin-typegen instead of codegen #266
Conversation
1. Remove codegen plugin and its generated codes. 2. Apply typegen plugin and add type of props for much components.
Ha nice, I only removed it a day or two ago because I introduced the shared fragments and the old one couldn't handle it! If you can add the generated types to |
GitHub is having issues, I'm gonna manually merge this! Thanks! |
}[] | ||
} | ||
import { SitePage } from "../__generated__/gatsby-types"; | ||
export type AllSitePage = { readonly nodes: ReadonlyArray<Pick<SitePage, 'path'>> }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed this to:
import { AllSitePageFragment } from "../__generated__/gatsby-types";
export type AllSitePage = AllSitePageFragment["allSitePage"];
in case you don't know about the type accessor feature in TS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. It's nice. thanks your kindness :)
|
that's awesome! @orta if you think this is good, I think it would be a good idea to update your amazing blog post on Gatsby and Typescript. |
I think website of TypeScript must be type-safe, right?😱
But, there is few type definition only.
Almost props of components use
(props: any)
.So... I make type definition file automatically with gatsby-plugin-typegen.
This plugin support autogenerated type-def file with gatsby together.
Please read this PR and consider merge.