AboutAbout
  • Introduction
  • TypeScript
    • Installation and Usage
    • Data Type
    • Type Assertion
    • Types and Interface
    • Extends
    • Utility
    • Generics
    • Modules and Namespaces
    • Declaration File
    • Best Practice
  • Next.js + TypeScript
    • React Typescript
    • Component
  • ESLint
    • Basic Eslint
    • Eslint Rules
    • Most Common Rules
  • Husky
  • NextAuth.js
    • Installation and Usage
    • Session
  • Zod
    • Zod
    • Refinement
    • Inference
  • Introduction
  • TypeScript
    • Installation and Usage
    • Data Type
    • Type Assertion
    • Types and Interface
    • Extends
    • Utility
    • Generics
    • Modules and Namespaces
    • Declaration File
    • Best Practice
  • Next.js + TypeScript
    • React Typescript
    • Component
  • ESLint
    • Basic Eslint
    • Eslint Rules
    • Most Common Rules
  • Husky
  • NextAuth.js
    • Installation and Usage
    • Session
  • Zod
    • Zod
    • Refinement
    • Inference
  • About
Zod
Inference

Inference

Di dalam Zod kita bisa melakukan inference dengan menggunakan infer method. Method ini akan membuat sebuah type inference dari sebuah data yang kita berikan. Contoh:

import { z } from "zod";
 
const schema = z.object({
  name: z.string(),
  age: z.number(),
});
 
type Schema = z.infer<typeof schema>;
 
const data: Schema = {
  name: "John Doe",
  age: 20,
};
Refinement

Devscale Indonesia - Fullstack Typescript Bootcamp Guide