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

[BUG] The return type of `step.run` is typed incorrectly. It removes object keys with type `unknown` #456

Closed anirudhsama closed 7 months ago

anirudhsama commented 8 months ago

Describe the bug The return type of step.run is typed incorrectly. It removes object keys with type unknown

To Reproduce Consider this function:

export const helloWorld = inngest.createFunction(
    { id: "hello-world" },
    { event: "test/hello.world" },
    async ({  step }) => {
        await step.sleep("wait-a-moment", "1s");

        const result = await step.run("do-some-work", () => {
            const d: unknown = { hello: "world" };
            const r = { status: "success", data: d }
            return r;
            // typed as {status: string; data: unknown}
        });

        return result;
        // typed as {status: string}
               // key data is removed
    },
);

Expected behavior The return type of step.run shouldn't remove unknown keys.

Code snippets / Logs / Screenshots

CleanShot 2024-01-11 at 11 26 23@2x

System info (please complete the following information):

jpwilliams commented 7 months ago

Thanks for the report, @anirudhsama!

This should now be fixed in v3.15.5. 🙂