includes
const actions = [
"CREATE",
"READ",
"UPDATE",
"DELETE"
] as const;
// readonly ["CREATE", "READ", "UPDATE", "DELETE"]
const execute = (action: string) => {
if (actions.includes(action)) {
// 💥 ERROR
}
};interface Array<T> {
includes(searchElement: T, fromIndex?: number): boolean;
}
interface ReadonlyArray<T> {
includes(searchElement: T, fromIndex?: number): boolean;
}Last updated