Array#includes overload doesn't work on arrays over generic types (`T[]`)
Author: pavadeliCreated Mar 9, 2023Updated Apr 1, 2026
Labelsbugneeds-triage
While this works (no type error):
const arr: ('a' | 'b')[] = [];
arr.includes('some string');This doesn't seem to extend to arrays that are defined in terms of a type parameter, e.g.:
function someFn<T extends string>() {
const arr: T[] = [];
arr.includes('some string');
// ^^^^^^^^^^^^^ Argument of type '"some string"' is not assignable to parameter of type 'T | (WidenLiteral<T> & {})'
}Source: mattpocock/ts-reset