7 Replies
correct-apricot•2w 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.
adverse-sapphireOP•2w 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.genetic-orange•2w ago
WhatDoIPutHere is whatever the queryFn returns, as that is the input for select. It gets inferred if you inline it
adverse-sapphireOP•2w ago
i should have named the function "handleSelectedQueryData".
what if i have many inline select functions and still need to get their return type?
genetic-orange•2w ago
Please show a typescript playground
adverse-sapphireOP•2w 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.
genetic-orange•2w 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.