小编gib*_*ers的帖子

Conditional keys based on value of another key with Zod

I'm making a project with the TMDB API and trying to make it super type-safe to reinforce some of the TypeScript stuff I'm learning. I'm using Zod to describe the shape of the data returned by the API.

However, I've noticed that depending on the request parameters, the API can send back data with different keys. Specifically, if the API is sending back data from the "trending" endpoint where data.media_type = "movie" it also has the keys title, original_title …

rest types typescript zod trpc.io

12
推荐指数
1
解决办法
8497
查看次数

标签 统计

rest ×1

trpc.io ×1

types ×1

typescript ×1

zod ×1