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

Change EventType to an interface with a type argument #110

Merged
merged 2 commits into from
Dec 19, 2018

Conversation

Arcath
Copy link
Contributor

@Arcath Arcath commented Dec 10, 2018

Brief Description

Change EventType to an interface with a type argument so that the data attribute can be typed implicitly. For example, once you set the event type to EventType<EVENT_ATTACK> the data takes on the type EventData[EVENT_ATTACK]. This also lets the type of data be addressable so you can write functions that expect a certain type of event data.

This also fixes #109 as EventType incorrectly used type instead of event.

Checklists

  • Test passed
  • Coding style (indentation, etc)
  • Edits have been made to src/ files not index.d.ts
  • Run npm run dtslint to update index.d.ts

dist/index.d.ts Outdated Show resolved Hide resolved
src/literals.ts Outdated Show resolved Hide resolved
@Arcath
Copy link
Contributor Author

Arcath commented Dec 18, 2018

I've updated the type to something that better describes the return data, it's either null or an object that might have these properties.

The index type is only there so typescript will let you address it as EventData[X] which is how the EventItem type works.

@Arcath Arcath merged commit 952c000 into master Dec 19, 2018
@Arcath Arcath deleted the event-data-as-interface branch December 19, 2018 08:55
@Meekohi
Copy link

Meekohi commented Dec 19, 2018

Awesome :D

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

Successfully merging this pull request may close these issues.

Type for EventItem incorrect
4 participants