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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby): Add option to emit TS types during build #36405

Merged
merged 3 commits into from
Aug 18, 2022
Merged

Conversation

LekoArts
Copy link
Contributor

Description

The request to also have src/gatsby-types.d.ts during gatsby build has come up more and more in #35420, so this is adding an option to generate this file during gatsby build.

I'm totally open to a better name than gatsbyBuild!

Documentation

Docs were changed

@LekoArts LekoArts added the topic: TypeScript Issues and PRs related to TS in general, public typings or gatsby-plugin-typescript label Aug 17, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 17, 2022
@LekoArts LekoArts removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 17, 2022
@@ -419,6 +420,42 @@ module.exports = async function build(
await waitMaterializePageMode
const waitWorkerPoolEnd = Promise.all(workerPool.end())

// create scope so we don't leak state object
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The position of this is quite arbitrary (at the very end of the build). Any reason to not keep it there?

if (state.config.graphqlTypegen) {
telemetry.trackFeatureIsUsed(`GraphQLTypegen`)
writeGraphQLConfig(program)
// This is only run during `gatsby develop`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correcting the implementation to actually do what the comment said (this file is not needed during gatsby build)

imjoshin
imjoshin previously approved these changes Aug 17, 2022
Copy link
Contributor

@imjoshin imjoshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will defer merge until name is decided. Code looks good though!

@LekoArts LekoArts merged commit 3760a0e into master Aug 18, 2022
@LekoArts LekoArts deleted the typegen-build branch August 18, 2022 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: TypeScript Issues and PRs related to TS in general, public typings or gatsby-plugin-typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants