GA-MO / react-confirm-alert

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

Fix TS definition for the 'buttons' property #81

Closed mixaildudin closed 2 years ago

mixaildudin commented 2 years ago

The problem

Here's the index.d.ts code currently in the master:

buttons?: Array<{
  label: string
  className?: string
} & HTMLButtonElement>

These type definitions break even the code from the docs with the following error: image

onClick won't let my code compile, so for now I had to suppress the error.

Here's why it breaks. HTMLButtonElement is an interface describing a vanilla DOM button element. So it has a lowercased onclick and a whole lot of other required fields (about 300 of them) which you will need to specify in order to get your code to compile.

What's in the PR

I updated the d.ts-file and used the interface which React itself uses for buttons. It has a normal React-style onClick and other optional fields relevant for buttons and the inherited ones.