Departializing in typescript
How can I write a utility to convert a partial or potentially partial type to a non-partial type?
I'm trying to do something like
6 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.Do not all partials have a
fetch
function?Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Hmm, I'm not sure I see how I can use that to help here
Is there any way to get the non-partial type from a potentially partial type? E.g. get
Discord.Message
from Discord.Message | Discord.PartialMessage
just fetch the message
.fetch() on the partial object
I am..... I just can't figure out how to get the types correct
Typescript doesn't think fetch exists on T otherwise
ReturnType<T["fetch"]>
would be the easy solution
Ok so worst case I can do this
But there has got to be a better way to do this
I'm going with
Posting it here in case it's of use to anyone else