Typed Array.prototype.includes — narrows the type of value to T[number] when returning true.
Array.prototype.includes
value
T[number]
true
The array to search.
The value to look for.
const roles = ["admin", "user"] as constarrayIncludes(roles, "admin") // => true, value typed as "admin" | "user"arrayIncludes(roles, "guest") // => false Copy
const roles = ["admin", "user"] as constarrayIncludes(roles, "admin") // => true, value typed as "admin" | "user"arrayIncludes(roles, "guest") // => false
Typed
Array.prototype.includes— narrows the type ofvaluetoT[number]when returningtrue.