type AssertFuncSync = (...args: any[]) => boolean
type AssertFunc = (...args: any[]) => Promise<boolean>
I have defined two types in typescript above.
Now, in the function demoFunc
, I need to check whether the parameter is an AssertFuncSync
or an AssertFunc
. How can I achieve it?
const demoFunc = (test_func: AssertFunc | AssertFuncSync): any => {
if (test_func is an AssertFunc) {
console.log("it belongs to AssertFunc")
}else{
console.log("it belongs to AssertFuncSync")
}
}