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

Does this user-defined type guard produce a compile error, and what is the consequence?

function isStringArray(x: unknown): x is string[] { return Array.isArray(x); } const data: unknown = [1, 2, 3]; if (isStringArray(data)) { data[0].toUpperCase(); }