Skip to content
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(utils): Unwrap loadable/selectAtom promise types #844

Merged
merged 2 commits into from
Nov 24, 2021

Conversation

Pinpickle
Copy link
Contributor

@Pinpickle Pinpickle commented Nov 22, 2021

#713 changed the type signature for atoms. The data field for a loadable ended up incorrectly typed with a promise, when it should be unwrapped.

A similar issue occurred with selectAtom

This adds a ResolveType (used in other files) to fix it.

@vercel
Copy link

vercel bot commented Nov 22, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/jotai/FJfUCcpWvvMJi7faLsNnVAKQs6aa
✅ Preview: https://jotai-git-fork-pinpickle-loadable-promise-signature-pmndrs.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 22, 2021

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 55dadec:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration
Next.js with custom Babel config Configuration
React with custom Babel config Configuration

@Pinpickle Pinpickle changed the title fix(utils): Unwrap loadable promise fix(utils): Unwrap loadable/selectAtom promise Nov 22, 2021
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhhhh, nice catch. thanks a lot!
something totally missed in #713. thanks for the test too.

@dai-shi dai-shi changed the title fix(utils): Unwrap loadable/selectAtom promise fix(utils): Unwrap loadable/selectAtom promise types Nov 23, 2021
@dai-shi dai-shi added this to the v1.4.5 milestone Nov 23, 2021
@dai-shi dai-shi merged commit 2c0791a into pmndrs:main Nov 24, 2021
@dai-shi
Copy link
Member

dai-shi commented Nov 24, 2021

Maybe type assertion can be solved (eliminated) with the future version (with Awaited?)

@Pinpickle
Copy link
Contributor Author

Maybe type assertion can be solved (eliminated) with the future version (with Awaited?)

I sure hope so! Although I don't know if it'll eliminate the assertion altogether... the code may need some refactoring so that TS knows the promise has been resolved.

@Pinpickle Pinpickle deleted the loadable-promise-signature branch November 29, 2021 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants