Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Fix legacy GCG generated Variables types #3029

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/dry-islands-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@urql/core': patch
---

Fix generated empty `Variables` type as passed to generics, that outputs a type of `{ [var: string]: never; }`.
A legacy/unsupported version of `typescript-urql`, which wraps `urql`'s React hooks, generates
empty variables types as the following code snippet, which is not detected:

```ts
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
type Variables = Exact<{ [key: string]: never }>;
```
10 changes: 8 additions & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,15 @@ export type GraphQLRequestParams<
: Variables extends {
[P in keyof Variables]: Exclude<Variables[P], null | void>;
}
? {
variables: Variables;
? Variables extends {
[P in keyof Variables]: never;
}
? {
variables?: Variables;
}
: {
variables: Variables;
}
: {
variables?: Variables;
}))
Expand Down