Add gatsby-plugin-typegen instead of codegen#266
Add gatsby-plugin-typegen instead of codegen#266orta merged 3 commits intomicrosoft:v2from item4:gatsby-plugin-typegen
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.
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.
oh. It's nice. thanks your kindness :)
|
👍 it's working so far |
|
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.