type ToArray < T > = T extends any [ ] ? T : T [ ] ; example export function toArray < T > ( arg ) { if ( Array . isArray ( arg ) ) { return arg as ToArray < T > ; } return ( typeof arg !== "undefined" ? [ arg ] : [ ] ) as ToArray < T > ; }