mailersend-nodejs
mailersend-nodejs copied to clipboard
Add typings
Would be cool for this library to have typings in a d.ts file so it would have a better editor support
Totally agree.
Also looking for this, thank you.
Hi, do we have any status updates on this?
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. 🙏
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!
- Definitely use TypeSript
- 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 ...
@8thblock that would be wonderful! Can we get in touch and tinker out details? If you can, write us over at [email protected] :)
Email sent
Hey there, can you update us here when you move forward with this? Looking forward to it
Hi @buzzb0x, We are currently working on this, and we would update soon.
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
}
@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.
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 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.
#54 has the complete revamp to TS. Release of TS version soon... WIP