在看到zod使用的时候,有发现,可以通过zod定义的schema直接推导出type:
const UserSchema = z.object({
username: z.string().min(3).max(20),
email: z.string().email(),
password: z.string().min(8),
});
type User = z.infer<typeof schema>;
请问,这样的场景下,是否可以使用此方式进行替换掉我们常见的使用TypeScript定义interface?
interface User {
username: string,
email: string
password: string
}