Closed Peeterush closed 1 year ago
Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:
Coverage data is based on head (
b736677
) compared to base (5ce100b
). Patch has no changes to coverable lines.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Hey, thanks for the PR and taking notice on those typings. Although any
solves this problem there is even a better solution - passing Context
, see #42
Forcing the bind and the callback to use the same context type, that's a good improvement!
Would you also consider having Context
as the first type parameter? I think most people are not that interested in setting a different Target
or Callback
type, but we need to supply them to reach Context
. Having it first would simply allow useLongPress<MyType>(/* ... */)
.
Now you can also just suppy a Context
and a Target
type, and let TS figure out the Callback
type!
Yes, I was considering it but that would require to bump major version because it would break backward compatibility. I was also considering handling it on TS overloads but it would get ugly. I will do it for sure in the future, but for now will stick with the Context
passing fix.
Closing as it was resolved in #42 and future improvements are addressed in #43
The context property is of type
unknown
. Setting a custom context type should be possible as such:But this fails:
By setting the
useLongPress
Callback
type to includeany
without changing its default value, the context type is overwritable while keeping the defaultunknown
when no type parameters are specified.