I have a function with the following signature
public async sequenceAnimations(animations: AnimationPlayer[] | AnimationTracker[]): Promise<any>
In the function itself I want to branch based on if it is an AnimationPlayer array or an AnimationTracker array so I tried this:
let mappedAnimations = animations;
if (animations instanceof Array<AnimationTracker>) {
mappedAnimations = animations.map(anim => anim.animationPlayer)
}
As you can see I am trying to allow the caller to pass either an AnimationPlayer array or an AnimationTracker array which has an instance of animationPlayer. But I get an error when checking instanceof the Array with a type
The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
Also the autocomplete isn't registering the type of the array in the if-block so I assume I can't check the array type like this.
What is the proper way to determine what the type of array being passed is?