function process<Type>(input: Type | Type[]): Type {
if (Array.isArray(input)) {
// input here is definitely Type[]
return input.map((element) => process(element) /* <- this error message is saying 'Type[]' is not the same as 'Type'*/);
}
// input here is definitely Type
}
The issue I am encountering is that my IDE is showing an error for the recursive call process(element)
even though I did not expect it to. On the other hand, when hovering over the variable within the isArray
check or later on, the correct typing is displayed.