I have an argument of type
((element: any) => Type<any>) | Type<any>
and if it is a Function i need to call it, other wise just use the Type as-is
getType(element: any, type: ((element: any) => Type<any>) | Type<any>): Type<any> {
return isFunctionNotType(type) ? type(element) : type;
}
Unfortunately I am not sure how to write the isFunctionNotType
method. There is an isType
method in @angular/core/src/type
but whenever I try using that I get the following error during compilation
ERROR in C:/Users/xxxxxx/xxxxxx/xxxxxx/dist/xxxxxx/fesm5/angular-utils.js
Module not found: Error: Can't resolve '@angular/core/src/type' in 'C:\Users\xxxxxx\xxxxxx\xxxxxx\dist\xxxxxx\fesm5'
Is there some way to get this working without having to break up the type
variable into two?
EDIT: I should point out since people seem to be missing the point here. In angular Type
extends Function
, and at run-time you will not be able to tell them apart just by doing an instanceof
or something like that.