type alias AutoComplete

This is a utility type that allows you to Autocomplete a string.

For example, let's say you have a situation where you would like an input autocompleted with suggestion, but you also want people to be able to type whatever they want. This would come in handy.

Examples

Example 1

// You will get autocomplete suggestions for 'free', 'paid', and 'admin'.
// but, you can also type anything you want.
function setUserRole(role: AutoComplete<'free' | 'paid' | 'admin'>): void {
 // omitted
}

Type Parameters

T extends string

Definition

T | (string & Record<PropertyKey, unknown>)

Usage

import { type AutoComplete } from ".";