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

Add TypeScript definitions #34

Open
igo opened this issue Jun 16, 2019 · 3 comments
Open

Add TypeScript definitions #34

igo opened this issue Jun 16, 2019 · 3 comments

Comments

@igo
Copy link

igo commented Jun 16, 2019

Please add TypeScript definitions or convert project to TypeScript

@Ritural
Copy link

Ritural commented Jul 12, 2019

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> {};
}

@mariano-filipe
Copy link

mariano-filipe commented Aug 6, 2020

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.

@revolunet
Copy link
Owner

Pull requests welcome :)

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

No branches or pull requests

4 participants