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

Add typings

Open talentlessguy opened this issue 4 years ago • 8 comments
trafficstars

Would be cool for this library to have typings in a d.ts file so it would have a better editor support

talentlessguy avatar Apr 24 '21 13:04 talentlessguy

Totally agree.

teamzz111 avatar Sep 20 '21 02:09 teamzz111

Also looking for this, thank you.

joshxyzhimself avatar Dec 19 '21 04:12 joshxyzhimself

Hi, do we have any status updates on this?

fredsossa1 avatar Mar 19 '22 22:03 fredsossa1

Hi, I started work on it: https://github.com/mailersend/mailersend-nodejs/pull/20 but got occupied with other priorities. If anyone wants to make some contribution, that'd be appreciated. 🙏

me-shaon avatar Mar 20 '22 07:03 me-shaon

Hacktoberfest community! We would really welcome input from you on this issue, either adding a dynamic way to generate typings, or even migrating the code base to TypeScript!

fosron avatar Oct 03 '22 09:10 fosron

  1. Definitely use TypeSript
  2. Also build ESM modules. CJS is slowly going away & not standards compliant

I am building mailersend provider in TS happy to just send the code to you when done for you to take a look and adopt any pieces should you find it useful. I intend to use your service for email jobs ...

ghost avatar Nov 16 '22 23:11 ghost

@8thblock that would be wonderful! Can we get in touch and tinker out details? If you can, write us over at [email protected] :)

fosron avatar Nov 18 '22 14:11 fosron

Email sent

ghost avatar Nov 18 '22 14:11 ghost

Hey there, can you update us here when you move forward with this? Looking forward to it

buzzb0x avatar Dec 11 '22 15:12 buzzb0x

Hi @buzzb0x, We are currently working on this, and we would update soon.

opheus2 avatar Dec 12 '22 10:12 opheus2

I've written a .d.ts file for the mailersend package whilst we wait for official typescript support. This covers the basics for emails. Just need to create a file called something like mailersend-t.d.ts in the root of your project and you should be good to go.

declare module 'mailersend' {
  class MailerSend{
    constructor(config: { api_key: string })
    send(email: EmailParams): Promise<Response>
  }

  export class Recipient {
    constructor(email: string, name: string)
  }

  export interface Personalization {
    email: string,
    data: Record<string, string>
  }

  export class EmailParams {
    setFrom(from: string): EmailParams
    setFromName(name: string): EmailParams
    setRecipients(recipients: Recipient[]): EmailParams
    setSubject(subject: string): EmailParams
    setTemplateId(templateId: string): EmailParams
    setPersonalization(personalizations: Personalization[]): EmailParams
  }

  export default MailerSend
}

GerryWilko avatar Dec 14 '22 14:12 GerryWilko

@opheus2 it looks like you guys are sticking with cjs modules and JS with typings file from what I can see on the branch add-typings. Would it not be quicker to just transform the whole repo to Typescript? Any dependencies that need CJS can always build their own version and it would be great to build it to es modules format.

GerryWilko avatar Dec 14 '22 14:12 GerryWilko

Hey @GerryWilko yes and no. Converting to full TS isn't exactly faster. However, converting the whole codebase to TS is the new goal.

opheus2 avatar Dec 14 '22 19:12 opheus2

@opheus2 Sorry yes I probably meant better rather than quicker. That's great news. Hopefully anyone who gets stuck on a TS project for now can get going with my Typings file.

GerryWilko avatar Dec 15 '22 12:12 GerryWilko

#54 has the complete revamp to TS. Release of TS version soon... WIP

opheus2 avatar Jan 03 '23 10:01 opheus2