#Unable to use Zod parse () without assertion
12 messages · Page 1 of 1 (latest)
However that's what I can only do - add as unknown as T
Is this the only way?
Omg
Wrong example it was
Ignore me
Let me prepare a correct test case
Ok, I think I cannot come up with anything different than this:
Preview:```ts
import type {ZodObject, ZodRawShape} from "zod"
function validate<T extends ZodRawShape>(
data: T,
schema: ZodObject<T>
): T {
const res = schema.parse(data)
return res as unknown as T
}```
You can choose specific lines to embed by selecting them before copying the link.