From 76b4e188eed4d6c2a84af928865e8d29743bde24 Mon Sep 17 00:00:00 2001 From: Markus Schulte Date: Mon, 29 Jun 2026 17:26:14 +0200 Subject: [PATCH] fix(typescript): derive context `enabled` from UseQueryOptions TanStack Query renamed the exported type `Enabled` -> `QueryBooleanOption` in v5.100.0, so the generated context file fails to type-check on react-query >= 5.100.0 where `Enabled` no longer exists. Instead of swapping to the new alias (which would just break < 5.100.0), derive the field structurally from `UseQueryOptions` (already imported): enabled?: UseQueryOptions['enabled']; This resolves to whatever react-query types `enabled` as across every v5 version and is immune to future renames of the alias. The `type Enabled` import is dropped and the github example snapshot is updated accordingly. Verified the generated context type-checks against both react-query 5.66.0 (pre-rename) and 5.101.2 (post-rename). --- examples/frontend/src/github/githubContext.ts | 8 ++++++-- plugins/typescript/src/templates/context.ts | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/frontend/src/github/githubContext.ts b/examples/frontend/src/github/githubContext.ts index 79ff533..7d1a31e 100644 --- a/examples/frontend/src/github/githubContext.ts +++ b/examples/frontend/src/github/githubContext.ts @@ -1,7 +1,6 @@ import { skipToken, type DefaultError, - type Enabled, type QueryKey, type UseQueryOptions, } from "@tanstack/react-query"; @@ -31,7 +30,12 @@ export type GithubContext< * Set this to `false` to disable automatic refetching when the query mounts or changes query keys. * Defaults to `true`. */ - enabled?: Enabled; + enabled?: UseQueryOptions< + TQueryFnData, + TError, + TQueryFnData, + TQueryKey + >["enabled"]; }; }; diff --git a/plugins/typescript/src/templates/context.ts b/plugins/typescript/src/templates/context.ts index 1f3f872..4f59096 100644 --- a/plugins/typescript/src/templates/context.ts +++ b/plugins/typescript/src/templates/context.ts @@ -8,7 +8,6 @@ export const getContext = ( `import { skipToken, type DefaultError, - type Enabled, type QueryKey, type UseQueryOptions, } from "@tanstack/react-query"; @@ -35,7 +34,7 @@ export const getContext = ( * Set this to \`false\` to disable automatic refetching when the query mounts or changes query keys. * Defaults to \`true\`. */ - enabled?: Enabled; + enabled?: UseQueryOptions['enabled']; }; };