Super Set Unions

What

A super set union is a pattern that allows a variable to accept any value of a broad type (like string) while still providing IDE autocomplete suggestions for specific common values.

How

You combine your common literal values with the broad type intersected with an empty object (string & {}):

type Status = "active" | "inactive" | (string & {});

const s: Status = "active"; // Autocompletes "active" and "inactive"
const s2: Status = "custom"; // Also valid!

Why

If you simply use "active" | "inactive" | string, TypeScript simplifies the type to just string, and you lose all autocomplete suggestions for your literals. The & {} trick prevents this simplification, giving you the best of both worlds: full flexibility and a great developer experience.

Summary

Use super set unions when you want to suggest standard options but still permit custom, user-defined inputs.