sendgrid / sendgrid-nodejs

The Official Twilio SendGrid Led, Community Driven Node.js API Library
https://sendgrid.com
MIT License
2.98k stars 781 forks source link

fix: ResponseError typescript compile errors #1413

Open geofflangenderfer opened 3 weeks ago

geofflangenderfer commented 3 weeks ago

Fixes

this PR updates the types for the ResponseError class. Previously, this caused typescript compiler failures that require casting this to any type.

Type error: Property 'toJSON' does not exist on type 'ResponseError'.
  48 |                 console.error(error)
  49 |                 if (error instanceof ResponseError) {
> 50 |                     res.status(error.code).json(error.toJSON());
     |                                                       ^
  51 |                 } else if (error instanceof Error) {
  52 |                     const errorMessage = error.message
  53 |                     res.status(500).json({ message: errorMessage });
Error: Command "npm run build" exited with 1

Checklist

If you have questions, please file a support ticket.