-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
[TS] Void function interop #400
Conversation
7ff07f2
to
dac78a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests indeed failed
@@ -83,6 +83,7 @@ export type CompositeName = { | |||
|
|||
export interface Event<Payload> extends Unit<Payload> { | |||
(payload: Payload): Payload | |||
(this: Payload extends void ? void : `Error: Expected 1 argument, but got 0`): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is `Error: Expected 1 argument, but got 0`?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a text to show in the error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to tests, it will be shown only if Event expects an argument, but no parameters given.
@@ -355,9 +355,6 @@ describe('#filterMap', () => { | |||
" | |||
--typescript-- | |||
Type 'Event<number>' is not assignable to type 'Event<number | void>'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is important to put "this" overload after the first one to keep this kind of messages right.
dac78a2
to
80ee403
Compare
I've updated the snapshot, tests pass |
Interesting solution, okay, lets try it. Thanks! 👍 |
Use case:
This PR adds void function interop:
The only weak spot is the text of the message:
All tests pass!