+ {ui + .match("pending", () => "Bears") + .match("forbidden", () => "Can't enter the den") + .match("error", () => "Couldn't load bears") + .match("empty", () => "No bears yet") + .match( + "empty-search", + ({ search: term }) => `No results for ${term}`, + ) + .match("default", ({ bears }) => + bears.length === 1 ? "1 bear" : `${bears.length} bears`, + ) + .exhaustive()} +
+ {ui + .match("pending", () => ( ++ {ui + .match("pending", () => "Loading…") + .match("forbidden", () => "Forbidden") + .match("error", () => "Request failed") + .match("empty", () => "Nothing in the den") + .match("empty-search", ({ search: term }) => `"${term}"`) + .match("default", ({ bears }) => + bears.map((bear) => bear.name).join(" · "), + ) + .exhaustive()} +
+
+ Name every display condition on one match chain.
+ Miss a case, TypeScript fails.
+
+ + See why did we create ui-state + + (opens in a new tab) + +
+