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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

damianstasik
Copy link

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.

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

Successfully merging this pull request may close these issues.

1 participant