graphql-code-generator
graphql-code-generator copied to clipboard
declarationKind: 'class' raises TS2449 error due to alphabetical sorting
Which packages are impacted by your issue?
No response
Describe the bug
Using declarationKind: 'class' config generates erroneous file - TS2449 error (Class '_' used before its declaration) due to alphabetical sorting
Your Example Website or App
https://stackblitz.com/edit/github-jfympc?file=schema.ts
Steps to Reproduce the Bug or Issue
use the attached config with this schema:
type AClass implements BClass {
id: ID
}
interface BClass {
id: ID
}
and generate
Expected behavior
Base classes to be defined before their extensions
Screenshots or Videos
No response
Platform
- NodeJS: 18.14.0
- @graphql-codegen/typescript: 3.0.2
- typescript: 4.9.5
Codegen Config File
{
overwrite: true,
schema: 'src/schema.graphql',
'src/schema.ts': {
config: {
declarationKind: 'class',
namingConvention: 'keep',
},
plugins: ['typescript'],
},
}
Additional context
No response
workaround:
declarationKind: {
type: 'class',
input: 'class',
interface: 'interface',
},
workaround:
declarationKind: { type: 'class', input: 'class', interface: 'interface', },
it doesn't work for me >>
const config: CodegenConfig = {
overwrite: true,
schema: './src/**/*.graphql',
watch: true,
generates: {
'src/graphql.ts': {
plugins: ['typescript'],
config: {
declarationKind: {
type: 'class',
input: 'class',
interface: 'interface',
},
emitTypenameField: true,
defaultScalarType: 'unknown',
},
},
},
}