How to have multiple possible types for function argument

Yes. You can. Can pass multiple objects in function, just like in Java. Can use these object values for condition check, calculations. Even typescrit support method overloading and method overridding like in Java.