Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error when sending mail with a template #1056

Closed
ogrodnek opened this issue Mar 6, 2020 · 1 comment
Closed

Type error when sending mail with a template #1056

ogrodnek opened this issue Mar 6, 2020 · 1 comment
Labels
status: duplicate duplicate issue

Comments

@ogrodnek
Copy link

ogrodnek commented Mar 6, 2020

Issue Summary

#1041 which requires email content to be present breaks sending email with a template.

Steps to Reproduce

Code Snippet

sendgrid.send({
  from: "[email protected]",
  to: "[email protected]",
  templateId: "d-d123abcd",
});

Exception/Log

error TS2769: No overload matches this call.
  Overload 1 of 2, '(data: MailDataRequired, isMultiple?: boolean | undefined, cb?: ((err: Error | ResponseError, result: [Response, {}]) => void) | undefined): Promise<...>', gave the following error.
    Argument of type '{ from: string; to: string; templateId: string; dynamicTemplateData: { secretLoginCode: string; signInLink: string; }; }' is not assignable to parameter of type 'MailDataRequired'.
      Type '{ from: string; to: string; templateId: string; dynamicTemplateData: { secretLoginCode: string; signInLink: string; }; }' is not assignable to type 'MailData & { content: MailContent[] & { 0: MailContent; }; }'.
        Property 'content' is missing in type '{ from: string; to: string; templateId: string; dynamicTemplateData: { secretLoginCode: string; signInLink: string; }; }' but required in type '{ content: MailContent[] & { 0: MailContent; }; }'.
  Overload 2 of 2, '(data: MailDataRequired[], isMultiple?: boolean | undefined, cb?: ((err: Error | ResponseError, result: [Response, {}]) => void) | undefined): Promise<...>', gave the following error.
    Argument of type '{ from: string; to: string; templateId: string; dynamicTemplateData: { secretLoginCode: string; signInLink: string; }; }' is not assignable to parameter of type 'MailDataRequired[]'.
      Object literal may only specify known properties, and 'from' does not exist in type 'MailDataRequired[]'.

 46     sendgrid
        ~~~~~~~~
 47       .send({
    ~~~~~~~~~~~~~
... 
 54         },
    ~~~~~~~~~~
 55       })
    ~~~~~~~~

  src/create-auth-challenge/node_modules/@sendgrid/mail/src/mail.d.ts:6:43
    6   { text: string } | { html: string } | { content: MailContent[] & { 0: MailContent } });
                                                ~~~~~~~
    'content' is declared here.

Technical details:

  • sendgrid-nodejs version:
  • node version:
@childish-sambino
Copy link
Contributor

Fixed by #1053

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate duplicate issue
Projects
None yet
Development

No branches or pull requests

2 participants