globalpayments / globalpayments-js

JavaScript library for web applications to connect to Heartland eCommerce & Global Payments eCommerce tokenization services
14 stars 23 forks source link

Typescript typings prevent data from being passed to event listeners #44

Open aechan opened 3 years ago

aechan commented 3 years ago

We are using the library with the Typescript types provided in this repository.

In your docs, you give this as an example of how to listen for errors:

GlobalPayments.on("error", (error) => {
  console.error(error);
});

The issue is that, the .on function is defined as:

on: (ev: string, listener: IEventListener) => void;

and IEventListener is defined as:

export declare type IEventListener = () => void;

So this type dictates that no data should be passed through an event listener.

I know that the code is actually passing the data through these listeners, but this mis-typing prevents our Typescript project from compiling without explicitly ignoring typings for the .on function.

slogsdon commented 3 years ago

Thanks for bringing this to our attention, @aechan. I'll work with the team to improve the types here.

reubenoxara commented 10 months ago

this is still an issue for me