-
Notifications
You must be signed in to change notification settings - Fork 449
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
Strongly typed event names & values #106
Comments
@franky47 I like the idea! Curious how we could do this given the move to |
Is this still being planned for implementation, or will this be dropped altogether in its current state? |
PR #114 is exactly what I'm looking for, FYI. |
@franky47 It'll need to be approved first though. It would be a nice addition for sure. |
This TypeScript userland solution (outside of Mitt) works perfectly fine: |
I really like mitt, and the rewrite in TypeScript is a great step forward, but I wonder if we could go a bit further and allow strong typing of both the event names and their associated values.
Ideally, this would be an opt-in behaviour, meaning that by default mitt uses a
string | symbol
type for event names, andany
for values. But passing an interface as a generic type to the constructor would tell mitt what events to expect and what values are associated, along with providing auto-completion in IDEs.Hypothetical API:
Such a typing system can be seen in action in
vegemite
, a state management library with a similar EventEmitter interface.The text was updated successfully, but these errors were encountered: