import type {AllExtend} from 'type-fest';
type A = AllExtend<[1, 2, 3], number>;
//=> true
type B = AllExtend<[1, 2, '3'], number>;
//=> false
type C = AllExtend<[number, number | string], number>;
//=> boolean
type D = AllExtend<[true, boolean, true], true>;
//=> boolean
Note: Behaviour of optional elements depend on the exactOptionalPropertyTypes compiler option. When the option is disabled, the target type must include undefined for a successful match.
// @exactOptionalPropertyTypes: true
import type {AllExtend} from 'type-fest';
type A = AllExtend<[1?, 2?, 3?], number>;
//=> true
// @exactOptionalPropertyTypes: false
import type {AllExtend} from 'type-fest';
type A = AllExtend<[1?, 2?, 3?], number>;
//=> boolean
type B = AllExtend<[1?, 2?, 3?], number | undefined>;
//=> true
Returns a boolean for whether every element in an array type extends another type.