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

An assertion function is assigned to a `const` instead of declared with `function`. Why does this code fail to compile?

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