igorkamyshev / farfetched

The advanced data fetching tool for web applications
https://ff.effector.dev
MIT License
190 stars 34 forks source link

Missing overload for `createQuery` with 'effect' + 'validate' #441

Open js2me opened 8 months ago

js2me commented 8 months ago

I' ve add modified example from documentation about validators in my ts project and got ts errors
https://farfetched.pages.dev/tutorial/validators.html

const blockQuery = createQuery<string, Record<string, any>, any>({
  effect: createEffect<string, Record<string, any>, any>(async (id: string) => {
    const response = await fetch(`https://api.salo.com/blocks/${id}.json`);
    return response.json() as unknown as Record<string, any>;
  }),
  validate: ({ result, params }) => result.id === params,
});

image

If I will add more typings for validate property then problem is already exist

validate: ({
    result,
    params,
  }: {
    result: Record<string, any>;
    params: string;
  }) => result.id === params

image

P.S. this code works fine in runtime without typescript