DEV Community

Discussion on: Typescript - why to use "unknown" instead of "any"

Collapse
 
attkinsonjakob profile image
Jakob Attkinson • Edited

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.

declare type TODO = any;
Enter fullscreen mode Exit fullscreen mode

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.

Collapse
 
arikaturika profile image
Arika O

Never thought about it, nice :D. Does it do anything else besides tricking the compiler?