Describe the bug
When inline fragments are used in unions with common __typename invalid TypeScript code is generated.
Ex.
query TopMenu {
menuItems(where: { location: TOP_MENU }) {
edges {
node {
connectedObject {
__typename
... on Page {
title
}
... on Post {
title
}
}
}
}
}
}
with config
generates:
types.ts:
- typescript-client:
noNamespaces: true
Generates
export type TopMenuConnectedObject = {
__typename: TopMenuPageInlineFragment["__typename"] | TopMenuPostInlineFragment["__typename"];
} (TopMenuPageInlineFragment | TopMenuPostInlineFragment
Which is not syntactically valid TypeScript.
Error from prettier:

To Reproduce
I've created a repository demonstrating this:
git clone https://github.com/epeli/graphql-codegen-typescript-bug
cd graphql-codegen-typescript-bug/
npm ci
npm run codegen
npm test
Expected behavior
No really sure what should be generated here...
Schema/Documents
It's all in the repository
Environment:
Thanks @epeli
We are currently working on a big refactor that will solve all these mis-matches and issues (https://github.com/dotansimha/graphql-code-generator/pull/1353).
We hope to release a beta version in a day or two.
Fixed in the recent refactor :)
Fix available in 1.0.0 馃憤
Yay, thank you!