TypeScript can't narrow a generic boolean like M at runtime, so it doesn't know if value is an array or not. Using function overloads or a type guard is usually the way to handle this.