Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScriptdiscriminated unionsSingle-choice MCQ

The two members of this union share no discriminant property. What does the `in` operator do to the type of `x` in each branch?

type A = { a: number }; type B = { b: number }; function pick(x: A | B): number { if ("a" in x) { return x.a; } return x.b; }