Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScriptbranded nominal typingSingle-choice MCQ

Using the branded type below, which line is rejected by the compiler?

declare const brand: unique symbol; type USD = number & { [brand]: "USD" }; function toUSD(n: number): USD { return n as USD; } const a: USD = toUSD(10); const b: USD = toUSD(20); const sum = a + b; // line 1 const back: number = a; // line 2 const c: USD = a * 2; // line 3 const d: USD = sum; // line 4