sweetalert2 / sweetalert2-react-content

Official SweetAlert2 enhancer adding support for React elements as content
MIT License
702 stars 48 forks source link

Using shorthands with TypeScript #102

Closed limonte closed 4 years ago

limonte commented 4 years ago

When using with TypeScript

Swal.fire(<p>Shorthand works too</p>)

produces this error:

image

Which is correct per sweetalert2's types:

function fire(title?: string, message?: string, icon?: SweetAlertIcon): Promise<SweetAlertResult>;

The first param title is string and passing <p>Shorthand works too</p> should produce an error.

Should we deprecate shorthands or somehow support passing Element shorthands? What do you think about this @zenflow

zenflow commented 4 years ago

Should we deprecate shorthands or somehow support passing Element shorthands? What do you think about this @zenflow

I don't think we should ever downgrade the actual capabilities of a library in order to match typings. It should be the other way around; the typings should be made to match the actual types of the library.

limonte commented 4 years ago

Done, thank you @zenflow for the feedback!

sweetalert2-react-content is used in sweetalert2-webpack-demo now: https://github.com/sweetalert2/sweetalert2-webpack-demo/commit/962f5f6e18948d85883a0b7ba5d83c267aa39f37 :tada:

limonte commented 4 years ago

Reopening this issue as https://github.com/sweetalert2/sweetalert2/pull/1804 brought the regression described in https://github.com/sweetalert2/sweetalert2/issues/1822

This issue should be fixed here.

limonte commented 4 years ago

Can't reproduce this issue anymore, shorthands seem to work as expected:

image