-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Description
π Description
I am migrating my application from using Typebox schemas to Zod schemas, and encountered an issue with zod4 and novu.
When defining a workflow with a payloadSchema built using Zod v4, TypeScript does not infer the payload type. Inside step.* handlers, payload properties are typed as never (e.g., Property 'foo' does not exist on type 'never').
The same code path does infer correctly when the schema is defined with TypeBox.
The versions:
"zod-to-json-schema": "~3.24.6",
"zod": "4.1.12",
"@novu/framework": "^2.7.1"
π Reproduction steps
import { workflow } from '@novu/framework';
import { z } from 'zod';
const payloadSchema = z.object({
applicationUrl: z.string().url(),
opportunityId: z.string(),
status: z.enum(['pending', 'approved', 'rejected']),
});
export const myWorkflow = workflow(
'MY_WORKFLOW',
async ({ payload, step }) => {
// TypeScript error here:
// Property 'applicationUrl' does not exist on type 'never'.
await step.email('send-email', async () => {
return {
subject: `Status: ${payload.status}`, // ts error: Property 'status' does not exist on type 'never'.
body: `Open: ${payload.applicationUrl}`, // ts error: Property 'applicationUrl' does not exist on type 'never'.
};
});
await step.inApp('notify', async () => {
return {
subject: 'Update',
body: `Changed to ${payload.status}`,
data: { opportunityId: payload.opportunityId }, // flagged as never
};
});
},
{
payloadSchema, // <- Zod schema provided here
tags: ['example'],
}
);π Expected behavior
The types will be inferred correctly as the type of the zod schema.
π Actual Behavior with Screenshots
The types are not inferred and is considered as 'never'
Novu version
@novu/framework: 2.7.1
npm version
No response
node version
No response
π Provide any additional context for the Bug.
No response
π Have you spent some time to check if this bug has been raised before?
- I checked and didn't find a similar issue
π’ Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to submit PR?
None