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

Skip importing export types in TS #4754

Closed
wants to merge 3 commits into from
Closed

Conversation

drewatk
Copy link
Contributor

@drewatk drewatk commented Jul 31, 2024

A fix for a typescript generation bug discovered from the work in #4753, with efforts to enable checking for all TS generated files #4745

This fixes a class of Typescript errors in generated typescript files with TS checking enabled:

/src/__generated__/mutation.graphql.ts(11,27): error TS2305: Module '"relay-runtime"' has no exported member 'Mutation'.
/src/__generated__/mutation.graphql.ts(11,27): error TS6133: 'Mutation' is declared but its value is never read.

The root cause is the exported type is both not exported by the TS types, and not used due to typescript using the export default syntax.
Where flow would generate the following export:

module.exports = ((node/*: any*/)/*: Mutation<
  validateMutationTest9ChangeNameIncludeMutation$variables,
  validateMutationTest9ChangeNameIncludeMutation$data,
>*/);

Typescript would generate the following, not using the Mutation type:

export default node;

This fix removes the extraneous import type when the language is set as typescript.

@facebook-github-bot
Copy link
Contributor

Hi @drewatk!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link
Contributor

@captbaritone captbaritone left a comment

Choose a reason for hiding this comment

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

Looks very sensible! Just one tiny nit

@captbaritone
Copy link
Contributor

Looks good! Happy to import/merge once the CLA is signed.

@facebook-github-bot
Copy link
Contributor

@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@drewatk
Copy link
Contributor Author

drewatk commented Aug 7, 2024

Can this be merged @captbaritone ?

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 0f49c2e.

@captbaritone
Copy link
Contributor

@drewatk Thanks for the ping. Merged. We are still working on some issues with our CI which means we are not currently cutting our @main NPM releases relay-compiler@main. Were you depending upon using those releases to validate this change at Microsoft? If so, let me know and I can try to find a way to get a release here.

@alloy
Copy link
Contributor

alloy commented Aug 9, 2024

@drewatk We should really consider adding some tests for the TS typings that get emitted.

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

Successfully merging this pull request may close these issues.

4 participants