import type {SomeExtend} from 'type-fest';
type A = SomeExtend<['1', '2', 3], number>;
//=> true
type B = SomeExtend<[1, 2, 3], string>;
//=> false
type C = SomeExtend<[string, number | string], number>;
//=> boolean
type D = SomeExtend<[true, boolean, true], false>;
//=> 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 {SomeExtend} from 'type-fest';
type A = SomeExtend<[1?, 2?, '3'?], string>;
//=> true
// @exactOptionalPropertyTypes: false
import type {SomeExtend} from 'type-fest';
type A = SomeExtend<[1?, 2?, '3'?], string>;
//=> boolean
type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
//=> true
Returns a boolean for whether some element in an array type extends another type.