GA-MO / react-confirm-alert

react component confirm dialog.
https://ga-mo.github.io/react-confirm-alert/demo/
MIT License
272 stars 105 forks source link

TypeScript support? #18

Closed Yaojian closed 5 years ago

Yaojian commented 5 years ago

Great lib, and it will be even greater provides the typescript .d.ts ^_^.

danzel commented 5 years ago

These should get you started, feel free to add them.

The propTypes say that buttons is required, but then they are supplied in defaultProps, so I've made them optional here.

declare module 'react-confirm-alert' {

  export interface ReactConfirmAlertProps {
    title?: string;
    message?: string;
    buttons?: Array<{
      label: string;
      onClick: () => void;
    }>;
    childrenElement?: () => React.ReactNode;
    customUI?: (customUiOptions: { title: string, message: string, onClose: () => void }) => React.ReactNode;
    willUnmount?: () => void;
  }

  export function confirmAlert(options: ReactConfirmAlertProps): void;

  export default class ReactConfirmAlert extends React.Component<ReactConfirmAlertProps>{
  }
}
GA-MO commented 5 years ago

@danzel Can you make this PR?