Aaronius / penpal

A promise-based library for securely communicating with iframes via postMessage.
MIT License
381 stars 56 forks source link

Please make connectToParent and connectToChild accept a generic type parameter. #47

Closed marlon-tucker closed 4 years ago

marlon-tucker commented 4 years ago

Hello,

In the 3.x branch, the TS Typings for these methods were generic and thus allowed the returned promise to be correctly typed. In the 5.x branch at the moment, this promise is typed to CallSender which is just a function dictionary and so there's no type safety.

Something like this would keep compatibility

connectToParent<TParent = CallSender>(...)

So if a generic parameter isn't provided, it falls back to CallSender.

Am happy to provide a pull request if you want.

Aaronius commented 4 years ago

@marlon-tucker Please do! I don't have a lot of experience with TS so a pull request would be helpful. Thanks for filing the issue.