Tsallaka zuwa abun ciki
Justice Tech School

any, unknown and never

any turns off checking. unknown is the safe version that forces a check before use. never is for values that cannot happen.

Example
function show(v: unknown) {
  if (typeof v === "string") return v.toUpperCase();
  return String(v);
}
console.log(show("a"), show(5));

Result

A 5

Exercise

Safe unknown type.

let v:  = 1;

Quiz Test

Which is safer than any?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.