Those sound like the same thing to me.
unknown = I don’t know
any = I don’t care
Often the implications are the same, but as you can intuit, any is a lot more relaxed.
Any will work anywhere because you just don’t care what the type is.
Unknown is stricter. It won’t work in cases where other types expect you to know what type you’re dealing with.
The compiler treats unknown very cautiously, whereas you can slap an any on pretty much anything.
Whereas ‘Unknown’ might be a stepping stone to introduce a more specific type once all the use cases are known. I let it handle strings and integers, log a line about any other type that calls it, and continue behaviour as it is today.
For example:
function handleString(s: string) {
//...
}
declare const a: any;
declare const u: unknown;
handleString(a); // works with zero intervention
handleString(u); // error: Argument of type 'unknown' is not assignable to parameter of type 'string'
handleString(u as string); // works again with explicit re-typing