-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
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.
dalen, gtktsc, leahein, ergunsh, wongjiahau and 22 more
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created