I was recently looking at some java code and liked the idea of method overloading signature.
Typescript too supports the same but, just at the type signature level.
Since, JS doesn't have native support for function/method overload.
Here is an example in playground
Not exactly a thing folks are not aware but, things I wish folks used more often:
{} is not an empty object. Record<string, unknown> is a better representation.
Defining an interface for classes and usage of extends and implements (together).
Here is a link
Usage of Property accessor: interface_name["property_name"]
Very often, I have noticed that we have a function that takes a specific property of an object as an argument. And we end up REPEATING the property's type in the function signature instead of ACCESSING the property's type from the object's interface.
Here is a playground link
I was recently looking at some java code and liked the idea of method overloading signature.
Typescript too supports the same but, just at the type signature level.
Since, JS doesn't have native support for function/method overload.
Here is an example in playground
Not exactly a thing folks are not aware but, things I wish folks used more often:
{}is not an empty object.Record<string, unknown>is a better representation.Defining an interface for classes and usage of extends and implements (together).
Here is a link
Usage of Property accessor:
interface_name["property_name"]Very often, I have noticed that we have a function that takes a specific property of an object as an argument. And we end up REPEATING the property's type in the function signature instead of ACCESSING the property's type from the object's interface.
Here is a playground link
Specifying a type for a constructor.
Links: