react-mailchimp-subscribe icon indicating copy to clipboard operation
react-mailchimp-subscribe copied to clipboard

Add TypeScript definitions

Open igo opened this issue 6 years ago • 3 comments

Please add TypeScript definitions or convert project to TypeScript

igo avatar Jun 16 '19 11:06 igo

Hey @igo,

This might help if you're looking for a TypeScript definition. This is what I've got if you need a starting point :)

You'll need to create a definition file called react-mailchimp-subscribe.d.ts and include the following code in it

type Status = 'sending' | 'error' | 'success';
type FormData = {
  [key: string]: string;
}

interface IProps {
  url: string;
  render: (props: { subscribe: (formData: FormData) => void, status: Status, message: string }) => React.ReactNode;
}

declare module 'react-mailchimp-subscribe' {
  export default class MailchimpSubscribe extends React.Component<IProps> {};
}

Ritural avatar Jul 12 '19 01:07 Ritural

Regarding the type definitions @Ritural provided, I'd like to add that in case of errors in the jsonp request, the message can also be an instance of Error.

mariano-filipe avatar Aug 06 '20 12:08 mariano-filipe

Pull requests welcome :)

revolunet avatar Aug 06 '20 12:08 revolunet