Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScriptuser-defined type guardsSingle-choice MCQ

After this narrowing, the compiler reports that the `else` branch still type-errors at runtime because the guard's implementation is wrong, yet `tsc` compiles it cleanly. Why does the compiler accept the guard?

function isString(x: unknown): x is string { return typeof x === "number"; }