Skip to content

get method type to boolean is resolved to unknown #302

Answered by cyrilletuzi
C0ZEN asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, thanks for the precise issue and the stackblitz reproduction.

This is working as intended.

You're getting a value from client-side storage. So assuming you'll get what you previously stored is not safe: it could have been forged. So it's why the lib is returning unknown if you don't provide a JSON schema for runtime validation (validation can't be done at compilation time via a cast). You can see in the overload you provided that the second param is required.

So what you need to do is this:

this.storage.get('hello', { type: 'boolean' });

But this is not a change in v9 of this lib. It was a change in v7. So maybe something during Angular v8 to v9 migration made you aware of this, bu…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by cyrilletuzi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #302 on December 08, 2020 21:20.