dotansimha / dotansimha/graphql-code-generator

declarationKind: 'class' raises TS2449 error due to alphabetical sorting

Open
#9,232 2 comments 0 reactions 0 assignees View on GitHub
kind/bug stage/1-reproduction
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### 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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.