{
    "api": "YAML JSON TOON Database",
    "version": "1.0.0",
    "format": "json",
    "dataset": {
        "id": 505,
        "slug": "typescript-type-system",
        "title": "TypeScript Type System",
        "description": "TypeScript's static type system: types, interfaces, generics, utility types, and advanced type manipulation.",
        "category": "Programming Languages",
        "category_slug": "programming-languages",
        "tags": "typescript,types,static-typing,generics,interfaces",
        "view_count": 1,
        "created_at": 1781275786,
        "updated_at": 1781275786
    },
    "data": {
        "concepts": [
            {
                "name": "Primitive Types",
                "types": [
                    "string",
                    "number",
                    "boolean",
                    "null",
                    "undefined",
                    "symbol",
                    "bigint"
                ],
                "description": "Basic built-in types. TypeScript adds `any`, `unknown`, `never`, `void`.",
                "example": "let name: string = \"Alice\"; let age: number = 30; let isActive: boolean = true;"
            },
            {
                "name": "Interfaces",
                "keyword": "interface",
                "description": "Define object shape; can be extended and implemented. Structural typing.",
                "example": "interface User { id: number; name: string; email?: string; }\nconst u: User = { id: 1, name: \"Bob\" };"
            },
            {
                "name": "Type Aliases",
                "keyword": "type",
                "description": "Create new named type; can represent primitives, unions, tuples, objects.",
                "example": "type ID = number | string; type Point = [number, number]; type User = { name: string };"
            },
            {
                "name": "Generics",
                "keyword": "<T>",
                "description": "Type variables enable reusable components that work with multiple types.",
                "example": "function identity<T>(arg: T): T { return arg; }\nlet output = identity<string>(\"hello\");"
            },
            {
                "name": "Union Types",
                "keyword": "|",
                "description": "Value can be one of several types; use type guards to narrow.",
                "example": "function format(x: string | number) { if (typeof x === 'string') { ... } else { ... } }"
            },
            {
                "name": "Intersection Types",
                "keyword": "&",
                "description": "Combine multiple types into one; object must satisfy all constraints.",
                "example": "type Admin = User & { permissions: string[] };"
            },
            {
                "name": "Type Guards",
                "patterns": [
                    "typeof",
                    "instanceof",
                    "in operator",
                    "custom type predicate"
                ],
                "description": "Narrow types within conditional blocks.",
                "example": "function isString(x: unknown): x is string { return typeof x === 'string'; }\nif (isString(val)) { val.toUpperCase(); }"
            },
            {
                "name": "Utility Types",
                "common": [
                    "Partial<T>",
                    "Required<T>",
                    "Pick<T,K>",
                    "Omit<T,K>",
                    "Record<K,T>",
                    "ReturnType<T>"
                ],
                "description": "Built-in type transformations; avoid manual re-declaration.",
                "example": "interface Post { title: string; content: string; published: boolean; }\ntype EditPost = Pick<Post, 'title' | 'content'>;"
            },
            {
                "name": "Discriminated Unions",
                "pattern": "tagged union",
                "description": "Union of types with common literal field; enables exhaustive type checking in switch.",
                "example": "type Shape = { kind: 'circle'; radius: number } | { kind: 'square'; side: number };\nfunction area(s: Shape) { switch(s.kind) { case 'circle': return Math.PI * s.radius ** 2; ... } }"
            },
            {
                "name": "Mapped Types",
                "keyword": "keyof, in",
                "description": "Create types by mapping over properties of another type.",
                "example": "type Readonly<T> = { readonly [P in keyof T]: T[P]; }\ntype Optional<T> = { [P in keyof T]?: T[P] };"
            },
            {
                "name": "Conditional Types",
                "keyword": "T extends U ? X : Y",
                "description": "Types that choose between two types based on a condition.",
                "example": "type IsString<T> = T extends string ? true : false;\ntype NonNullable<T> = T extends null | undefined ? never : T;"
            },
            {
                "name": "Template Literal Types",
                "keyword": "`${}`",
                "description": "Build strings from other types; useful for CSS property names, API endpoints.",
                "example": "type EventName = `on${Capitalize<string>}`; \/\/ onLoad, onMouseEnter, etc."
            }
        ]
    }
}