Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types are not coming through the .on function #271

Open
wladpaiva opened this issue Aug 13, 2024 · 2 comments
Open

Types are not coming through the .on function #271

wladpaiva opened this issue Aug 13, 2024 · 2 comments

Comments

@wladpaiva
Copy link

Event names work fine but the types for each event is coming as any.

Screenshot 2024-08-13 at 11 46 18

@proudrain
Copy link

You should declare the payload type with a function type, like:

const ee = new EventEmitter<{
   data: (dataEventPayload: DataEventPayload) => void;
}>();

// You can get `DataEventPayload` here
ee.on('data', (data) => {});

@wladpaiva
Copy link
Author

Ohh ok. That makes sense.
On the other hand, the api shouldn't allow me for what I did. It's a minor convenience issue but still

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants