inngest / inngest-js

The developer platform for easily building reliable workflows with zero infrastructure for TypeScript & JavaScript
https://www.inngest.com/
GNU General Public License v3.0
414 stars 41 forks source link

`step.run()` output removes union `{ name: string }` properties #537

Closed jpwilliams closed 5 months ago

jpwilliams commented 5 months ago

Describe the bug

Nested objects with only a name property in step.run() returns are removed from the output if they are unions with other values.

To Reproduce

https://tsplay.dev/Wzqz2m

import { Inngest } from "inngest";

const inngest = new Inngest({ id: "my-app" });

inngest.createFunction(
  { id: "my-fn" },
  { event: "my/event" },
  async ({ step }) => {
    const obj = await step.run("get-obj", () => {
      const ret: { foo: { name: string } | null } = {
        foo: { name: "foo" },
      };

      ret.foo;
      //   ^? (property) foo: { name: string; } | null

      return ret;
    });

    obj.foo;
    //  ^? Property 'foo' does not exist on type '{}'
  },
);

Expected behavior

The property is preserved.

System info (please complete the following information):

linear[bot] commented 5 months ago

INN-2927 `step.run()` output removes union `{ name: string }` properties