true if Arr is an array that includes elements of type T, otherwise false. An array of elements of type T is defined as Arr being a subtype of T[].
true
Arr
T
false
T[]
IsArrayOf<number[], number>; // trueIsArrayOf<string[], number>; // falseIsArrayOf<number[], string>; // falseIsArrayOf<(number | string)[], number>; // falseIsArrayIncludeTypeof<Record<string, number>[], number> // falseIsArrayIncludeTypeof<string[], null | boolean> // falseArrayIncludeTypeof<string[], string | boolean> // trueIsArrayIncludeTypeof<Record<string, number>[], Record<symbol, boolean>> // true, Copy
IsArrayOf<number[], number>; // trueIsArrayOf<string[], number>; // falseIsArrayOf<number[], string>; // falseIsArrayOf<(number | string)[], number>; // falseIsArrayIncludeTypeof<Record<string, number>[], number> // falseIsArrayIncludeTypeof<string[], null | boolean> // falseArrayIncludeTypeof<string[], string | boolean> // trueIsArrayIncludeTypeof<Record<string, number>[], Record<symbol, boolean>> // true,
If you want more type narrowing use IsArrayOf<Arr,T>
Returns
true
ifArr
is an array that includes elements of typeT
, otherwisefalse
. An array of elements of typeT
is defined asArr
being a subtype ofT[]
.Example
See
If you want more type narrowing use IsArrayOf<Arr,T>