Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gatsby-plugin-typegen instead of codegen #266

Merged
merged 3 commits into from Feb 19, 2020
Merged

Conversation

@item4
Copy link
Contributor

item4 commented Feb 19, 2020

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.

1. Remove codegen plugin and its generated codes.
2. Apply typegen plugin and add type of props for much components.
@item4 item4 requested a review from orta Feb 19, 2020
@msftclas

This comment has been minimized.

Copy link

msftclas commented Feb 19, 2020

CLA assistant check
All CLA requirements met.

@orta

This comment has been minimized.

Copy link
Member

orta commented Feb 19, 2020

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 gitignore then this is good to go thanks! Wooo

@orta

This comment has been minimized.

Copy link
Member

orta commented Feb 19, 2020

GitHub is having issues, I'm gonna manually merge this! Thanks!

@orta orta merged commit 49d54b1 into microsoft:v2 Feb 19, 2020
@cometkim

This comment has been minimized.

Copy link

cometkim commented Feb 19, 2020

Hey @item4 and @orta, I'm author of the plugin. I'm really happy to see that the official TypeScript webpage uses my plugins, appreciates all of your work.

The plugin is currently actively developing. so If you have any trouble to use the plugin, please give feedback.

@item4 item4 deleted the item4:gatsby-plugin-typegen branch Feb 19, 2020
}[]
}
import { SitePage } from "../__generated__/gatsby-types";
export type AllSitePage = { readonly nodes: ReadonlyArray<Pick<SitePage, 'path'>> };

This comment has been minimized.

Copy link
@orta

orta Feb 20, 2020

Member

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

This comment has been minimized.

Copy link
@item4

item4 Feb 20, 2020

Author Contributor

oh. It's nice. thanks your kindness :)

@orta

This comment has been minimized.

Copy link
Member

orta commented Feb 20, 2020

馃憤 it's working so far

@Urigo

This comment has been minimized.

Copy link

Urigo commented Feb 24, 2020

that's awesome!
We also use that plugin (we are a bit biased as it's using https://github.com/dotansimha/graphql-code-generator under the hood ;) )

@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 assume a lot of people will read it and use it as a resource!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can鈥檛 perform that action at this time.