Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScriptassertion functionsSingle-choice MCQ

Why does this assertion function fail to narrow v at the call site?

const assertString = function (x: unknown): asserts x is string { if (typeof x !== "string") throw new Error(); }; function use(v: unknown) { assertString(v); return v.toUpperCase(); }