Add factory payload inference type-level coverage

Co-authored-by: Eric Allam <eric@trigger.dev>
This commit is contained in:
Cursor Agent
2026-02-15 00:11:43 +00:00
parent 302df5e7ae
commit dc48c614f2
@@ -1,6 +1,7 @@
import { expectTypeOf, it } from "vitest";
import type { InferUIMessageChunk, UIMessage } from "ai";
import {
createTriggerChatTransport,
TriggerChatTransport,
TriggerChatTransportOptions,
type TriggerChatTransportPayload,
@@ -89,6 +90,22 @@ it("accepts async payload mappers and trigger option resolvers", function () {
expectTypeOf(options).toBeObject();
});
it("infers custom payload output from mapper in factory helper", function () {
const transport = createTriggerChatTransport({
task: "ai-chat",
accessToken: "pk_test",
payloadMapper: function payloadMapper(request) {
return {
prompt: request.chatId,
};
},
});
expectTypeOf(transport).toEqualTypeOf<
TriggerChatTransport<UIMessage, { prompt: string }>
>();
});
it("accepts typed stream definition objects", function () {
const typedStream = {
id: "chat-stream",