#Do Partials Create Un-Typesafe Code?

1 messages · Page 1 of 1 (latest)

edgy temple
#

If I am listening for say a message update event with partials of messages and I receive a partial message in that event with only the ID and no other information, is it possible for me to access a value that doesn’t exist on the object sent to the event listener?

My assumption would be there’s a Message type and a PartialMessage type and the onMessageUpdate() event listener would give a PartialMessage | Message and you’d use the .partial property to determine the state of it

From the docs though it only sends a message object which could be partially constructed, resulting in accessing a property that’s null - creating a runtime error that could have been caught with types?

tawdry hillBOT
#

@edgy temple to help others find answers, you can mark your question as solved via Right Click Solution Message->Apps->✅ Mark Solution

edgy temple
gusty onyx
#

Short answer: yes.

But sometimes partials are a must have and so we need to work around it in runtime.