I am a tall (1,95m) coding & drawing enthusiast that likes all type of coding and drawing cartoons. I like to work (coding & drawing) on the go with my surface
#cypress #js #csharp
Passionate about solving problems since 2012! I'm a full stack web developer with experience in AWS, TypeScript and React. Looking for new opportunities!
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 😇".
Software producer specialized in data and distributed systems.
Past: tech lead for Disney+ DRM (NYC), consulting and contracting (NYC), startup scene, Salesforce, full-time lab staff.
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 as any.
declaretypeTODO=any;
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.
Nice. Did not know that feature!
So it was
unknownfor 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
unknownthe 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
TODOthat'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
unknownsolution 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
unknownwhen 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 :).