#inferring signature from function for conditional execution
5 messages · Page 1 of 1 (latest)
It's the only function in the union tho, so you could do if (typeof this.rule === 'function') {}
TS will ensure the signature is correct. If you need to handle multiple different types of functions then you'll need a way to differentiate them at runtime, you'll need to implement it yourself.
Generally speaking btw, accepting a bunch of wildly different types at the same time gives me code smell.
In your case instead of the chain of ifs you may want to consider subclassing instead.