Question presented to candidate: "Both `any` and `unknown` can hold any value. So what is the difference, and which one would you use for the result of `JSON.parse` or for a caught error?"
What a strong answer should cover:
- Both are top types for assignment: every value can be assigned to either
- `any` disables checking: every property access, call and assignment compiles, and it is contagious (whatever you read from it is `any` too)
- `unknown` is the safe top type (added in TypeScript 3.0): you must narrow it with `typeof`, `instanceof`, `Array.isArray`, `in` or a type guard before using it, and it is assignable only to `unknown` and `any`
- Practical uses: `unknown` for untrusted input (`JSON.parse`, network data, catch variables under `strict`), `any` only as a temporary migration escape hatch
- Type algebra: `unknown | T` is `unknown`, `unknown & T` is `T`, `keyof unknown` is `never`
Code / implementation expected: Yes β the same operation on `any` and `unknown`, and a narrowing function that accepts `unknown`.