remorses / genql

Type safe TypeScript client for any GraphQL API
https://genql.dev
MIT License
872 stars 37 forks source link

bug: Exported type alias 'Headers' has or is using private name 'HeadersInit' #137

Closed seawatts closed 1 year ago

seawatts commented 1 year ago

When generating a genql client with the CLI

npx @genql/cli --sort --output ./src/genql --schema ./schema.graphql --esm

The file genql/runtime/createClient.ts creates a type called Headers

export type Headers =
    | HeadersInit
    | (() => HeadersInit)
    | (() => Promise<HeadersInit>)

When running tsc on this file, I get the following error:

Exported type alias 'Headers' has or is using private name 'HeadersInit'

It looks like the code is being generated here: https://github.com/remorses/genql/blob/8c02b9c01ce6d64b900940344b248b18f3d2cc8c/cli/src/runtime/createClient.ts#L9

I believe the fix would be to create a new type for HeadersInit. I'm not sure what the type should be which is why I haven't created a PR.

Let me know how I can help here.

remorses commented 1 year ago

Can you try adding @types/node or dom in your taconfig.json types?

seawatts commented 1 year ago

Do you have an example of the tsconfig.json file that includes those? I can't seem to get it working.

remorses commented 1 year ago

Example tsconfig:

{
  "compilerOptions": {

    "lib": ["dom"],
// ...
seawatts commented 1 year ago

That worked! Thank you so much. 🙂