Conditional Type and Infer Type example here is the demo of how to use both of these in real life scenario