TypeScript Function Overloading witch can realy help to overloading function and make good function provides the concept of function overloading. You can have multiple functions with the same name but different parameter types and return type. However, the number of parameters should be the same.
The last function should have the function implementation. Since the return type can be either string or number as per the first two function declarations, we must use compatible parameters and return type as any in the function definition.
Function overloading with different number of parameters and types with same name is not supported
No comments:
Post a Comment