As I was saying in my last post, I am trying to avoid using the any type as much as possible. Although I understand the need for skipping type chec...
For further actions, you may consider blocking this person and/or reporting abuse
Nice. Did not know that feature!
So it was
unknown
for you???ok I'll leave myself
Hope it helped :).
unknown is just pessimistic 'any' 🙈. With any , ts is like "maybe it is of type array, who knows?", and with unknown it is like "dude, I am not taking any risks 😇".
Best explanation ever
Hehe, nice analogy :).
Thanks for the lesson. Your examples made this easy to understand, and I'm now motivated to use
unknown
the next time I start to reach forany
! 🚸Yes, why not? We indeed need to make some extra checks but since it's safer I believe it's worth it. Thank you for your input!
For situations where defining the type is not possible, I'd like to use the lazy gradual typing. Meaning, I have a global type alias
TODO
that's the same asany
.While it's just a "hack", I do like it and it does come in handy from time to time. Some details.
However, the
unknown
solution you proposed seems much better overall.Never thought about it, nice :D. Does it do anything else besides tricking the compiler?
I've ran across
unknown
when interacting with some libs but never understood what it meant in comparison toany
. Now I know thanks!I've rarely seen it in the wild too, I know what you mean. Glad that it helped :).
Taken it, very Thanks
You're welcome :).