8 Replies
conscious-sapphire•4mo ago
Lucky for you, Dominik just wrote an in depth blog on this
https://tkdodo.eu/blog/react-query-selectors-supercharged
React Query Selectors, Supercharged
How to get the most out of select, sprinkled with some TypeScript tips.
dependent-tanOP•4mo ago
i read the whole article but i don't think it covers inferring the return type of an inline function passed to
select.
only how to abstract the function itself as a parameter.harsh-harlequin•4mo ago
WhatDoIPutHere is whatever the queryFn returns, as that is the input for select. It gets inferred if you inline it
dependent-tanOP•4mo ago
i should have named the function "handleSelectedQueryData".
what if i have many inline select functions and still need to get their return type?
harsh-harlequin•4mo ago
Please show a typescript playground
dependent-tanOP•3mo ago
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
harsh-harlequin•3mo ago
not really possible unless you define it inilne and have access to
myQuery
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ5wC+cAZlBCHAEQACMAhgHaoMDGA1gPRTr2swBaAI458VANwAoSawjN4IPNlwEAvCgzL8ACgSS4cESoDS6PAC44AbSrszVALoAafXAwAbdP0vaAlHFUAPjgARklCX2lZeTgACyYAE08AEXoGALhtBLT6SwA5OTzkd3d6ACNPAB4YPDB0CBI4RS08KwBybIY2h0D-IMRXAyHh4c5OYYA9AH5XMbiIAHc4GAhl2vRl2I3UYABzRjTkHkzgRhJcakZkEDLcKl8ZwmlgRu1m0TwAOmBUAGVkVisdCoVD+PQGaIsRBwTr0IgZd4qVzxRhJdCpBhZHKRQhAATS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
dependent-tanOP•2mo ago
In case someone comes across this (probably me in a few months lmao):