rtk-incubator / rtk-query

Data fetching and caching addon for Redux Toolkit
https://redux-toolkit.js.org/rtk-query/overview
MIT License
626 stars 31 forks source link

Enforce an object return from `selectFromResult` #216

Closed markerikson closed 3 years ago

markerikson commented 3 years ago

This PR:

I'd found a lovely edge case in my own app where I had:

selectFromResult: (res => res?.items?.length ?? 0)

Unfortunately, due to how the result stuff gets merged together later, I ended up with number & BunchOfResultData, which is of course not valid at all. I had to ensure that I returned the value inside an object.

So, now we enforce that at the type level too.

codesandbox-ci[bot] commented 3 years ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 35504ca5684a21fcd66f5c83192d1910bfb326e5:

Sandbox Source
React Configuration
React Typescript Configuration
rtk-query-demo Configuration
svelte-app-rtk-simplequery-demo Configuration
netlify[bot] commented 3 years ago

Deploy preview for rtk-query-docs ready!

Built with commit 35504ca5684a21fcd66f5c83192d1910bfb326e5

https://deploy-preview-216--rtk-query-docs.netlify.app

github-actions[bot] commented 3 years ago

size-limit report 📦

Path Size
ESM full 10.15 KB (0%)
ESM full (React) 11.56 KB (0%)
createApi + setupListeners 9.19 KB (0%)
createApi (React) + setupListeners 10.46 KB (0%)
fetchBaseQuery 701 B (0%)
retry 278 B (0%)
ApiProvider 400 B (0%)
CJS minfied 15.67 KB (0%)
CJS React minfied 17.37 KB (0%)