I've read the official doc about the unknown type but I have some difficulties to really understand how it works.
One can read in the doc : "no operations are permitted on an unknown without first asserting or narrowing to a more specific type."
but if I have this function:
const foo = (x: unknown) => {
return x + "3";
}
it's ok for TypeScript, but this function raises an error, telling that x is unknown:
const foo = (x: unknown) => {
return x + 3;
}
why does it work with x + "3" ?
If casting is involved, true + 3 or {} + 3 works for instance, as well as true + "3".