Closed alexandredev3 closed 1 year ago
Merging #83 (fe80b2f) into main (45b33c0) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## main #83 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 201 201
Branches 30 30
=========================================
Hits 201 201
Impacted Files | Coverage Δ | |
---|---|---|
src/index.tsx | 100.00% <ø> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Thanks @alexandredev3 for the quick fix!
This PR fixes the default value of the
PreparedProps
generic type.The![image](https://user-images.githubusercontent.com/61118233/196858133-1ba75f7a-10b4-4884-9541-5fc474c8c701.png)
PreparedProps
generic needs an object as a default value. Without the default value object, Typescript would set all themodal.show()
props to optional even if they're not unless the user initially passes an object to theuseModal()
.But if the![image](https://user-images.githubusercontent.com/61118233/196855317-94dde268-b224-4ebd-bc73-7959b1ede258.png)
PreparedProps
generic has an object as a default value. Typescript couldn't possibly know the initial props that theuseModal
receives because the default value of thePreparedProps
generic was just an object.My solution was to set the![image](https://user-images.githubusercontent.com/61118233/196859539-6a09d196-463b-4981-aa69-eecc369da5be.png)
PreparedProps
generic default value to{} | ComponentProps
. That way, Typescript knows what props the modal receives and if they are required or optional.