// *** before: ***
function parse(json: string): any {
return JSON.parse(json);
}
const value = parse("42");
value.toFixed(2); // compiles unchecked, though value may be anything
value.trim(); // compiles too - any switches the checks off entirely
// *** in version 3.0: ***
function parseSafe(json: string): unknown {
return JSON.parse(json);
}
const safe = parseSafe("42");
// safe.toFixed(2); // <-Error: Object is of type 'unknown'
if (typeof safe === "number") {
safe.toFixed(2); // OK once the type is narrowed
}