Open ryanliljestrom opened 1 year ago
No response
When generating types with enumsAsConst: true enabled, it can generate invalid types if the graphql enum starts with an underscore and digit digit, e.g. _401K. The generated type looks like:
enumsAsConst: true
_401K
export const SomeType = { 401K: '_401K', Other: 'Other' }
This does not compile. I would expect it to generate an enum like:
export const SomeType = { '401K': '_401K', Other: 'Other' }
.
enum SomeType { _401K Other }
Get the following generated type:
export const SomeType = { 401K: '_401K', Other: 'Other' } as const
, which is invalid TypeScript
It would generate something that looks like
export const SomeType = { '401K': '_401K', Other: 'Other' } as const
macOS, node 16.18.1
extensions: codegen: generates: ./src/generated/types.ts:
I think on this line there needs to be a call to this.makeValidEnumIdentifier
this.makeValidEnumIdentifier
Fixed with @graphql-codegen/typescript-operations@3.0.3
@graphql-codegen/typescript-operations@3.0.3
Which packages are impacted by your issue?
No response
Describe the bug
When generating types with
enumsAsConst: true
enabled, it can generate invalid types if the graphql enum starts with an underscore and digit digit, e.g._401K
. The generated type looks like:This does not compile. I would expect it to generate an enum like:
Your Example Website or App
.
Steps to Reproduce the Bug or Issue
Get the following generated type:
, which is invalid TypeScript
Expected behavior
It would generate something that looks like
Screenshots or Videos
No response
Platform
macOS, node 16.18.1
Codegen Config File
extensions: codegen: generates: ./src/generated/types.ts:
Additional context
I think on this line there needs to be a call to
this.makeValidEnumIdentifier