#Partial Messages for typescript

9 messages · Page 1 of 1 (latest)

earnest sigil

Hi, i was wondering if it would be a good idea to change the <message>.partial property to a method <message>.isPartial() instead.
The reason for this is that as a typescript user, there seems to be no short way to identify a message as being partial. The only way i've found is with a double check instead of a single check since (message instanceof Message) will return true even if it's Partial. So i had to use if (message.partial && (message instanceof Message))

I can do a PR for it but needed to get some opinions on this.

I'm not an expert dev so maybe i tried the wrong way but i couldn't find a way to make public readonly partial: false; return this is PartialMessage at the same time. I Think it's only possible through public isPartial(): this is PartialMessage

Correct me if i'm wrong on anything!!

Made my first PR yesterday and looking to make more in the future when i'm able too 😛

dawn lichen

Feel free to make a PR for it and let the other devs roll over it

And yes, you can only have type guards with methods, not getters or properties

earnest sigil

Alright, thank you!!

spare bluff

Actually it's a property because it's always false in a Message object. This is so in events where the message passed can be partial it's typed as Message | PartialMessage, where PartialMessage has a partial property of always false

So you can use if (message.partial) actually

earnest sigil
spare bluff

👍