Describe the bug
When ever I run webpack it gives me Duplicate declaration "Component" in the generated-models.tsx file
To Reproduce
Steps to reproduce the behavior:
gql-gen ...Expected behavior
Would be not to have generated-models.tsx: Duplicate declaration "Component"
Environment:
UPDATE: I also tried ts-loader instead of babel-loader & it gave me
TS2345: Argument of type '{ new (): Document; prototype: Document; }' is not assignable to parameter of type 'DocumentNode'.
Type '{ new (): Document; prototype: Document; }' is missing the following properties from type 'DocumentNode': kind, definitions
UPDATE: I got ts-loader to work & compile with another generate. Babel typescript preset doesn't support namespaces so I think that's why it doesn't work.
@dragonfire1119 im running into the same issue...
Duplicate declaration "Document"
How did you get around this? do you mind providing more details?
@harrisrobin Have you tried ts-loader with webpack? I've moved on from this awhile ago. I seem to remember it was Babel typescript problem. I went through some headaches on getting it right but it's working perfect now.
@dragonfire1119 gave up on CRA's typescript support because they don't support namespacing and reverted back to using tsc. It's a shame they don't support namespacing though! really a blocker for me because this tool is more useful than dropping tsc.
@harrisrobin You can use noNamepsaces configuration and the output will work with CRA (see https://graphql-code-generator.com/docs/integrations/create-react-app)
@harrisrobin I'm also getting Duplicate declaration "Document"
Is there anyway to solve this without turning off namespaces? I'm using next.js and babel to transpile my typescript
@seawatts Babel has said they are not going to support namespaces already https://github.com/babel/babel/issues/8244
@seawatts Babel's TypeScript support has a lot of issues like that. I recommend you to use TypeScript's own compiler which already handles JSX transpilation, and you can make a bundle with Webpack.
In the recent refactor, we removed namespaces completely, so now everyone should be able to use it without loosing the ability to use other features.
Most helpful comment
@dragonfire1119 im running into the same issue...
Duplicate declaration "Document"How did you get around this? do you mind providing more details?