From 8bde747351a41a7b4f0c5eb7c8e88448af85352a Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Mon, 6 Apr 2026 23:20:56 +0900 Subject: [PATCH 1/5] test({solid,svelte,angular}-query): add missing 'initialData' describe nesting and wrap with top-level describe --- .../src/__tests__/inject-query.test-d.ts | 118 +++++++++--------- .../src/__tests__/useQuery.test-d.tsx | 66 +++++----- .../svelte-query/tests/createQuery.test-d.ts | 66 +++++----- 3 files changed, 128 insertions(+), 122 deletions(-) diff --git a/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts b/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts index 541ad65f148..9723271a429 100644 --- a/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts @@ -3,8 +3,9 @@ import { sleep } from '@tanstack/query-test-utils' import { injectQuery, queryOptions } from '..' import type { Signal } from '@angular/core' -describe('initialData', () => { - describe('Config object overload', () => { +describe('injectQuery', () => { + describe('initialData', () => { + describe('Config object overload', () => { it('TData should always be defined when initialData is provided as an object', () => { const { data } = injectQuery(() => ({ queryKey: ['key'], @@ -107,73 +108,74 @@ describe('initialData', () => { }) }) - describe('structuralSharing', () => { - it('should be able to use structuralSharing with unknown types', () => { - // https://github.com/TanStack/query/issues/6525#issuecomment-1938411343 - injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => 5, - structuralSharing: (oldData, newData) => { - expectTypeOf(oldData).toBeUnknown() - expectTypeOf(newData).toBeUnknown() - return newData - }, - })) + describe('structuralSharing', () => { + it('should be able to use structuralSharing with unknown types', () => { + // https://github.com/TanStack/query/issues/6525#issuecomment-1938411343 + injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => 5, + structuralSharing: (oldData, newData) => { + expectTypeOf(oldData).toBeUnknown() + expectTypeOf(newData).toBeUnknown() + return newData + }, + })) + }) }) }) -}) -describe('Discriminated union return type', () => { - test('data should be possibly undefined by default', () => { - const query = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => sleep(0).then(() => 'Some data'), - })) + describe('Discriminated union return type', () => { + test('data should be possibly undefined by default', () => { + const query = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => sleep(0).then(() => 'Some data'), + })) - expectTypeOf(query.data).toEqualTypeOf>() - }) + expectTypeOf(query.data).toEqualTypeOf>() + }) - test('data should be defined when query is success', () => { - const query = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => sleep(0).then(() => 'Some data'), - })) + test('data should be defined when query is success', () => { + const query = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => sleep(0).then(() => 'Some data'), + })) - if (query.isSuccess()) { - expectTypeOf(query.data).toEqualTypeOf>() - } - }) + if (query.isSuccess()) { + expectTypeOf(query.data).toEqualTypeOf>() + } + }) - test('error should be null when query is success', () => { - const query = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => sleep(0).then(() => 'Some data'), - })) + test('error should be null when query is success', () => { + const query = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => sleep(0).then(() => 'Some data'), + })) - if (query.isSuccess()) { - expectTypeOf(query.error).toEqualTypeOf>() - } - }) + if (query.isSuccess()) { + expectTypeOf(query.error).toEqualTypeOf>() + } + }) - test('data should be undefined when query is pending', () => { - const query = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => sleep(0).then(() => 'Some data'), - })) + test('data should be undefined when query is pending', () => { + const query = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => sleep(0).then(() => 'Some data'), + })) - if (query.isPending()) { - expectTypeOf(query.data).toEqualTypeOf>() - } - }) + if (query.isPending()) { + expectTypeOf(query.data).toEqualTypeOf>() + } + }) - test('error should be defined when query is error', () => { - const query = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => sleep(0).then(() => 'Some data'), - })) + test('error should be defined when query is error', () => { + const query = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => sleep(0).then(() => 'Some data'), + })) - if (query.isError()) { - expectTypeOf(query.error).toEqualTypeOf>() - } + if (query.isError()) { + expectTypeOf(query.error).toEqualTypeOf>() + } + }) }) }) diff --git a/packages/solid-query/src/__tests__/useQuery.test-d.tsx b/packages/solid-query/src/__tests__/useQuery.test-d.tsx index 89c383859f2..35ee761291b 100644 --- a/packages/solid-query/src/__tests__/useQuery.test-d.tsx +++ b/packages/solid-query/src/__tests__/useQuery.test-d.tsx @@ -2,7 +2,8 @@ import { describe, expectTypeOf, it } from 'vitest' import { queryOptions, useQuery } from '../index' describe('useQuery', () => { - describe('Config object overload', () => { + describe('initialData', () => { + describe('Config object overload', () => { it('TData should always be defined when initialData is provided as an object', () => { const { data } = useQuery(() => ({ queryKey: ['key'], @@ -54,45 +55,46 @@ describe('useQuery', () => { }) }) - describe('Query key overload', () => { - it('TData should always be defined when initialData is provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + describe('Query key overload', () => { + it('TData should always be defined when initialData is provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) }) - }) - describe('Query key and func', () => { - it('TData should always be defined when initialData is provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + describe('Query key and func', () => { + it('TData should always be defined when initialData is provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) }) }) }) diff --git a/packages/svelte-query/tests/createQuery.test-d.ts b/packages/svelte-query/tests/createQuery.test-d.ts index ed44e967c1d..ea8d556857f 100644 --- a/packages/svelte-query/tests/createQuery.test-d.ts +++ b/packages/svelte-query/tests/createQuery.test-d.ts @@ -2,7 +2,8 @@ import { describe, expectTypeOf, it } from 'vitest' import { createQuery, queryOptions } from '../src/index.js' describe('createQuery', () => { - describe('Config object overload', () => { + describe('initialData', () => { + describe('Config object overload', () => { it('TData should always be defined when initialData is provided as an object', () => { const { data } = createQuery(() => ({ queryKey: ['key'], @@ -44,45 +45,46 @@ describe('createQuery', () => { }) }) - describe('Query key overload', () => { - it('TData should always be defined when initialData is provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + describe('Query key overload', () => { + it('TData should always be defined when initialData is provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) }) - }) - describe('Query key and func', () => { - it('TData should always be defined when initialData is provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + describe('Query key and func', () => { + it('TData should always be defined when initialData is provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) }) }) }) From 547a9c65617c28fe43555eb87848a2498cc766ae Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2026 14:22:56 +0000 Subject: [PATCH 2/5] ci: apply automated fixes --- .../src/__tests__/inject-query.test-d.ts | 166 +++++++++--------- .../src/__tests__/useQuery.test-d.tsx | 80 ++++----- .../svelte-query/tests/createQuery.test-d.ts | 64 +++---- 3 files changed, 155 insertions(+), 155 deletions(-) diff --git a/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts b/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts index 9723271a429..a220ccfa6fe 100644 --- a/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts @@ -6,107 +6,107 @@ import type { Signal } from '@angular/core' describe('injectQuery', () => { describe('initialData', () => { describe('Config object overload', () => { - it('TData should always be defined when initialData is provided as an object', () => { - const { data } = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + it('TData should always be defined when initialData is provided as an object', () => { + const { data } = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf>() - }) + expectTypeOf(data).toEqualTypeOf>() + }) + + it('TData should be defined when passed through queryOptions', () => { + const options = () => + queryOptions({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: { + wow: true, + }, + }) + const { data } = injectQuery(options) + + expectTypeOf(data).toEqualTypeOf>() + }) - it('TData should be defined when passed through queryOptions', () => { - const options = () => - queryOptions({ + it('should be possible to define a different TData than TQueryFnData using select with queryOptions spread into useQuery', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(1), + }) + + const query = injectQuery(() => ({ + ...options, + select: (data) => data > 1, + })) + + expectTypeOf(query.data).toEqualTypeOf>() + }) + + it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => { + const { data } = injectQuery(() => ({ queryKey: ['key'], queryFn: () => { return { wow: true, } }, - initialData: { + initialData: () => ({ wow: true, - }, - }) - const { data } = injectQuery(options) - - expectTypeOf(data).toEqualTypeOf>() - }) + }), + })) - it('should be possible to define a different TData than TQueryFnData using select with queryOptions spread into useQuery', () => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(1), + expectTypeOf(data).toEqualTypeOf>() }) - const query = injectQuery(() => ({ - ...options, - select: (data) => data > 1, - })) - - expectTypeOf(query.data).toEqualTypeOf>() - }) - - it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => { - const { data } = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: () => ({ - wow: true, - }), - })) - - expectTypeOf(data).toEqualTypeOf>() - }) - - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + })) - expectTypeOf(data).toEqualTypeOf>() - }) + expectTypeOf(data).toEqualTypeOf>() + }) - it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { - const { data } = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: () => undefined as { wow: boolean } | undefined, - })) + it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { + const { data } = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: () => undefined as { wow: boolean } | undefined, + })) - expectTypeOf(data).toEqualTypeOf>() - }) + expectTypeOf(data).toEqualTypeOf>() + }) - it('TData should be narrowed after an isSuccess check when initialData is provided as a function which can return undefined', () => { - const query = injectQuery(() => ({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: () => undefined as { wow: boolean } | undefined, - })) + it('TData should be narrowed after an isSuccess check when initialData is provided as a function which can return undefined', () => { + const query = injectQuery(() => ({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: () => undefined as { wow: boolean } | undefined, + })) - if (query.isSuccess()) { - expectTypeOf(query.data).toEqualTypeOf>() - } + if (query.isSuccess()) { + expectTypeOf(query.data).toEqualTypeOf>() + } + }) }) - }) describe('structuralSharing', () => { it('should be able to use structuralSharing with unknown types', () => { diff --git a/packages/solid-query/src/__tests__/useQuery.test-d.tsx b/packages/solid-query/src/__tests__/useQuery.test-d.tsx index 35ee761291b..ec11493862f 100644 --- a/packages/solid-query/src/__tests__/useQuery.test-d.tsx +++ b/packages/solid-query/src/__tests__/useQuery.test-d.tsx @@ -4,56 +4,56 @@ import { queryOptions, useQuery } from '../index' describe('useQuery', () => { describe('initialData', () => { describe('Config object overload', () => { - it('TData should always be defined when initialData is provided as an object', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) - - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + it('TData should always be defined when initialData is provided as an object', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - it('TData should be defined when passed through queryOptions', () => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() }) - const { data } = useQuery(() => options) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + it('TData should be defined when passed through queryOptions', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + }) + const { data } = useQuery(() => options) - it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: () => ({ wow: true }), - })) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: () => ({ wow: true }), + })) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) - it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: () => undefined as { wow: boolean } | undefined, - })) + it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: () => undefined as { wow: boolean } | undefined, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) }) - }) describe('Query key overload', () => { it('TData should always be defined when initialData is provided', () => { diff --git a/packages/svelte-query/tests/createQuery.test-d.ts b/packages/svelte-query/tests/createQuery.test-d.ts index ea8d556857f..2f25052463d 100644 --- a/packages/svelte-query/tests/createQuery.test-d.ts +++ b/packages/svelte-query/tests/createQuery.test-d.ts @@ -4,46 +4,46 @@ import { createQuery, queryOptions } from '../src/index.js' describe('createQuery', () => { describe('initialData', () => { describe('Config object overload', () => { - it('TData should always be defined when initialData is provided as an object', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) - - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + it('TData should always be defined when initialData is provided as an object', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - it('TData should be defined when passed through queryOptions', () => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() }) - const { data } = createQuery(() => options) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + it('TData should be defined when passed through queryOptions', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + }) + const { data } = createQuery(() => options) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) - it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: () => undefined as { wow: boolean } | undefined, - })) + it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: () => undefined as { wow: boolean } | undefined, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) }) - }) describe('Query key overload', () => { it('TData should always be defined when initialData is provided', () => { From e183325b6378d24c3f13f7aaac9dae668b2d0e07 Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Mon, 6 Apr 2026 23:36:28 +0900 Subject: [PATCH 3/5] test(angular-query-experimental): fix incorrect 'describe' name in 'inject-queries.test-d.ts' and 'inject-mutation.test-d.ts' --- .../src/__tests__/inject-mutation.test-d.ts | 4 +++- .../src/__tests__/inject-queries.test-d.ts | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/angular-query-experimental/src/__tests__/inject-mutation.test-d.ts b/packages/angular-query-experimental/src/__tests__/inject-mutation.test-d.ts index f331bb02dea..f33d89a37ec 100644 --- a/packages/angular-query-experimental/src/__tests__/inject-mutation.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/inject-mutation.test-d.ts @@ -3,7 +3,8 @@ import { sleep } from '@tanstack/query-test-utils' import { injectMutation } from '..' import type { Signal } from '@angular/core' -describe('Discriminated union return type', () => { +describe('injectMutation', () => { + describe('Discriminated union return type', () => { test('data should be possibly undefined by default', () => { const mutation = injectMutation(() => ({ mutationFn: () => sleep(0).then(() => 'string'), @@ -68,4 +69,5 @@ describe('Discriminated union return type', () => { } expectTypeOf(mutation.variables).toEqualTypeOf>() }) + }) }) diff --git a/packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts b/packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts index 62547fd9e09..eaa319c2468 100644 --- a/packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts @@ -5,8 +5,9 @@ import { queryOptions } from '../query-options' import type { CreateQueryOptions, CreateQueryResult, OmitKeyof } from '..' import type { Signal } from '@angular/core' -describe('InjectQueries config object overload', () => { - it('TData should always be defined when initialData is provided as an object', () => { +describe('injectQueries', () => { + describe('config object overload', () => { + it('TData should always be defined when initialData is provided as an object', () => { const query1 = { queryKey: ['key1'], queryFn: () => { @@ -174,4 +175,5 @@ describe('InjectQueries config object overload', () => { > >() }) + }) }) From 070a890056efcc4307e2139ae87c6cba23a92e7c Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2026 14:37:31 +0000 Subject: [PATCH 4/5] ci: apply automated fixes --- .../src/__tests__/inject-mutation.test-d.ts | 108 +++---- .../src/__tests__/inject-queries.test-d.ts | 294 +++++++++--------- 2 files changed, 203 insertions(+), 199 deletions(-) diff --git a/packages/angular-query-experimental/src/__tests__/inject-mutation.test-d.ts b/packages/angular-query-experimental/src/__tests__/inject-mutation.test-d.ts index f33d89a37ec..b3a45d1c374 100644 --- a/packages/angular-query-experimental/src/__tests__/inject-mutation.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/inject-mutation.test-d.ts @@ -5,69 +5,71 @@ import type { Signal } from '@angular/core' describe('injectMutation', () => { describe('Discriminated union return type', () => { - test('data should be possibly undefined by default', () => { - const mutation = injectMutation(() => ({ - mutationFn: () => sleep(0).then(() => 'string'), - })) + test('data should be possibly undefined by default', () => { + const mutation = injectMutation(() => ({ + mutationFn: () => sleep(0).then(() => 'string'), + })) - expectTypeOf(mutation.data).toEqualTypeOf>() - }) + expectTypeOf(mutation.data).toEqualTypeOf>() + }) - test('data should be defined when mutation is success', () => { - const mutation = injectMutation(() => ({ - mutationFn: () => sleep(0).then(() => 'string'), - })) + test('data should be defined when mutation is success', () => { + const mutation = injectMutation(() => ({ + mutationFn: () => sleep(0).then(() => 'string'), + })) - if (mutation.isSuccess()) { - expectTypeOf(mutation.data).toEqualTypeOf>() - } - }) + if (mutation.isSuccess()) { + expectTypeOf(mutation.data).toEqualTypeOf>() + } + }) - test('error should be null when mutation is success', () => { - const mutation = injectMutation(() => ({ - mutationFn: () => sleep(0).then(() => 'string'), - })) + test('error should be null when mutation is success', () => { + const mutation = injectMutation(() => ({ + mutationFn: () => sleep(0).then(() => 'string'), + })) - if (mutation.isSuccess()) { - expectTypeOf(mutation.error).toEqualTypeOf>() - } - }) + if (mutation.isSuccess()) { + expectTypeOf(mutation.error).toEqualTypeOf>() + } + }) - test('data should be undefined when mutation is pending', () => { - const mutation = injectMutation(() => ({ - mutationFn: () => sleep(0).then(() => 'string'), - })) + test('data should be undefined when mutation is pending', () => { + const mutation = injectMutation(() => ({ + mutationFn: () => sleep(0).then(() => 'string'), + })) - if (mutation.isPending()) { - expectTypeOf(mutation.data).toEqualTypeOf>() - } - }) + if (mutation.isPending()) { + expectTypeOf(mutation.data).toEqualTypeOf>() + } + }) - test('error should be defined when mutation is error', () => { - const mutation = injectMutation(() => ({ - mutationFn: () => sleep(0).then(() => 'string'), - })) + test('error should be defined when mutation is error', () => { + const mutation = injectMutation(() => ({ + mutationFn: () => sleep(0).then(() => 'string'), + })) - if (mutation.isError()) { - expectTypeOf(mutation.error).toEqualTypeOf>() - } - }) + if (mutation.isError()) { + expectTypeOf(mutation.error).toEqualTypeOf>() + } + }) - test('should narrow variables', () => { - const mutation = injectMutation(() => ({ - mutationFn: (_variables: string) => sleep(0).then(() => 'string'), - })) + test('should narrow variables', () => { + const mutation = injectMutation(() => ({ + mutationFn: (_variables: string) => sleep(0).then(() => 'string'), + })) - if (mutation.isIdle()) { - expectTypeOf(mutation.variables).toEqualTypeOf>() - } - if (mutation.isPending()) { - expectTypeOf(mutation.variables).toEqualTypeOf>() - } - if (mutation.isSuccess()) { - expectTypeOf(mutation.variables).toEqualTypeOf>() - } - expectTypeOf(mutation.variables).toEqualTypeOf>() - }) + if (mutation.isIdle()) { + expectTypeOf(mutation.variables).toEqualTypeOf>() + } + if (mutation.isPending()) { + expectTypeOf(mutation.variables).toEqualTypeOf>() + } + if (mutation.isSuccess()) { + expectTypeOf(mutation.variables).toEqualTypeOf>() + } + expectTypeOf(mutation.variables).toEqualTypeOf< + Signal + >() + }) }) }) diff --git a/packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts b/packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts index eaa319c2468..de3f7e68578 100644 --- a/packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts @@ -8,172 +8,174 @@ import type { Signal } from '@angular/core' describe('injectQueries', () => { describe('config object overload', () => { it('TData should always be defined when initialData is provided as an object', () => { - const query1 = { - queryKey: ['key1'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: { - wow: false, - }, - } - - const query2 = { - queryKey: ['key2'], - queryFn: () => 'Query Data', - initialData: 'initial data', - } - - const query3 = { - queryKey: ['key2'], - queryFn: () => 'Query Data', - } - - const queryResults = injectQueries(() => ({ - queries: [query1, query2, query3], - })) - - const query1Data = queryResults()[0].data() - const query2Data = queryResults()[1].data() - const query3Data = queryResults()[2].data() - - expectTypeOf(query1Data).toEqualTypeOf<{ wow: boolean }>() - expectTypeOf(query2Data).toEqualTypeOf() - expectTypeOf(query3Data).toEqualTypeOf() - }) + const query1 = { + queryKey: ['key1'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: { + wow: false, + }, + } - it('TData should be defined when passed through queryOptions', () => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: { - wow: true, - }, - }) - const queryResults = injectQueries(() => ({ queries: [options] })) + const query2 = { + queryKey: ['key2'], + queryFn: () => 'Query Data', + initialData: 'initial data', + } - const data = queryResults()[0].data() + const query3 = { + queryKey: ['key2'], + queryFn: () => 'Query Data', + } - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + const queryResults = injectQueries(() => ({ + queries: [query1, query2, query3], + })) + + const query1Data = queryResults()[0].data() + const query2Data = queryResults()[1].data() + const query3Data = queryResults()[2].data() - it('should be possible to define a different TData than TQueryFnData using select with queryOptions spread into injectQuery', () => { - const query1 = queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(1), - select: (data) => data > 1, + expectTypeOf(query1Data).toEqualTypeOf<{ wow: boolean }>() + expectTypeOf(query2Data).toEqualTypeOf() + expectTypeOf(query3Data).toEqualTypeOf() }) - const query2 = { - queryKey: ['key'], - queryFn: () => Promise.resolve(1), - select: (data: number) => data > 1, - } + it('TData should be defined when passed through queryOptions', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } + }, + initialData: { + wow: true, + }, + }) + const queryResults = injectQueries(() => ({ queries: [options] })) - const queryResults = injectQueries(() => ({ queries: [query1, query2] })) - const query1Data = queryResults()[0].data() - const query2Data = queryResults()[1].data() + const data = queryResults()[0].data() - expectTypeOf(query1Data).toEqualTypeOf() - expectTypeOf(query2Data).toEqualTypeOf() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { - const queryResults = injectQueries(() => ({ - queries: [ - { - queryKey: ['key'], - queryFn: () => { - return { - wow: true, - } - }, - initialData: () => undefined as { wow: boolean } | undefined, - }, - ], - })) + it('should be possible to define a different TData than TQueryFnData using select with queryOptions spread into injectQuery', () => { + const query1 = queryOptions({ + queryKey: ['key'], + queryFn: () => Promise.resolve(1), + select: (data) => data > 1, + }) + + const query2 = { + queryKey: ['key'], + queryFn: () => Promise.resolve(1), + select: (data: number) => data > 1, + } - const data = queryResults()[0].data() + const queryResults = injectQueries(() => ({ queries: [query1, query2] })) + const query1Data = queryResults()[0].data() + const query2Data = queryResults()[1].data() - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + expectTypeOf(query1Data).toEqualTypeOf() + expectTypeOf(query2Data).toEqualTypeOf() + }) - describe('custom injectable', () => { - it('should allow custom hooks using UseQueryOptions', () => { - type Data = string - - const injectCustomQueries = ( - options?: OmitKeyof, 'queryKey' | 'queryFn'>, - ) => { - return injectQueries(() => ({ - queries: [ - { - ...options, - queryKey: ['todos-key'], - queryFn: () => Promise.resolve('data'), + it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { + const queryResults = injectQueries(() => ({ + queries: [ + { + queryKey: ['key'], + queryFn: () => { + return { + wow: true, + } }, - ], - })) - } + initialData: () => undefined as { wow: boolean } | undefined, + }, + ], + })) - const queryResults = injectCustomQueries() const data = queryResults()[0].data() - expectTypeOf(data).toEqualTypeOf() + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() }) - }) - it('TData should have correct type when conditional skipToken is passed', () => { - const queryResults = injectQueries(() => ({ - queries: [ - { - queryKey: ['withSkipToken'], - queryFn: Math.random() > 0.5 ? skipToken : () => Promise.resolve(5), - }, - ], - })) + describe('custom injectable', () => { + it('should allow custom hooks using UseQueryOptions', () => { + type Data = string + + const injectCustomQueries = ( + options?: OmitKeyof, 'queryKey' | 'queryFn'>, + ) => { + return injectQueries(() => ({ + queries: [ + { + ...options, + queryKey: ['todos-key'], + queryFn: () => Promise.resolve('data'), + }, + ], + })) + } - const firstResult = queryResults()[0] + const queryResults = injectCustomQueries() + const data = queryResults()[0].data() - expectTypeOf(firstResult).toEqualTypeOf>() - expectTypeOf(firstResult.data()).toEqualTypeOf() - }) + expectTypeOf(data).toEqualTypeOf() + }) + }) - it('should return correct data for dynamic queries with mixed result types', () => { - const Queries1 = { - get: () => - queryOptions({ - queryKey: ['key1'], - queryFn: () => Promise.resolve(1), - }), - } - const Queries2 = { - get: () => - queryOptions({ - queryKey: ['key2'], - queryFn: () => Promise.resolve(true), - }), - } - - const queries1List = [1, 2, 3].map(() => ({ ...Queries1.get() })) - const result = injectQueries(() => ({ - queries: [...queries1List, { ...Queries2.get() }], - })) - - expectTypeOf(result).branded.toEqualTypeOf< - Signal< - [ - ...Array>, - CreateQueryResult, - ] - > - >() - }) + it('TData should have correct type when conditional skipToken is passed', () => { + const queryResults = injectQueries(() => ({ + queries: [ + { + queryKey: ['withSkipToken'], + queryFn: Math.random() > 0.5 ? skipToken : () => Promise.resolve(5), + }, + ], + })) + + const firstResult = queryResults()[0] + + expectTypeOf(firstResult).toEqualTypeOf< + CreateQueryResult + >() + expectTypeOf(firstResult.data()).toEqualTypeOf() + }) + + it('should return correct data for dynamic queries with mixed result types', () => { + const Queries1 = { + get: () => + queryOptions({ + queryKey: ['key1'], + queryFn: () => Promise.resolve(1), + }), + } + const Queries2 = { + get: () => + queryOptions({ + queryKey: ['key2'], + queryFn: () => Promise.resolve(true), + }), + } + + const queries1List = [1, 2, 3].map(() => ({ ...Queries1.get() })) + const result = injectQueries(() => ({ + queries: [...queries1List, { ...Queries2.get() }], + })) + + expectTypeOf(result).branded.toEqualTypeOf< + Signal< + [ + ...Array>, + CreateQueryResult, + ] + > + >() + }) }) }) From 337be3b43337feef30f14fd99379344d706eb399 Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Mon, 6 Apr 2026 23:41:01 +0900 Subject: [PATCH 5/5] revert: remove solid-query and svelte-query changes from this PR --- .../src/__tests__/useQuery.test-d.tsx | 148 +++++++++--------- .../svelte-query/tests/createQuery.test-d.ts | 132 ++++++++-------- 2 files changed, 138 insertions(+), 142 deletions(-) diff --git a/packages/solid-query/src/__tests__/useQuery.test-d.tsx b/packages/solid-query/src/__tests__/useQuery.test-d.tsx index ec11493862f..89c383859f2 100644 --- a/packages/solid-query/src/__tests__/useQuery.test-d.tsx +++ b/packages/solid-query/src/__tests__/useQuery.test-d.tsx @@ -2,99 +2,97 @@ import { describe, expectTypeOf, it } from 'vitest' import { queryOptions, useQuery } from '../index' describe('useQuery', () => { - describe('initialData', () => { - describe('Config object overload', () => { - it('TData should always be defined when initialData is provided as an object', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) - - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) - - it('TData should be defined when passed through queryOptions', () => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - }) - const { data } = useQuery(() => options) + describe('Config object overload', () => { + it('TData should always be defined when initialData is provided as an object', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + it('TData should be defined when passed through queryOptions', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, }) + const { data } = useQuery(() => options) - it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: () => ({ wow: true }), - })) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: () => ({ wow: true }), + })) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: () => undefined as { wow: boolean } | undefined, - })) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: () => undefined as { wow: boolean } | undefined, + })) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() }) + }) - describe('Query key overload', () => { - it('TData should always be defined when initialData is provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + describe('Query key overload', () => { + it('TData should always be defined when initialData is provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() }) + }) - describe('Query key and func', () => { - it('TData should always be defined when initialData is provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + describe('Query key and func', () => { + it('TData should always be defined when initialData is provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = useQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = useQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() }) }) }) diff --git a/packages/svelte-query/tests/createQuery.test-d.ts b/packages/svelte-query/tests/createQuery.test-d.ts index 2f25052463d..ed44e967c1d 100644 --- a/packages/svelte-query/tests/createQuery.test-d.ts +++ b/packages/svelte-query/tests/createQuery.test-d.ts @@ -2,89 +2,87 @@ import { describe, expectTypeOf, it } from 'vitest' import { createQuery, queryOptions } from '../src/index.js' describe('createQuery', () => { - describe('initialData', () => { - describe('Config object overload', () => { - it('TData should always be defined when initialData is provided as an object', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) - - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) - - it('TData should be defined when passed through queryOptions', () => { - const options = queryOptions({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - }) - const { data } = createQuery(() => options) + describe('Config object overload', () => { + it('TData should always be defined when initialData is provided as an object', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + it('TData should be defined when passed through queryOptions', () => { + const options = queryOptions({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, }) + const { data } = createQuery(() => options) + + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() + }) - it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: () => undefined as { wow: boolean } | undefined, - })) + it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: () => undefined as { wow: boolean } | undefined, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() }) + }) - describe('Query key overload', () => { - it('TData should always be defined when initialData is provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + describe('Query key overload', () => { + it('TData should always be defined when initialData is provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() }) + }) - describe('Query key and func', () => { - it('TData should always be defined when initialData is provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - initialData: { wow: true }, - })) + describe('Query key and func', () => { + it('TData should always be defined when initialData is provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + initialData: { wow: true }, + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean }>() + }) - it('TData should have undefined in the union when initialData is NOT provided', () => { - const { data } = createQuery(() => ({ - queryKey: ['key'], - queryFn: () => ({ wow: true }), - })) + it('TData should have undefined in the union when initialData is NOT provided', () => { + const { data } = createQuery(() => ({ + queryKey: ['key'], + queryFn: () => ({ wow: true }), + })) - expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() - }) + expectTypeOf(data).toEqualTypeOf<{ wow: boolean } | undefined>() }) }) })