-
Notifications
You must be signed in to change notification settings - Fork 119
Description
Your use case
https://github.com/matrix-org/matrix-js-sdk/blob/fc2671d8538a3339ca5925ef42e3ba6102f7e8f2/src/matrixrtc/CallMembership.ts#L40 takes a typed data structure and does further validation on it that should be unnecessary because of the types. This is a bit weird and confusing, but is because we are casting the raw content from the event into a CallMembershipData and then having the constructor take a typed interface, so we are technically lying about the type of the data between those points.
Now that I think about this more, I suspect the neatest solution would be to have a separate validator function that takes unknown
, validates it and returns CallMembershipData
or throws, then you can construct the CallMembership with a validated CallMembershipData.
Either way, we should do something less confusing, but still actually do explicit validation which we have often neglected in the past.
Have you considered any alternatives?
No response
Additional context
No response