In typescript, if I use this,
Array.isArray(value) ? [value] : value
...it works fine. But if I use a utility function to check it if is array then Typescript complains with error message Argument of type Item[] | Item[][] is not assignable to type Item | Item[].
const isArray = (value: any) => Array.isArray(value)
isArray(value) ? [value] : value // Throws error
const isArray = (value: any): value is any[] => Array.isArray(value)const { isArray } = Array? Given that the function only does that one thing. Or is that just an example?const { isArray } = Array. No need to create a new function just to call an existing function.