I'm trying to change the return type of a function based on the value of the arguments passed to the function itself. I'm struggling to find the right documentation for it, could anyone point me in the right direction
Here's an example of what I want:
function doSomething({user, includePfp}){if(includePfp) return {...user, pfp: 'wow'}return user}doSomething({user}) // returns type of UserdoSomething({user, includePfp: true}) // returns type of User & {pfp: string}
function doSomething({user, includePfp}){if(includePfp) return {...user, pfp: 'wow'}return user}doSomething({user}) // returns type of UserdoSomething({user, includePfp: true}) // returns type of User & {pfp: string}