-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #1605: create async thunk reject with value typing #1626
fix #1605: create async thunk reject with value typing #1626
Conversation
✔️ Deploy Preview for redux-starter-kit-docs ready! 🔨 Explore the source changes: 055036d 🔍 Inspect the deploy log: https://app.netlify.com/sites/redux-starter-kit-docs/deploys/616f612f609dad0008cc2325 😎 Browse the preview: https://deploy-preview-1626--redux-starter-kit-docs.netlify.app |
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 055036d:
|
Thanks for the PR!
I'm far from a pc and won't be able to check this for a week or so, but just from skimming it, wouldn't that accept just anything as a return value, even when a specific one was specified in the generics?
Am 20. Oktober 2021 02:22:17 MESZ schrieb Kadir DAMENE ***@***.***>:
…This should fix the (now closed) issue #1605 without breaking the fix
introduced after #1156.
You can view, comment on, or merge this pull request online at:
#1626
-- Commit Summary --
* <a
href="https://github.com/reduxjs/redux-toolkit/pull/1626/commits/c2113469ca59767afcabcb9e64e43005e91f61d3">fix
maybe promise reject with value inference</a>
* <a
href="https://github.com/reduxjs/redux-toolkit/pull/1626/commits/055036d7671cceb393f77bfd45592b849f40f93e">add
maybe promise reject with value type test</a>
-- File Changes --
M packages/toolkit/src/createAsyncThunk.ts (8)
M packages/toolkit/src/tests/createAsyncThunk.typetest.ts (28)
-- Patch Links --
https://github.com/reduxjs/redux-toolkit/pull/1626.patch
https://github.com/reduxjs/redux-toolkit/pull/1626.diff
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
|
Yeah, as I had feared, unfortunately, this would allow the following test to pass, making it possible to return just any value from an async thunk with manual return type annotation: createAsyncThunk<'ret', void>('test', async () => 5) Can you think of other ways of doing this? |
Also, the next closest thing, removing the createAsyncThunk<'ret', void, { fulfilledMeta: string }>(
'test',
async (_, api) => 'ret' as const
) So it will allow just returning the return type value without any |
I think I have a solution over in #1644. Could you give that a try? |
I will. |
Fixed with #1644 |
This should fix the (now closed) issue #1605 without breaking the fix introduced after #1156.