krakenjs / post-robot

Cross domain post-messaging on the client side using a simple listener/client pattern.
Apache License 2.0
741 stars 92 forks source link

Mismatch between post-robot and @types/post-robot #109

Open malsabbagh opened 2 years ago

malsabbagh commented 2 years ago

I noticed a couple of instances that would be nice to fix.

once definition doesn't return cancel function in its type. It should return

export function once(
    name: string,
    options?: ServerOptionsType | HandlerType,
    handler?: HandlerType,
): ZalgoPromise<{ source: any; origin: string; data: object }> & CancelableType;

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/post-robot/index.d.ts#L39-L43

HandlerType doesn't allow non-promise functions it should be both

type HandlerType = (event: {
    source: CrossDomainWindowType,
    origin: string,
    data: any
}) => ZalgoPromise<any> | void;

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/post-robot/index.d.ts#L15-L19

I didn't go over all other definitions, I just noticed these two, there could be more issues.

Cijin commented 1 year ago

I can take this up, have been busy since I wrote the definitions couple of years ago. @mstuart

Thank you @malsabbagh for pointing these out :)