effector / effector/farfetched

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

Open
#441 0 comments 0 reactions 0 assignees View on GitHub
scope:core
Dominant language
TypeScript
Stars
221
Forks
36
PR merge metrics
No merged PRs in 30d

Description

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

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

![image](https://github.com/igorkamyshev/farfetched/assets/16340911/fa6d0277-5c51-42d6-9563-2ded51ce25e5)

If I will add more typings for `validate` property then problem is already exist
```ts
validate: ({
result,
params,
}: {
result: Record;
params: string;
}) => result.id === params
```
![image](https://github.com/igorkamyshev/farfetched/assets/16340911/aed4589f-033a-4dcb-b816-fc2ae03514a7)

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.