Type 'string | null' is not assignable to type 'string | undefined'.

Argument of type 'Quest' is not assignable to parameter of type '{ id: string; title?: string | undefined; rating?: number | undefined; rating_denominator?: number | undefined; reward_xp?: number | undefined; goal?: string | undefined; target?: Date | undefined; ... 7 more ...; objectives?: { ...; }[] | undefined; }'. Types of property 'description' are incompatible. Type 'string | null' is not assignable to type 'string | undefined'. Type 'null' is not assignable to type 'string | undefined'.ts(2345) I'm getting type directly from: type Quest = RouterOutputs["quests"]["getById"]; and update procedure is below... also lmk if I'm updating custom types wrong
K
Kirik377d ago
update: privateProcedure
.input(
z.object({
id: z.string(),
title: z.string().min(1).max(280).optional(),
rating: z.number().min(1).max(5).optional(),
rating_denominator: z.number().min(1).optional(),
reward_xp: z.number().min(1).optional(),
goal: z.string().optional(),
target: z.date().optional(),
description: z.string().optional(),
region: z.string().optional(),
location: z.string().optional(),
imageUrl: z.string().optional(),
tagline: z.string().optional(),
ingredients: z.string().optional(),
reward: z.string().optional(),
objectives: z.array(
z.object({
obj: z.string(),
location: z.string(),
ingredients: z.string(),
requiredAmount: z.number(),
})
).optional(),
})
)
.mutation(async ({ ctx, input }) => {
const authorId = ctx.userId;

const { success } = await ratelimit.limit(authorId);

if (!success) throw new TRPCError({ code: "TOO_MANY_REQUESTS" });

const quest = await ctx.prisma.quest.update({
where: { id: input.id },
data: {
title: input.title,
rating: input.rating,
rating_denominator: input.rating_denominator,
reward_xp: input.reward_xp,
goal: input.goal,
target: input.target,
description: input.description,
region: input.region,
location: input.location,
imageUrl: input.imageUrl,
tagline: input.tagline,
ingredients: input.ingredients,
reward: input.reward,

},

});
/* const objectives = await ctx.prisma.objective.update({data: {create:
{obj :input.objectives}); */
if (!quest) throw new TRPCError({ code: "NOT_FOUND" });

return (await addUserDataToQuests([quest]))[0];

}),
update: privateProcedure
.input(
z.object({
id: z.string(),
title: z.string().min(1).max(280).optional(),
rating: z.number().min(1).max(5).optional(),
rating_denominator: z.number().min(1).optional(),
reward_xp: z.number().min(1).optional(),
goal: z.string().optional(),
target: z.date().optional(),
description: z.string().optional(),
region: z.string().optional(),
location: z.string().optional(),
imageUrl: z.string().optional(),
tagline: z.string().optional(),
ingredients: z.string().optional(),
reward: z.string().optional(),
objectives: z.array(
z.object({
obj: z.string(),
location: z.string(),
ingredients: z.string(),
requiredAmount: z.number(),
})
).optional(),
})
)
.mutation(async ({ ctx, input }) => {
const authorId = ctx.userId;

const { success } = await ratelimit.limit(authorId);

if (!success) throw new TRPCError({ code: "TOO_MANY_REQUESTS" });

const quest = await ctx.prisma.quest.update({
where: { id: input.id },
data: {
title: input.title,
rating: input.rating,
rating_denominator: input.rating_denominator,
reward_xp: input.reward_xp,
goal: input.goal,
target: input.target,
description: input.description,
region: input.region,
location: input.location,
imageUrl: input.imageUrl,
tagline: input.tagline,
ingredients: input.ingredients,
reward: input.reward,

},

});
/* const objectives = await ctx.prisma.objective.update({data: {create:
{obj :input.objectives}); */
if (!quest) throw new TRPCError({ code: "NOT_FOUND" });

return (await addUserDataToQuests([quest]))[0];

}),
S
Sturlen377d ago
it might be more helpful the show the entire router, as the code here seems to be missing the "getById" procedure metioned in the error. also using ```js at the top of your code snippets will add syntax highlighting for js
S
sheng2808377d ago
where there is no quest description, you want it to be null or undefined? if you want it to be null, add .nullable behind your zod input, if you want it to be undefined, then modify your quest so that it returns undefined when there is no description
S
sheng2808377d ago
GitHub
GitHub - colinhacks/zod: TypeScript-first schema validation with st...
TypeScript-first schema validation with static type inference - GitHub - colinhacks/zod: TypeScript-first schema validation with static type inference
Want results from more Discord servers?
Add your server
More Posts
Matching types to Prisma modelsI have a T3 boilerplate with Prisma and PlanetScale as per Theo's T3 Stack Tutorial. I'm trying to cneed key value pair database like redisneed key value pair datastore like redis which is similar to python dictionary and should be cleint How do I solve this errorI have installed daisyui already. Already tried the suggested fix"Unsafe assignment of `any` valueI am using latest create-t3-app with prisma, tailwind nextAuth and trpcClerk + Next.js app router <SignedOut> children not rendered after <UserButton> sign outHi there! I'm currently building an app with Clerk and I've got signing in working however when I siturbo repo built lint errorI was setting up ct3turbo when I saw the GitHub action workflow is showing errors, how do I fix it?changing col-span with template literalany idea why this isnt working?[Solved] T3 Stack PWA ??Does anybody know how to turn a t3 site into a PWA? I am using next-pwa but I am getting a few errortRPC Error: Invalid hook call.Sorry for the noob question I just cant figure out how to do this I have the following tRPC route: eStack?Hey how would I go about creating a website where you can post minecraft servers and include a imageHow would I order by the role?Hello, I'm trying to set up an API, where I return some users. I've got it working, where it returnsPrisma Create with Connect IssueHey! I wasn't able to find another thread explaining this, but I'd love help with this! I have twoGenerating image background jobI'm making a game where you can create levels in HTML5 Canvas and upload them to the api. I will neeHelp with Vercel deploymentHi folks, I am having issues deploying to vercel. I keep getting this error: