Closed NoamLoewenstern closed 1 year ago
Oh wow that's so much cleaner and easier to understand...
Great recommendation! I'll see if I can support this without a breaking change, but I doubt that will be possible. I'll try and release v2 sometime today with this change.
I've added to this pull request. Seems there was an error in the pull-requests' bot deploying to vercel. Odd, since I've changed only a type check.
Thanks for the PR, I've got it merged and published to v1.3.0
. I also updated the docs: https://webext-core.aklinker1.io/messaging/protocol-maps.html
Currently, if a message wants to get response, the way to do that is to use ProtocolWithReturn<data, responseValue>. But it's possible to infer the type passing a regular function type, and inferring the data-argument and response-value from the type.
Instead of:
To infer like this: