effector / effector/farfetched

Runtime mismatch between `mapData` result and `validate` input in `createQuery`

Open
#490 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

## Description
There is a bug in the `createQuery` function where the `validate` function's argument type correctly inherits the result of `mapData` type-wise, but the actual runtime values do not match, causing validation issues.

## Steps to Reproduce
1. Open the provided [reproduction link](https://stackblitz.com/edit/effector-react-j8hud9?file=src%2Fmain.tsx,src%2Fmodel.ts).
2. Check the `model.ts` file where `query` is implemented.
3. Observe that while TypeScript shows no type errors, the runtime behavior indicates a mismatch between the `mapData` result and the `validate` input.

## Expected Behavior
The `validate` function should receive the correctly mapped data from `mapData` at runtime, ensuring proper validation.

Alternatively, if validation is intended to occur before `mapData`, the overload types should be adjusted accordingly to reflect this order of operations.

## Actual Behavior
Despite TypeScript showing no type errors, the `validate` function receives data that doesn't match the expected runtime values from `mapData`, leading to validation failures.

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.