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

This guard is meant to check for non-empty strings but its predicate is wrong. What is the actual type of `v` inside the `if`, given the predicate as written?

function isNonEmpty(v: unknown): v is string { return typeof v === "string" && v.length > 0; } function g(v: string | number | null) { if (isNonEmpty(v)) { // v here? } }