Open this example in the interactive library
Source code
type Fields = { name: string; age: number; subscribed: boolean };
const initial: Fields = { name: "Ada", age: 30, subscribed: false };
console.log(((s: "on" | "off"): boolean => s === "on")("on"));
Sample output
true
