You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many members of the ParsedMail interface that can either be a type, an array of that type, or undefined.
Writing downstream code which has to specifically handle array vs literal cases is cumbersome. It's more intuitive for consumers to handle only arrays (or undefined) instead of handle both cases.
Some examples:
// Assume undefined checks on `parsedMessage.to`// Before:// Only works if there is one recipientconstfirstRecipient=parsedMessage.to.text;// Only works if there is more than one recipientconstfirstRecipient=parsedMessage.to[0].text;// Requires code to handle both casesletfirstRecipient;if(Array.isArray(parsedMessage.to))firstRecipient=parsedMessage.to[0].text;elsefirstRecipient=parsedMessage.to[0].text;// After (always use arrays)// Gets the first address 100% of the timeconstfirstRecipient=parsedMessage.to[0].text;
Programmers are lazy, we don't want to write extra code.
I know this is a breaking change, so perhaps a multiple purpose object could be used for backwards compatibility. ie;
exportinterfaceAddressObject{/** * An array with address details. */value: EmailAddress[];/** * A formatted address string for HTML context. */html: string;/** * A formatted address string for plaintext context. */text: string;}exportinterfaceParsedMessageAddressObjectextendsAddressObject{[index: number]: AddressObject|undefined;}exportinterfaceParsedMail{
...
to?: ParsedMessageAddressObject|undefined;
...
}
The text was updated successfully, but these errors were encountered:
There are many members of the
ParsedMail
interface that can either be a type, an array of that type, or undefined.Writing downstream code which has to specifically handle array vs literal cases is cumbersome. It's more intuitive for consumers to handle only arrays (or undefined) instead of handle both cases.
Some examples:
Programmers are lazy, we don't want to write extra code.
I know this is a breaking change, so perhaps a multiple purpose object could be used for backwards compatibility. ie;
The text was updated successfully, but these errors were encountered: