-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixed an issue in the EmittedFrom
type helper that could prevent it from inferring the desired type from some service
#3292
Conversation
… from inferring the desired type from some service
🦋 Changeset detectedLatest commit: 8b96e09 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodeSee Review Map:Review in an interactive map View more CodeSee Maps Legend |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8b96e09:
|
packages/core/src/types.ts
Outdated
@@ -1799,7 +1799,7 @@ export interface Behavior<TEvent extends EventObject, TEmitted = any> { | |||
} | |||
|
|||
export type EmittedFrom<T> = ReturnTypeOrValue<T> extends infer R | |||
? R extends ActorRef<infer _, infer TEmitted> | |||
? R extends ActorRef<any, infer TEmitted> |
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.
This is somewhat weird because my intuition was that it should not work when R
has TEvent
configured as never
.
And indeed it shouldn't work as per this playground. So it got me thinking... and I've realized that those becomes assignable when we turn off the strictFunctionTypes
(see here).
The weird thing is that... our tests should be type-checked using strict mode but apparently this doesn't quite work 🤷♂️
Gonna fix this up in a sec.
@@ -1799,7 +1799,9 @@ export interface Behavior<TEvent extends EventObject, TEmitted = any> { | |||
} | |||
|
|||
export type EmittedFrom<T> = ReturnTypeOrValue<T> extends infer R | |||
? R extends ActorRef<infer _, infer TEmitted> | |||
? R extends Interpreter<infer _, infer __, infer ___, infer ____, infer _____> |
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.
this might look a little bit strange because Interpreter
implements ActorRef
and ActorRef
is already handled here - but, unfortunately, while it implements the ActorRef
, its send
method's signature is different and TS might not be able to actually treat it as ActorRef
for the purpose of conditional types with infer
fixes the issue reported here: https://discord.com/channels/795785288994652170/809564589880639548/974402582393024562