jackbearheart / email-addresses

An RFC 5322 email address parser
MIT License
249 stars 36 forks source link

Mark all function return values as nullable #47

Closed ZhangYiJiang closed 4 years ago

ZhangYiJiang commented 5 years ago

From the examples it seems that all functions can return null if the address is not parsable. This PR corrects the typing so that all functions are correctly marked as being able to return null

ZhangYiJiang commented 5 years ago

This might be considered a breaking change for TypeScript users. I'm not actually sure how semvar deals with types

svdo commented 4 years ago

Despite this being a major version increase according to semver, I hope this change can be merged and released as the types are incorrect at the moment, resulting in false compiler errors. For example, this code gives an error "expression is always true":

const emailValid = emailAddrs.parseOneAddress(email) !== null