Skip to content

Commit

Permalink
Simplify step returns such that JsonifyObject<> is hidden entirely (#…
Browse files Browse the repository at this point in the history
…371)

## Summary
<!-- Succinctly describe your change, providing context, what you've
changed, and why. -->

Step results are serialized and deserialized while being pushed to/from
Inngest, so step returns are typed as JSON to make this clear.

These returns still came back wrapped in `JsonifyObject<>`, though,
meaning they didn't actually show the resulting changes unless the user
started to attempt to use them. This small change ensures we display the
resulting type correctly, free of any wrappers.

|
![image](https://github.com/inngest/inngest-js/assets/1736957/cc1027a3-d246-43e1-b6c9-7adad2dea485)
|
![image](https://github.com/inngest/inngest-js/assets/1736957/1c639a86-cd2f-49a1-96cd-2018c7ba52de)
|
| - | - |
| Before | After |


## Checklist
<!-- Tick these items off as you progress. -->
<!-- If an item isn't applicable, ideally please strikeout the item by
wrapping it in "~~"" and suffix it with "N/A My reason for skipping
this." -->
<!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" -->

- [ ] ~~Added a [docs PR](https://github.com/inngest/website) that
references this PR~~ N/A
- [ ] ~~Added unit/integration tests~~ N/A
- [x] Added changesets if applicable
  • Loading branch information
jpwilliams committed Oct 25, 2023
1 parent 76a61db commit d45bfbd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-moose-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"inngest": patch
---

Remove `JsonifyObject<>` wrapper from step output - it's now clearer to see the actual type of a step's result
1 change: 1 addition & 0 deletions packages/inngest/etc/inngest.api.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions packages/inngest/src/components/InngestStepTools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type Jsonify } from "type-fest";
import { type SimplifyDeep } from "type-fest/source/merge-deep";
import { timeStr } from "../helpers/strings";
import {
type ExclusiveKeys,
Expand Down Expand Up @@ -271,12 +272,14 @@ export const createStepTools = <
* TODO Middleware can affect this. If run input middleware has returned
* new step data, do not Jsonify.
*/
Jsonify<
T extends () => Promise<infer U>
? Awaited<U extends void ? null : U>
: ReturnType<T> extends void
? null
: ReturnType<T>
SimplifyDeep<
Jsonify<
T extends () => Promise<infer U>
? Awaited<U extends void ? null : U>
: ReturnType<T> extends void
? null
: ReturnType<T>
>
>
>
>(
Expand Down

0 comments on commit d45bfbd

Please sign in to comment.