nice-modal-react icon indicating copy to clipboard operation
nice-modal-react copied to clipboard

Make component and props' types optional in the standalone show function

Open damianstasik opened this issue 3 months ago • 0 comments

This PR simplifies specifying type of the resolved value from the show function. Currently, if you want to provide a precise type of the value resolved from a promise, you'll need to provide 1/2 additional types – depending on whether you use an ID or a modal reference.

Before:

NiceModal.show<TypeOfTheValue, ComponentType, PropsType>(SomeModal, someProps).then((value) => { ... });

Both ComponentType and PropsType can be automatically inferred by TS, so having to type them all each time you want to provide TypeOfTheValue is a bit inconvenient.

After:

NiceModal.show<TypeOfTheValue>(SomeModal, someProps).then((value) => { ... });

Now you can provide just the first type while the rest gets inferred. Let me know what you think.

damianstasik avatar Mar 23 '24 15:03 damianstasik