-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add special handling for identifiers which consist entirely of _ characters when transformUnderscore is true to emit valid Typescript syntax #10412
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
base: master
Are you sure you want to change the base?
Conversation
…we are asked to remove underscores. Added a test for this behaviour as well.
🦋 Changeset detectedLatest commit: 2b74089 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
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 |
Hi @thekevinbrown, One thought I have is If we see this needs to be applied across the board, we could consider your proposed implementation. Here's how we scope it to just enum options: |
No worries, will update this to be scoped to just that case. |
… _ when we are asked to remove underscores. Added a test for this behaviour as well." This reverts commit 3765f2a.
Alrighty @eddeee888, I believe that's what you were after. Let me know if not! |
transformUnderscore: true, | ||
// We can only strip out the underscores if the value contains other | ||
// characters. Otherwise we'll generate syntactically invalid code. | ||
transformUnderscore: !onlyUnderscoresPattern.test(enumOption.name as any), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious shouldn't this be enumOption.name.value
? 🙂
We've recently fixed NameNode
overrides which shouldn't require as any
any more.
Add special handling for identifiers that consist entirely of
_
when we are asked to remove underscores. Added a test for this behaviour as well.Description
Our GraphQL schema includes an enum which has
_
as a value. This currently results in invalid syntax in the generated types file.Related # (issue): #10411
Type of change
Please delete options that are not relevant.
Screenshots/Sandbox (if appropriate/relevant):
Code Sandbox
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
transformUnderscore: true,
and the passed in strings consist entirely of_
characters.Test Environment:
Jest, CI
Checklist:
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...