Angular's $http.defaults.transformRequest
is defined as:
transformRequest?: IHttpRequestTransformer |IHttpRequestTransformer[];
Now I want to append an own transformer, so I need to check if this is already an array. I thought a simple typeguard with
function x(): angular.IHttpRequestTransformer[] {
if($http.defaults.transformRequest instanceof Array){
return $http.defaults.transformRequest;
}
}
would work, however, inside the if clause idea still thinks it is a union type. I also tried instanceof
and $http.defaults.transformRequest.length === undefined
, nothing worked.
Can anyone hint me in the right direction how I can tell IDEA that I've already ensured that $http.defaults.transformRequest
is an array?
Thank!