LooseAutocomplete: T | Omit<string, T> & string

Creates a type that allows for autocomplete suggestions on a string type, while not giving errors for other values.

Type Parameters

  • T extends string

    A union type of string literals to add to the autocomplete.

// Will allow autocomplete for "abc", "b", and "def", and will not throw errors for other string values.
type Original = LooseAutocomplete<"abc" | "b" | "def">; // "abc" | "b" | "def" | (Omit<string, "abc" | "b" | "def"> & string)