-
Notifications
You must be signed in to change notification settings - Fork 114
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
result of env.run is not inferring type, returning unknown
#1601
Comments
unknown
I can work around the issue by passing explicit types to env.run, i.e. const result = await env.run<
[UpdateCustomerRelationshipActivityInput],
Nullable<UpdateCustomerRelationshipActivityResult>,
typeof updateCustomerRelationship
>(updateCustomerRelationship, {
...
}); |
Why? ==== The types on MockActivityEnvironment.run() currently explicitly return `unknown` which is annoying to work with. How? ==== Instead of splitting the generic args, use the TypeScript built-in utilities `Parameters<F>` and `ReturnType<F>` so that the types can be properly inferred from the activity function. ---- Closes temporalio#1601.
@mjameswh here's a possible fix for this issue: chadxz@5884ef5 Main thing i'm not sure about is whether this would be considered a breaking change or not. I imagine if you were previously explicitly specifying the generic type parameters, a change like this may break you. With the fix, you can see in the test suite that the return type is improved: |
Any thoughts on this? I'm happy to submit a PR, just want to make sure I take an appropriate approach. |
What are you really trying to do?
I'm trying to test my activities using env.run and assert against the result.
Describe the bug
The return type of env.run is
unknown
when I would expect that it would be inferred from the activity.Minimal Reproduction
https://codesandbox.io/p/devbox/l363c8
Environment/Versions
Macbook M2 Pro Sequoia 15.2
@temporal/testing
1.11.6The text was updated successfully, but these errors were encountered: