Skip to content

multiGet can return nulls, but the TS types do not reflect this #58

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

Closed
lukewlms opened this issue Apr 4, 2019 · 3 comments
Closed

multiGet can return nulls, but the TS types do not reflect this #58

lukewlms opened this issue Apr 4, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@lukewlms
Copy link
Contributor

lukewlms commented Apr 4, 2019

Current behavior

Querying AsyncStorage for an unknown key using multiGet can return null values.

However the types indicate this is impossible.

Expected behavior

Types should indicate that returning null is possible, OR null should never be returned (I don't know which is correct, but I would think the types).

Repro steps

Run code:

  const [testPair] = await AsyncStorage.multiGet(["DOES NOT EXIST"]);
  console.log(testPair);

return value: ["DOES NOT EXIST", null]

Environment

  • Async Storage version: Latest

"@react-native-community/async-storage": "^1.2.2",

"react-native": "0.59.1",

  • Platform tested: iOS
@krizzu krizzu added the bug Something isn't working label Apr 4, 2019
@krizzu
Copy link
Member

krizzu commented Apr 4, 2019

Hey @lukewlms, thanks for reporting this.

Yes, it seems it slipped through by mistake - obviously, AS can return null if something does not exist.

I'd suggest to update the types. Mind opening a PR?

thanks.

lukewlms added a commit to lukewlms/react-native-async-storage that referenced this issue Apr 5, 2019
Per issue: react-native-async-storage#58

`multiGet` types should allow returning `string | null`, not just string.
@lukewlms
Copy link
Contributor Author

lukewlms commented Apr 5, 2019

Created #59

krizzu pushed a commit that referenced this issue Apr 6, 2019
Per issue: #58

`multiGet` types should allow returning `string | null`, not just string.
@krizzu
Copy link
Member

krizzu commented Apr 7, 2019

Merged,

thanks.

@krizzu krizzu closed this as completed Apr 7, 2019
Corey-Peyton added a commit to Corey-Peyton/async-storage that referenced this issue Jul 14, 2021
Per issue: react-native-async-storage/async-storage#58

`multiGet` types should allow returning `string | null`, not just string.
DenisSolution pushed a commit to DenisSolution/React-native-async-storage that referenced this issue Aug 27, 2022
Per issue: react-native-async-storage/async-storage#58

`multiGet` types should allow returning `string | null`, not just string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants