diff --git a/definitions/npm/@tanstack/react-query_v5.x.x/flow_v0.83.x-/react-query_v5.x.x.js b/definitions/npm/@tanstack/react-query_v5.x.x/flow_v0.83.x-/react-query_v5.x.x.js new file mode 100644 index 0000000000..347d10dbf5 --- /dev/null +++ b/definitions/npm/@tanstack/react-query_v5.x.x/flow_v0.83.x-/react-query_v5.x.x.js @@ -0,0 +1,147 @@ +declare module "@tanstack/react-query" { + declare type QueryFunctionContext = { [key: string]: any }; + + declare type UseQueryOptions = {| + queryKey: Array, + queryFn?: (context: QueryFunctionContext) => Promise, + cacheTime?: any, + enabled?: any, + networkMode?: any, + initialData?: any, + initialDataUpdatedAt?: any, + keepPreviousData?: any, + meta?: any, + notifyOnChangeProps?: any, + onError?: any, + onSettled?: any, + onSuccess?: any, + placeholderData?: any, + queryKeyHashFn?: any, + refetchInterval?: any, + refetchIntervalInBackground?: any, + refetchOnMount?: any, + refetchOnReconnect?: any, + refetchOnWindowFocus?: any, + retry?: any, + retryOnMount?: any, + retryDelay?: any, + select?: any, + staleTime?: any, + structuralSharing?: any, + suspense?: any, + useErrorBoundary?: any, + |}; + + declare type UseQueryReturn = {| + isLoading: boolean, + data: TData, + dataUpdatedAt: number, + error: null | TError, + errorUpdatedAt: number, + failureCount: number, + failureReason: null | TError, + fetchStatus: any, + isError: boolean, + isFetched: boolean, + isFetchedAfterMount: boolean, + isFetching: boolean, + isInitialLoading: boolean, + isLoadingError: boolean, + isPaused: boolean, + isPending: boolean, + isPlaceholderData: boolean, + isRefetchError: boolean, + isRefetching: boolean, + isStale: boolean, + isSuccess: boolean, + refetch: any, + status: string, + |}; + + declare type UseMutationOptions = {| + mutationKey: Array, + mutationFn: () => Promise, + onSuccess?: (data: TData, variables: any) => Promise, + onError?: (error: TError) => Promise, + onSettled?: (data: TData | void, error: TError | null, variables: any) => Promise, + onMutate?: () => Promise, + cacheTime?: any, + mutationKey?: any, + networkMode?: any, + retry?: any, + retryDelay?: any, + useErrorBoundary?: any, + meta?: any, + |} + + declare type UseMutationReturn = {| + data: TData | void, + error: TError | null, + isError: boolean, + isIdle: boolean, + isLoading: boolean, + isPaused: boolean, + isSuccess: boolean, + failureCount: number, + failureReason: TError | null, + mutate: ( + variables: any, + options?: {| + onError?: (error: TError) => Promise, + onSettled?: (data: TData | void, error: TError | null, variables: any) => Promise, + onSuccess?: (data: TData, variables: any) => Promise, + |} + ) => Promise, + mutateAsync: ( + variables: any, + options?: {| + onError?: (error: TError) => Promise, + onSettled?: (data: TData | void, error: TError | null, variables: any) => Promise, + onSuccess?: (data: TData, variables: any) => Promise, + |} + ) => Promise, + reset: () => void, + status: string, + |}; + + declare class QueryClient { + queryCache?: any, + mutationCache?: any, + defaultOptions?: any, + } + + declare type QueryClientProviderOptions = {| + client: QueryClient, + children?: React$Node, + |}; + + declare module.exports: {| + useQuery: (queryOptions: UseQueryOptions) => UseQueryReturn, + useMutation: (options: UseMutationOptions) => UseMutationReturn, + QueryClientProvider: (options: QueryClientProviderOptions) => React$Node, + QueryClient: typeof QueryClient, + useQueries: any, + useInfiniteQuery: any, + useIsFetching: any, + useIsMutating: any, + useMutationState: any, + useSuspenseQuery: any, + useSuspenseInfiniteQuery: any, + useSuspenseQueries: any, + useQueryClient: any, + queryOptions: any, + infiniteQueryOptions: any, + QueryCache: any, + MutationCache: any, + QueryObserver: any, + InfiniteQueryObserver: any, + QueriesObserver: any, + QueryErrorResetBoundary: any, + useQueryErrorResetBoundary: any, + focusManager: any, + onlineManager: any, + dehydrate: any, + hydrate: any, + HydrationBoundary : any, + |}; +} diff --git a/definitions/npm/@tanstack/react-query_v5.x.x/flow_v0.83.x-/test_react-query_v5.x.x.js b/definitions/npm/@tanstack/react-query_v5.x.x/flow_v0.83.x-/test_react-query_v5.x.x.js new file mode 100644 index 0000000000..28631053e4 --- /dev/null +++ b/definitions/npm/@tanstack/react-query_v5.x.x/flow_v0.83.x-/test_react-query_v5.x.x.js @@ -0,0 +1,80 @@ +import * as React from 'react'; +import { describe, test } from 'flow-typed-test'; +import { useQuery, QueryClientProvider, useMutation, QueryClient } from '@tanstack/react-query'; + +describe('react-query', ()=> { + test('UseQuery', () => { + // Correct usage + const { isLoading, isSuccess, data } = useQuery({ + queryKey: ['example'], + queryFn: async () => { + const response = await fetch('https://api.example.com/data'); + const data = await response.json(); + return data; + }, + }); + + (isLoading: boolean); + (isSuccess: boolean); + + // Incorrect usage + useQuery({ + // $FlowExpectedError[incompatible-call] + queryKey: 123, // Error: Array + queryFn: () => { + // $FlowExpectedError[incompatible-call] + return 'not a promise'; // Error: Promise is required + }, + }); + }); + + test('UseMutation', () => { + // Correct usage + const {isLoading, isSuccess } = useMutation({ + mutationKey: ['example'], + mutationFn: async () => { + const response = await fetch('https://api.example.com/mutate'); + const data = await response.json(); + return data; + }, + onSuccess: async (data, variables) => await console.log(data, variables), + onError: async (error) => await console.error(error), + onSettled: async (data, error, variables) => await console.log(data, error, variables), + onMutate: async () => await console.log('onMutate callback'), + }); + + (isLoading: boolean); + (isSuccess: boolean); + + // Incorrect usage + useMutation({ + mutationKey: 123, // Error: Expected Array + mutationFn: () => { + // $FlowExpectedError[incompatible-call] + return 'not a promise'; // Error: Promise is required + }, + onSuccess: () => { + // $FlowExpectedError[incompatible-call] + return 'not a promise'; // Error: Promise is required + }, + onError: () => { + // $FlowExpectedError[incompatible-call] + return 'not a promise'; // Error: Promise is required + }, + onSettled: () => { + // $FlowExpectedError[incompatible-call] + return 'not a promise'; // Error: Promise is required + }, + onMutate: () => { + // $FlowExpectedError[incompatible-call] + return 'not a promise'; // Error: Promise is required + }, + }); + }); + + test('QueryClientProvider', () => { + // Correct usage + const queryClient = new QueryClient(); +
; + }); +}) diff --git a/definitions/npm/rimraf_v5.x.x/flow_v0.104.x-/rimraf_v5.x.x.js b/definitions/npm/rimraf_v5.x.x/flow_v0.104.x-/rimraf_v5.x.x.js new file mode 100644 index 0000000000..c29437f97d --- /dev/null +++ b/definitions/npm/rimraf_v5.x.x/flow_v0.104.x-/rimraf_v5.x.x.js @@ -0,0 +1,13 @@ +declare module 'rimraf' { + declare type Options = { + maxRetries?: number, + glob?: boolean, + ... + }; + + declare module.exports: { + (f: string, opts?: Options): Promise, + sync(path: string, opts?: Options): boolean, + ... + }; +} diff --git a/definitions/npm/rimraf_v5.x.x/flow_v0.25.0-v0.103.x/rimraf_v5.x.x.js b/definitions/npm/rimraf_v5.x.x/flow_v0.25.0-v0.103.x/rimraf_v5.x.x.js new file mode 100644 index 0000000000..0b366ee4c5 --- /dev/null +++ b/definitions/npm/rimraf_v5.x.x/flow_v0.25.0-v0.103.x/rimraf_v5.x.x.js @@ -0,0 +1,12 @@ +declare module 'rimraf' { + declare type Options = { + maxRetries?: number, + glob?: boolean + }; + + declare module.exports: { + (f: string, opts?: Options): Promise, + sync(path: string, opts?: Options): boolean, + ... + }; +} diff --git a/definitions/npm/rimraf_v5.x.x/test_rimraf_v3.x.x.js b/definitions/npm/rimraf_v5.x.x/test_rimraf_v3.x.x.js new file mode 100644 index 0000000000..b9beab82ba --- /dev/null +++ b/definitions/npm/rimraf_v5.x.x/test_rimraf_v3.x.x.js @@ -0,0 +1,7 @@ +import rimraf from 'rimraf'; + +rimraf('/tmp/foo/bar/baz', {glob: true}); +rimraf('/tmp/foo/bar/baz'); + +// $FlowExpectedError[incompatible-call] +rimraf(1);