Given the following code

```
type Test = string | boolean | string[] | boolean[]

function test (param: Test) {
  if (!_.isArray(param)) {
    param = [param]
  }

  return param
}

```

I recieve the following error

> 
> (parameter) param: string | boolean
> Type 'string | boolean' is not assignable to type 'boolean'.
> Type 'string' is not assignable to type 'boolean'.ts(2322)
> 
> 
> 

The solution is

```
type Test = string | boolean | (string | boolean)[]

```

But I don't understand my solution 

To put it into words I have a type which consists of two arbitrary types and (bad I know) arrays of those types. Through (!\_.isArray) type guarding I (bad I know) mutate the parameter.

Inside the type guard my type definition is narrowed to 'string | boolean'. Typescript is telling me I can't assign the value I want to this type.

Please give me insight into understanding the error and solution.

Thank you