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

[typescript-resolvers] Add _ prefix to generated RefType as it is sometimes unused #9944

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

eddeee888
Copy link
Collaborator

@eddeee888 eddeee888 commented Apr 25, 2024

Description

RefType in ResolversInterfaceTypes and ResolversUnionTypes are unused if the possible types do not refer to other abstract types.

This is an issue for codebases using noUnusedLocals: true and/or noUnusedParameters: true compiler options in their tsconfig.json because it'd throw TypeScript error:

TypeScript error TS6133: 'RefType' is declared but its value is never read

This PR prefixes _ to RefType to signal that it might not be used. We do this even when RefType is not used so the generated type has a consistent signature for all cases

Related #9584

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit test

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Copy link

changeset-bot bot commented Apr 25, 2024

🦋 Changeset detected

Latest commit: 1ac284a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@graphql-codegen/visitor-plugin-common Patch
@graphql-codegen/typescript-resolvers Patch
@graphql-codegen/typescript-document-nodes Patch
@graphql-codegen/gql-tag-operations Patch
@graphql-codegen/typescript-operations Patch
@graphql-codegen/typed-document-node Patch
@graphql-codegen/typescript Patch
@graphql-codegen/graphql-modules-preset Patch
@graphql-codegen/client-preset Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Apr 25, 2024

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/visitor-plugin-common 5.1.1-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 4.0.7-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 4.0.7-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 4.2.1-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 4.0.7-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 5.0.7-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 4.0.7-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 4.2.6-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 4.0.7-alpha-20240425115511-1ac284ac51b27d312ef3f9922218f228a3b468e3 npm ↗︎ unpkg ↗︎

Copy link
Contributor

💻 Website Preview

The latest changes are available as preview in: https://c583db3e.graphql-code-generator.pages.dev

@saihaj saihaj merged commit 156cc2b into master Apr 25, 2024
19 checks passed
@saihaj saihaj deleted the make-typeref-optional branch April 25, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants