sendgrid-nodejs icon indicating copy to clipboard operation
sendgrid-nodejs copied to clipboard

Confusing typing

Open assertnotnull opened this issue 3 years ago • 2 comments

The API for Node JS is confusing and not aligned with the API:

  • there's MailData.text & html but there's also MailData.content which is not optional when using MailData. The two first are not in the API doc but content is https://sendgrid.com/docs/api-reference/
  • Readme mentions internal classe Mail that seems like an option to use but then the typing is not aligned with anything in the documentation. Typescript says you can't call send with Mail or MailJSON.

The current version forces me to set:

content: [
      { type: 'text/plain', value: '' },
      { type: 'text/html', value: '' },
    ],

So it's valid Typescript even though we use template ids and values.

assertnotnull avatar Jun 16 '21 13:06 assertnotnull