Problem Statement
unknown is best described as…
Explanation
`unknown` can hold any value but cannot be used directly until you refine it with checks like typeof, instanceof, 'in', or a custom predicate. This pushes safe handling at compile time, unlike `any`, which allows all operations without checks.
Code Solution
SolutionRead Only
function parse(json: string): unknown {
return JSON.parse(json);
}
const data = parse('{"x":1}');
// data.x // ❌ Error
if (typeof data === 'object' && data !== null && 'x' in data) {
// ✅ safe after narrowing
}