Closed
Description
TypeScript Version: 2.9.2
Search Terms: array includes es2016 widen
Code
Array.includes
should allow the searchElement
param to be a subtype of the array element type, e.g.
type A = 'foo' | 'bar' | 'baz'
type ASub = Extract<A, 'foo' | 'bar'>;
declare const aSubs: ASub[];
declare const a: A;
/*
Argument of type 'A' is not assignable to parameter of type '"foo" | "bar"'.
Type '"baz"' is not assignable to type '"foo" | "bar"'.
*/
aSubs.includes(a);
Expected behavior:
No error.