-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
test(react-query): update vitest type test correctly #6990
test(react-query): update vitest type test correctly #6990
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 95e7528. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 95e7528:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intention as comments
expectTypeOf<(typeof queryKey)[typeof dataTagSymbol]>().toEqualTypeOf< | ||
InfiniteData<string> | ||
>() | ||
expectTypeOf(queryKey[dataTagSymbol]).toEqualTypeOf<InfiniteData<string>>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary generics
@@ -3,17 +3,10 @@ import { fireEvent, render, waitFor } from '@testing-library/react' | |||
import * as React from 'react' | |||
import { ErrorBoundary } from 'react-error-boundary' | |||
import { QueryCache, queryOptions, useQueries } from '..' | |||
import { | |||
createQueryClient, | |||
expectTypeNotAny, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary expectTypeNotAny
import type { | ||
QueryFunction, | ||
QueryKey, | ||
QueryObserverResult, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary QueryObserverResult
@@ -157,26 +152,24 @@ describe('useQueries', () => { | |||
queryKey: key1, | |||
queryFn: () => 'string', | |||
select: (a) => { | |||
expectTypeOf<string>(a) | |||
expectTypeNotAny(a) | |||
expectTypeOf(a).toEqualTypeOf<string>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check not any too.
expectTypeOf<QueryObserverResult<number, unknown>>(result4[1]) | ||
expectTypeOf<string | undefined>(result4[0].data) | ||
expectTypeOf<number | undefined>(result4[1].data) | ||
expectTypeOf(result4[0]).toEqualTypeOf<UseQueryResult<string, Error>>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why use toEqualTypeOf (Error type)
with toEqualTypeOf, We can strictly type check
/** | ||
* Assert the parameter is not typed as `any` | ||
*/ | ||
export function expectTypeNotAny<T>(_: 0 extends 1 & T ? never : T): void { | ||
return undefined | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary expectTypeNotAny by expectTypeOf().toEqualTypeOf
No description provided.