[
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nexpect(typeof value).toBe('string');\n// Runtime check only\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Type Assertion**\n\n**Fix:**\n```typescript\n// Type-level check at compile time\nconst _typeCheck: string = value;\n// Runtime check\nexpect(typeof value).toBe('string');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_type_assertion"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nexpect(component).toMatchSnapshot();\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Snapshot Typing**\n\n**Fix:**\n```typescript\nconst result = render(<Component />);\nexpect(result.toJSON()).toMatchSnapshot();\n// Explicit render result\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_snapshot_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Config {\n  static apiUrl = 'https://api.com';\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Static Property Typing**\n\n**Fix:**\n```typescript\nclass Config {\n  private static readonly apiUrl: string = 'https://api.com';\n  static getApiUrl(): string { return this.apiUrl; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_static_property_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst zipped = keys.map((key, i) => [key, values[i]]);\n// Manual\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Zip**\n\n**Fix:**\n```typescript\nfunction zip<K, V>(keys: K[], values: V[]): [K, V][] {\n  return keys.map((key, i) => [key, values[i]]);\n}\nfunction unzip<A, B>(pairs: [A, B][]): [A[], B[]] {\n  return [pairs.map(p => p[0]), pairs.map(p => p[1])];\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_zip"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nerrors.forEach(e => report(e));\n// Reports duplicates\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Deduplication**\n\n**Fix:**\n```typescript\nfunction dedupeErrors(errors: Error[]): Error[] {\n  const seen = new Set<string>();\n  return errors.filter(e => {\n    const key = `${e.name}:${e.message}`;\n    if (seen.has(key)) return false;\n    seen.add(key);\n    return true;\n  });\n}\ndedupeErrors(errors).forEach(e => report(e));\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_deduplication"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface ReadonlyUser {\n  readonly name: string;\n  readonly email: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Readonly**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\ntype ReadonlyUser = Readonly<User>;\n// All readonly\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_readonly"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config = require('./config');\n// any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Module Require Typing**\n\n**Fix:**\n```typescript\nimport config from './config';\n// Or:\nimport type { Config } from './config';\nconst config: Config = require('./config');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_module_require_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function retryFetch(url: string, retries: number) {\n  for (let i = 0; i < retries; i++) {\n    try { return await fetch(url); }\n    catch { if (i === retries - 1) throw; }\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Fetch Retry Typing**\n\n**Fix:**\n```typescript\nasync function retryFetch<T>(url: string, retries: number = 3): Promise<Response> {\n  let lastError: Error | null = null;\n  for (let i = 0; i < retries; i++) {\n    try {\n      const response = await fetch(url);\n      if (!response.ok) throw new Error(`HTTP ${response.status}`);\n      return response;\n    } catch (error) {\n      lastError = error as Error;\n      await new Promise(r => setTimeout(r, 1000 * (i + 1)));\n    }\n  }\n  throw lastError;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_fetch_retry_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { User } from '../../models/user';\n// Deep relative imports\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing paths**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\"compilerOptions\": {\n  \"baseUrl\": \".\",\n  \"paths\": {\n    \"@models/*\": [\"src/models/*\"]\n  }\n}}\nimport { User } from '@models/user';\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_paths"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconfig = config ? config : defaults;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with logical assignment**\n\n**Fix:**\n```typescript\nconfig ??= defaults;\n// Type preserved\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_logical_assignment"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { User, createUser } from './users';\n// If User is only used as a type, it still imports at runtime\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using type-only imports**\n\n**Fix:**\n```typescript\nimport type { User } from './users';\nimport { createUser } from './users';\n// Or combined:\nimport { createUser, type User } from './users';\n// Type-only imports are erased at compile time\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_type-only_imports"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(value: unknown) {\n  if (Array.isArray(value)) {\n    return value.length;\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with Array.isArray**\n\n**Fix:**\n```typescript\nfunction process(value: unknown): number {\n  if (Array.isArray(value)) {\n    return value.length; // Narrowed to unknown[]\n  }\n  return 0;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_array.isarray"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction createMap<K, V>(): Map<K, V> {\n  return new Map();\n  // Callers must always specify types\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Generic default value missing**\n\n**Fix:**\n```typescript\nfunction createMap<K, V = unknown>(): Map<K, V> {\n  return new Map();\n}\n// Default V to unknown so callers can omit it\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "generic_default_value_missing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst params = new URLSearchParams();\nparams.set('page', '1');\nparams.set('limit', '10');\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing URLSearchParams Typing**\n\n**Fix:**\n```typescript\nconst params = new URLSearchParams({\n  page: '1',\n  limit: '10',\n});\nconst url = `${base}?${params.toString()}`;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_urlsearchparams_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass UserService {\n  private api = new ApiService();\n  async getUser(id: number) {\n    return this.api.get(`/users/${id}`);\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Dependency Injection**\n\n**Fix:**\n```typescript\ninterface ApiService {\n  get<T>(url: string): Promise<T>;\n}\nclass UserService {\n  constructor(private api: ApiService) {}\n  async getUser(id: number): Promise<User> {\n    return this.api.get(`/users/${id}`);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_dependency_injection"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [state, setState] = useState();\n// Implicit any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Hook Typing**\n\n**Fix:**\n```typescript\ninterface AppState {\n  loading: boolean;\n  error: Error | null;\n  data: User | null;\n}\nconst [state, setState] = useState<AppState>({ loading: false, error: null, data: null });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_hook_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function getData() {\n  return fetch('/api').then(r => r.json());\n}\n// Fetches every call\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Memoized Promise**\n\n**Fix:**\n```typescript\nlet promise: Promise<Data> | null = null;\nasync function getData(): Promise<Data> {\n  if (!promise) promise = fetch('/api').then(r => r.json());\n  return promise;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_memoized_promise"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nenum Role {\n  Admin = 'admin',\n  User = 'user',\n}\nconst role: Role = Role.Admin;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum Union**\n\n**Fix:**\n```typescript\ntype Role = 'admin' | 'user';\nconst role: Role = 'admin';\n// String literal union vs enum\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_union"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction createMockUser() {\n  return { id: 1, name: 'Test' };\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Factory Typing**\n\n**Fix:**\n```typescript\ninterface User {\n  id: number;\n  name: string;\n}\ntype CreateUserOptions = Partial<User>;\nfunction createMockUser(options: CreateUserOptions = {}): User {\n  return { id: 1, name: 'Test', ...options };\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_factory_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nitems.forEach(item => item.value *= 2);\n// Mutation\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Traversal Pattern**\n\n**Fix:**\n```typescript\nfunction traverse<A, B>(fn: (a: A) => B): (arr: A[]) => B[] {\n  return (arr) => arr.map(fn);\n}\nconst doubled = traverse((item) => ({ ...item, value: item.value * 2 }))(items);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_traversal_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst visited = new WeakSet();\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing WeakSet Typing**\n\n**Fix:**\n```typescript\ninterface Visitable { id: string; }\nconst visited = new WeakSet<Visitable>();\n// Keys must be objects\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_weakset_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nnamespace MyApp {\n  export class User { }\n  export class Product { }\n  export class Order { }\n  // Everything in one namespace\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Namespace pollution**\n\n**Fix:**\n```typescript\n// Use ES modules instead of namespaces:\n// user.ts\nexport class User { }\n\n// product.ts\nexport class Product { }\n\n// order.ts\nexport class Order { }\n\n// Import what you need:\nimport { User } from './user';\nimport { Order } from './order';\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "namespace_pollution"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface OptionalUser {\n  name?: string;\n  email?: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Mapped Types**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\ntype OptionalUser = { [K in keyof User]?: User[K]; }\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_mapped_types"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// global.d.ts\ndeclare let __APP_CONFIG__: any;\ndeclare function __VERSION__(): string;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Ambient type declaration abuse**\n\n**Fix:**\n```typescript\n// Use proper module imports:\nimport { APP_CONFIG } from './config';\nimport { VERSION } from './version';\n// Ambient declarations bypass type checking\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "ambient_type_declaration_abuse"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst files = await globby(['src/**/*.ts', '!src/**/*.test.ts']);\n// string[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Globby Typing**\n\n**Fix:**\n```typescript\nconst files: string[] = await globby([\n  'src/**/*.ts',\n  '!src/**/*.test.ts',\n], { absolute: true });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_globby_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst { exec } = require('child_process');\nexec('ls', (error, stdout, stderr) => { });\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Child Process Typing**\n\n**Fix:**\n```typescript\nimport { exec } from 'child_process';\nexec('ls', (error: Error | null, stdout: string, stderr: string) => {\n  if (error) throw error;\n  console.log(stdout);\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_child_process_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst result = g(f(h(x)));\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Compose Function**\n\n**Fix:**\n```typescript\nfunction compose<T, U, V>(f: (t: U) => V, g: (t: T) => U): (t: T) => V {\n  return (t) => f(g(t));\n}\nconst result = compose(g, compose(f, h))(x);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_compose_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst ref = useRef();\nref.current.focus();\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Ref typing**\n\n**Fix:**\n```typescript\nconst ref = useRef<HTMLInputElement>(null);\nref.current?.focus();\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_ref_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst { password, ...publicUser } = user;\n// Destructure\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Omit**\n\n**Fix:**\n```typescript\nfunction omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n  const result = { ...obj };\n  for (const key of keys) delete result[key];\n  return result;\n}\nconst publicUser = omit(user, ['password']);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_omit"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction create<T>(template: T, overrides?: Partial<T>): T {\n  return { ...template, ...overrides };\n}\n// T inferred from overrides\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing NoInfer**\n\n**Fix:**\n```typescript\nfunction create<T>(template: NoInfer<T>, overrides?: Partial<T>): T {\n  return { ...template, ...overrides };\n}\n// Forces T from first argument\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_noinfer"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Callback = (value: string | number) => void;\n// Accepts too broad\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Function Covariance**\n\n**Fix:**\n```typescript\ntype Callback<T> = (value: T) => void;\n// Generic for type safety\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_function_covariance"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype A = { x: number; y: number };\ntype B = { x: number; z: string };\ntype AB = A | B;\n// Can't distinguish A from B\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Union with overlapping properties**\n\n**Fix:**\n```typescript\ntype A = { kind: 'a'; x: number; y: number };\ntype B = { kind: 'b'; x: number; z: string };\ntype AB = A | B;\n// Discriminant 'kind' makes narrowing possible\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "union_with_overlapping_properties"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst response = await fetch(url, {\n  method: 'POST',\n  body: JSON.stringify(data),\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Request Init Typing**\n\n**Fix:**\n```typescript\nconst response = await fetch(url, {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify(data),\n}));\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_request_init_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst data = fetchData();\n// Fetches immediately\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Lazy Promise**\n\n**Fix:**\n```typescript\nconst getData = (): Promise<Data> => fetchData();\n// Fetches on call\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_lazy_promise"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst value = input !== null && input !== undefined ? input : defaultVal;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with nullish coalescing**\n\n**Fix:**\n```typescript\nconst value = input ?? defaultVal;\n// Type: typeof defaultVal\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_nullish_coalescing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst factorial = (n: number): number => n === 0 ? 1 : n * factorial(n - 1);\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Hylo Pattern**\n\n**Fix:**\n```typescript\nfunction hylo<A, B, C>(\n  coalgebra: { empty: (a: A) => boolean; head: (a: A) => B; tail: (a: A) => A },\n  algebra: { nil: C; cons: (head: B, tail: C) => C }\n): (seed: A) => C {\n  return (seed) => {\n    const list: B[] = [];\n    let current = seed;\n    while (!coalgebra.empty(current)) {\n      list.push(coalgebra.head(current));\n      current = coalgebra.tail(current);\n    }\n    return list.reduceRight((acc, head) => algebra.cons(head, acc), algebra.nil);\n  };\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_hylo_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst allPositive = nums.every(n => n > 0);\n// Inferred\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Array.every/some Typing**\n\n**Fix:**\n```typescript\nconst allPositive: boolean = nums.every<number>((n): boolean => n > 0);\n// Explicit types\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_array.every/some_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Temperature = number;\n// No type safety\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Iso Pattern**\n\n**Fix:**\n```typescript\ntype Iso<F, T> = {\n  to: (f: F) => T;\n  from: (t: T) => F;\n};\nconst temperatureIso: Iso<number, Temperature> = {\n  to: (celsius) => celsius as Temperature,\n  from: (temp) => temp as number,\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_iso_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Action = { type: 'ADD'; val: number } | { type: 'REMOVE'; val: number };\nfunction handle(a: Action) {\n  if (a.type === 'ADDD') { /* typo - never matches */ }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Discriminant typo**\n\n**Fix:**\n```typescript\n// TypeScript should catch this at compile time if using switch + exhaustiveness\nfunction handle(a: Action) {\n  switch (a.type) {\n    case 'ADD': /* ... */ break;\n    case 'REMOVE': /* ... */ break;\n    default: {\n      const _exhaustive: never = a;\n      throw new Error(`Unknown: ${_exhaustive}`);\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "discriminant_typo"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction assertString(val: unknown): boolean {\n  if (typeof val !== 'string') return false;\n  return true;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Assertion Function**\n\n**Fix:**\n```typescript\nfunction assertString(val: unknown): asserts val is string {\n  if (typeof val !== 'string') {\n    throw new TypeError('Expected string');\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_assertion_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nif (status === Status.Active) { /* active code */ }\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum as Type Guard**\n\n**Fix:**\n```typescript\nfunction isActive(status: Status): boolean {\n  return status === Status.Active;\n}\n// Extracted guard function\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_as_type_guard"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Color = 'red' | 'green' | 'blue';\nfunction getHex(color: Color) {\n  switch (color) {\n    case 'red': return '#ff0000';\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with switch**\n\n**Fix:**\n```typescript\n// Switch narrowing\nfunction getHex(color: Color): string {\n  switch (color) {\n    case 'red': return '#ff0000'; // color is 'red'\n    case 'green': return '#00ff00'; // color is 'green'\n    case 'blue': return '#0000ff'; // color is 'blue'\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_switch"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst spy = jest.spyOn(obj, 'method');\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Spy Typing**\n\n**Fix:**\n```typescript\nconst spy = jest.spyOn(obj, 'method').mockReturnValue('test');\nexpect(spy).toHaveBeenCalledWith(args);\nspy.mockRestore();\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_spy_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst state = 'loading' as State;\n// Unsafe assertion\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with enum**\n\n**Fix:**\n```typescript\nconst state: State = 'loading';\n// Type-safe assignment\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_enum"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// a.ts\nimport { b } from './b';\nexport function a() { return b(); }\n\n// b.ts\nimport { a } from './a';\nexport function b() { return a(); }\n// Circular import\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Circular dependency**\n\n**Fix:**\n```typescript\n// Break circular dependencies:\n// 1. Extract shared types to a separate file\n// 2. Use dependency injection\n// 3. Lazy import for runtime-only dependencies\nimport('./b').then(({ b }) => b());\n// Or use forward references for type-only imports\nimport type { B } from './b';\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "circular_dependency"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Animal {\n  speak() { /* implementation */ }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Abstract Class**\n\n**Fix:**\n```typescript\nabstract class Animal {\n  abstract speak(): string;\n}\nclass Dog extends Animal {\n  speak(): string { return 'Woof!'; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_abstract_class"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Shape = Circle | Rect;\nfunction area(shape: Shape) {\n  // Cannot access shape-specific properties\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Union Discrimination**\n\n**Fix:**\n```typescript\ninterface Circle { kind: 'circle'; radius: number; }\ninterface Rect { kind: 'rect'; width: number; height: number; }\ntype Shape = Circle | Rect;\nfunction area(shape: Shape): number {\n  if (shape.kind === 'circle') {\n    return Math.PI * shape.radius ** 2; // Narrowed\n  }\n  return shape.width * shape.height; // Narrowed\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_union_discrimination"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { something } from 'untyped-lib';\n// No types\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing declare module**\n\n**Fix:**\n```typescript\n// types/untyped-lib.d.ts\ndeclare module 'untyped-lib' {\n  export function something(): void;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_declare_module"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction UserCard(props) {\n  return <div>{props.name}</div>;\n  // No type checking on props\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing React component typing**\n\n**Fix:**\n```typescript\ninterface UserCardProps {\n  name: string;\n  email?: string;\n  avatar?: string;\n}\n\nfunction UserCard({ name, email, avatar }: UserCardProps) {\n  return (\n    <div>\n      <h2>{name}</h2>\n      {email && <p>{email}</p>}\n      {avatar && <img src={avatar} alt={name} />}\n    </div>\n  );\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_react_component_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  name: string;\n}\n// Not exported\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing export in .d.ts**\n\n**Fix:**\n```typescript\nexport interface User {\n  name: string;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_export_in_.d.ts"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2020\",\n    \"module\": \"commonjs\"\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing strict in tsconfig**\n\n**Fix:**\n```typescript\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2022\",\n    \"module\": \"ESNext\",\n    \"strict\": true,\n    \"esModuleInterop\": true,\n    \"skipLibCheck\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"resolveJsonModule\": true,\n    \"isolatedModules\": true\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_strict_in_tsconfig"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction fetchData(): Promise<Data> { return ...; }\ntype Result = ReturnType<typeof fetchData>;\n// Result is Promise<Data>, not Data\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using Awaited**\n\n**Fix:**\n```typescript\nfunction fetchData(): Promise<Data> { return ...; }\ntype Result = Awaited<ReturnType<typeof fetchData>>;\n// Awaited unwraps the Promise, giving Data\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_awaited"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nenum Priority {\n  Low = 1,\n  Medium = 2,\n  High = 4,\n}\n// No combination support\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum Computation**\n\n**Fix:**\n```typescript\nenum Priority {\n  None = 0,\n  Low = 1,\n  Medium = 2,\n  High = 4,\n}\n// Use bitwise for combinations:\nconst combined = Priority.Low | Priority.High;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_computation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst results = new Map();\nfor (const [key, value] of entries) {\n  try { results.set(key, await process(value)); }\n  catch { results.set(key, null); }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Handling in Map**\n\n**Fix:**\n```typescript\ntype Result<T> = { success: true; value: T } | { success: false; error: Error };\nasync function processEntries<T>(entries: Map<string, T>): Promise<Map<string, Result<any>>> {\n  const results = new Map<string, Result<any>>();\n  for (const [key, value] of entries) {\n    try {\n      results.set(key, { success: true, value: await process(value) });\n    } catch (error) {\n      results.set(key, { success: false, error: error as Error });\n    }\n  }\n  return results;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_handling_in_map"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nlet resolve!: (value: string) => void;\nlet reject!: (error: Error) => void;\nconst promise = new Promise<string>((res, rej) => {\n  resolve = res;\n  reject = rej;\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Promise.withResolvers**\n\n**Fix:**\n```typescript\n// TypeScript 5.5+\nconst { promise, resolve, reject } = Promise.withResolvers<string>();\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_promise.withresolvers"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst result = step3(step2(step1(data)));\n// Error in any step crashes all\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Handling in Pipe**\n\n**Fix:**\n```typescript\nfunction pipe<T>(value: T, ...fns: Array<(val: T) => T>): T {\n  return fns.reduce((acc, fn) => fn(acc), value);\n}\n// Or use Either/Result monad for error handling\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_handling_in_pipe"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  name: string;\n}\ninterface User {\n  email: string;\n}\n// Merged automatically\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Interface Declaration Merging**\n\n**Fix:**\n```typescript\n// Interfaces merge automatically\ninterface User {\n  name: string;\n}\ninterface User {\n  email: string;\n}\n// Equivalent to:\n// interface User { name: string; email: string; }\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_interface_declaration_merging"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(value: string | null | undefined) {\n  if (value) return value.length;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing NonNullable**\n\n**Fix:**\n```typescript\nfunction process(value: string | null | undefined): number {\n  const clean: NonNullable<typeof value> = value!;\n  return clean.length;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_nonnullable"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst result = format(transform(preprocess(data)));\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Pipe Function**\n\n**Fix:**\n```typescript\nfunction pipe<T, U>(a: (t: T) => U, b: (u: U) => U): (t: T) => U {\n  return (t) => b(a(t));\n}\n// Left-to-right composition\nconst result = data |> preprocess |> transform |> format;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_pipe_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst nested = flat.reduce((acc, item) => {\n  const parent = acc.find(p => p.id === item.parentId);\n  if (parent) parent.children.push(item);\n  return acc;\n}, []);\n// Complex reduce\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Unflattener**\n\n**Fix:**\n```typescript\nfunction unflatten<T extends { id: number; parentId: number | null }>(items: T[]): TWithChildren[] {\n  const map = new Map<number, TWithChildren>();\n  const roots: TWithChildren[] = [];\n  for (const item of items) {\n    const node = { ...item, children: [] };\n    map.set(item.id, node);\n    if (item.parentId === null) roots.push(node);\n    else {\n      const parent = map.get(item.parentId);\n      if (parent) parent.children.push(node);\n    }\n  }\n  return roots;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_unflattener"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction multiply(a: number, b: number, c: number) { return a * b * c; }\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Curry Automatic**\n\n**Fix:**\n```typescript\n// Manual curry\nfunction curry<T, U, R>(fn: (a: T, b: U) => R): (a: T) => (b: U) => R {\n  return (a) => (b) => fn(a, b);\n}\nconst multiply = curry((a, b) => a * b);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_curry_automatic"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  password: string;\n}\ntype PublicUser = {\n  name: string;\n  email: string;\n};\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Omit Utility**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  password: string;\n}\ntype PublicUser = Omit<User, 'password'>;\n// Exclude sensitive fields\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_omit_utility"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function fetchUser(id: number) {\n  return fetch(`/api/users/${id}`).then(r => r.json());\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Async Return Type**\n\n**Fix:**\n```typescript\nasync function fetchUser(id: number): Promise<User> {\n  const response = await fetch(`/api/users/${id}`);\n  return response.json();\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_async_return_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Shape {\n  kind: 'circle' | 'rect';\n  radius?: number;\n  width?: number;\n  height?: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Discriminated Union**\n\n**Fix:**\n```typescript\ninterface Circle {\n  kind: 'circle';\n  radius: number;\n}\ninterface Rect {\n  kind: 'rect';\n  width: number;\n  height: number;\n}\ntype Shape = Circle | Rect;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_discriminated_union"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Config {\n  [key: string]: any;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with index signature**\n\n**Fix:**\n```typescript\ninterface Config {\n  [key: string]: string | number;\n}\n// Constrains value types\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_index_signature"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst item = arr[0];\n// Type: T\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing noUncheckedIndexedAccess**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\"compilerOptions\": {\n  \"noUncheckedIndexedAccess\": true\n}}\n// Type: T | undefined\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_nouncheckedindexedaccess"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Status = 'loading' | 'success' | 'error';\nfunction handle(s: Status) {\n  if (s === 'loading') { /* loading */ }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with equality**\n\n**Fix:**\n```typescript\n// Equality narrowing\nfunction handle(s: Status): void {\n  if (s === 'loading') { /* s is 'loading' */ }\n  else if (s === 'success') { /* s is 'success' */ }\n  else { /* s is 'error' */ }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_equality"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nif (errorCount > limit) stop();\n// No sliding window\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Rate Limiter**\n\n**Fix:**\n```typescript\nclass RateLimiter {\n  private timestamps: number[] = [];\n  constructor(private limit: number, private windowMs: number) {}\n  allow(): boolean {\n    const now = Date.now();\n    this.timestamps = this.timestamps.filter(t => now - t < this.windowMs);\n    if (this.timestamps.length >= this.limit) return false;\n    this.timestamps.push(now);\n    return true;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_rate_limiter"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype ToArray<T> = T extends any ? T[] : never;\n// Distributes\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Non-distributive Conditional**\n\n**Fix:**\n```typescript\n// Prevent distribution with tuple trick\ntype ToArray<T> = [T] extends [any] ? T[] : never;\ntype Result = ToArray<string | number>;\n// (string | number)[]\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_non-distributive_conditional"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst filtered = items.filter(item => item.active);\n// Recalculates every render\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Memoization**\n\n**Fix:**\n```typescript\nconst filtered = useMemo(() => items.filter(item => item.active), [items]);\n// Memoized\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_memoization"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst adults = people.filter(p => p.age >= 18);\n// Type: Person[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Array.filter Typing**\n\n**Fix:**\n```typescript\nfunction isAdult(person: Person): person is Adult {\n  return person.age >= 18;\n}\nconst adults = people.filter(isAdult);\n// Type: Adult[]\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_array.filter_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst ws = new WebSocket(url);\nws.onmessage = (event) => { console.log(event.data); };\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing WebSocket Typing**\n\n**Fix:**\n```typescript\nconst ws = new WebSocket<UserData>(url);\nws.onmessage = (event: MessageEvent<string>) => {\n  const data: UserData = JSON.parse(event.data);\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_websocket_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nexport { User } from './user';\n// May emit runtime\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Re-export**\n\n**Fix:**\n```typescript\nexport type { User } from './user';\n// Type-only re-export\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_re-export"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [state, dispatch] = useReducer(reducer, {});\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Reducer Typing**\n\n**Fix:**\n```typescript\ntype Action = { type: 'LOAD_START' } | { type: 'LOAD_SUCCESS'; data: User } | { type: 'LOAD_ERROR'; error: Error };\nconst reducer = (state: AppState, action: Action): AppState => {\n  switch (action.type) {\n    case 'LOAD_START': return { ...state, loading: true };\n    case 'LOAD_SUCCESS': return { ...state, loading: false, data: action.data };\n    case 'LOAD_ERROR': return { ...state, loading: false, error: action.error };\n    default: return state;\n  }\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_reducer_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction useData() {\n  const [data, setData] = useState();\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Hook typing**\n\n**Fix:**\n```typescript\nfunction useData(): { data: User | null; loading: boolean } {\n  const [data, setData] = useState<User | null>(null);\n  const [loading, setLoading] = useState(true);\n  return { data, loading };\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_hook_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nif (failures > threshold) throw new Error('Circuit open');\n// No half-open state\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Circuit Half-Open**\n\n**Fix:**\n```typescript\ntype State = 'closed' | 'open' | 'half-open';\nclass CircuitBreaker {\n  state: State = 'closed';\n  private failures = 0;\n  private lastFailureTime = 0;\n  private resetTimeout = 30000;\n  async call<T>(fn: () => Promise<T>): Promise<T> {\n    if (this.state === 'open') {\n      if (Date.now() - this.lastFailureTime > this.resetTimeout) {\n        this.state = 'half-open';\n      } else {\n        throw new Error('Circuit open');\n      }\n    }\n    try {\n      const result = await fn();\n      this.state = 'closed';\n      this.failures = 0;\n      return result;\n    } catch {\n      this.failures++;\n      this.lastFailureTime = Date.now();\n      this.state = 'open';\n      throw new Error('Circuit open');\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_circuit_half-open"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction reducer(state: State, action: Action): State {\n  if (action.type === 'INCREMENT') return { count: state.count + 1 };\n  return state;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Exhaustiveness check missing in reducer**\n\n**Fix:**\n```typescript\nfunction reducer(state: State, action: Action): State {\n  switch (action.type) {\n    case 'INCREMENT': return { count: state.count + 1 };\n    case 'DECREMENT': return { count: state.count - 1 };\n    default: {\n      const _exhaustive: never = action;\n      throw new Error(`Unknown action: ${_exhaustive}`);\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "exhaustiveness_check_missing_in_reducer"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nlet state = 'idle';\nfunction start() { state = 'loading'; }\nfunction success() { state = 'loaded'; }\n// No validation\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Machine**\n\n**Fix:**\n```typescript\ntype State = 'idle' | 'loading' | 'loaded' | 'error';\ntype Transition = {\n  from: State;\n  to: State;\n};\nconst transitions: Record<string, Transition> = {\n  start: { from: 'idle', to: 'loading' },\n  success: { from: 'loading', to: 'loaded' },\n  fail: { from: 'loading', to: 'error' },\n  reset: { from: 'error', to: 'idle' },\n};\nclass StateMachine {\n  state: State = 'idle';\n  transition(event: string): void {\n    const t = transitions[event];\n    if (!t || t.from !== this.state) throw new Error(`Invalid transition: ${event}`);\n    this.state = t.to;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_machine"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst controller = new AbortController();\nconst data = await fetch(url, { signal: controller.signal });\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing AbortSignal typing**\n\n**Fix:**\n```typescript\nasync function fetchData(url: string, timeout = 5000): Promise<Response> {\n  const controller = new AbortController();\n  const timeoutId = setTimeout(() => controller.abort(), timeout);\n  try {\n    return await fetch(url, { signal: controller.signal });\n  } finally {\n    clearTimeout(timeoutId);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_abortsignal_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction processData(data: any): any {\n  return data;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Any type escape hatch**\n\n**Fix:**\n```typescript\nfunction processData<T>(data: T): T {\n  return data;\n}\n// Generics preserve type information. any disables type checking.\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "any_type_escape_hatch"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nerrors.forEach(e => handle(e));\n// No priority\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Prioritization**\n\n**Fix:**\n```typescript\ntype Severity = 'critical' | 'warning' | 'info';\ninterface PrioritizedError {\n  error: Error;\n  severity: Severity;\n}\nconst priority: Severity[] = ['critical', 'warning', 'info'];\nerrors\n  .sort((a, b) => priority.indexOf(a.severity) - priority.indexOf(b.severity))\n  .forEach(e => handle(e.error));\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_prioritization"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(data: any) {\n  return data.value;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: any Type**\n\n**Fix:**\n```typescript\nfunction process(data: { value: unknown }) {\n  return data.value;\n}\n// Avoid any, use unknown instead\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "any_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst userSchema = z.object({\n  name: z.string(),\n  email: z.string().email()\n});\n\ninterface User {\n  name: string;\n  email: string;\n}\n// Duplicated schema and interface\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not inferring types from Zod**\n\n**Fix:**\n```typescript\nconst userSchema = z.object({\n  name: z.string(),\n  email: z.string().email()\n});\n\ntype User = z.infer<typeof userSchema>;\n// Single source of truth - type derived from schema\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_inferring_types_from_zod"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst data = await fetchPrimary();\n// No fallback\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Fallback Pattern**\n\n**Fix:**\n```typescript\nasync function withFallback<T>(primary: () => Promise<T>, fallback: () => Promise<T>): Promise<T> {\n  try { return await primary(); }\n  catch { return await fallback(); }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_fallback_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst data = await fetch(url);\n// Cannot cancel\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Cancellable Promise**\n\n**Fix:**\n```typescript\nasync function cancellableFetch(url: string): Promise<Response> {\n  const controller = new AbortController();\n  const timeout = setTimeout(() => controller.abort(), 5000);\n  try {\n    return await fetch(url, { signal: controller.signal });\n  } finally {\n    clearTimeout(timeout);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_cancellable_promise"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype HostType = string;\n// Duplicated\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Indexed Access**\n\n**Fix:**\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\ntype HostType = Config['host']; // string\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_indexed_access"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// @ts-ignore\nlegacyLibrary.doSomething();\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing @ts-ignore**\n\n**Fix:**\n```typescript\n// Prefer type augmentation over @ts-ignore\ndeclare module 'legacy-library' {\n  function doSomething(): void;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_@ts-ignore"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n/// <reference types=\"node\" />\nconst fs = require('fs');\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Using triple-slash directives**\n\n**Fix:**\n```typescript\n// Use proper imports instead:\nimport * as fs from 'node:fs';\n// Add @types/node to devDependencies\n// Remove triple-slash directives\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "using_triple-slash_directives"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Props {\n  name: string;\n  age: number;\n  email: string;\n}\ninterface PropsOptional {\n  name?: string;\n  age?: number;\n  email?: string;\n}\ninterface PropsReadonly {\n  readonly name: string;\n  readonly age: number;\n  readonly email: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using mapped types**\n\n**Fix:**\n```typescript\ninterface Props {\n  name: string;\n  age: number;\n  email: string;\n}\ntype PropsOptional = { [K in keyof Props]?: Props[K] };\ntype PropsReadonly = { readonly [K in keyof Props]: Props[K] };\n// Mapped types derive from existing types\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_mapped_types"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst id = setTimeout(() => {}, 1000);\nclearTimeout(id);\n// id is number in Node, ReturnType in browser\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing setTimeout typing**\n\n**Fix:**\n```typescript\nconst id: ReturnType<typeof setTimeout> = setTimeout(() => {}, 1000);\nclearTimeout(id);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_settimeout_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst buf = Buffer.from(str);\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Buffer Typing**\n\n**Fix:**\n```typescript\nconst buf = Buffer.from(str, 'utf-8');\nconst str: string = buf.toString('utf-8');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_buffer_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nexport default async function handler(req, res) {\n  // req: any\n  res.json({ ok: true });\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Untyped Next.js API route**\n\n**Fix:**\n```typescript\nimport { NextApiRequest, NextApiResponse } from 'next';\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  res.status(200).json({ ok: true });\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "untyped_next.js_api_route"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nexpect(data).toEqual({ id: 1, name: 'test' });\n// No type hint\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Matcher Typing**\n\n**Fix:**\n```typescript\nexpect(data).toEqual<User>({ id: 1, name: 'test' });\n// Or use type predicate\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_matcher_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass User {\n  name: string;\n  getName() { return this.name; }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Implements**\n\n**Fix:**\n```typescript\ninterface Named {\n  getName(): string;\n}\nclass User implements Named {\n  name: string;\n  getName(): string { return this.name; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_implements"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Config {\n  timeout?: number;\n}\nconst config: Config = { timeout: undefined };\n// Allowed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing exactOptionalPropertyTypes**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\"compilerOptions\": {\n  \"exactOptionalPropertyTypes\": true\n}}\n// timeout: undefined is now an error\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_exactoptionalpropertytypes"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype NumericKeys = 'age' | 'score';\n// Manual\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Exclude**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  age: number;\n  score: number;\n}\ntype NumericKeys = keyof Pick<User, Extract<keyof User, never>>;\n// Or: type NumericKeys = { [K in keyof User]: User[K] extends number ? K : never }[keyof User];\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_exclude"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface OptionalUser {\n  name?: string;\n  email?: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Mapped Type**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\ntype OptionalUser = { [K in keyof User]?: User[K]; }\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_mapped_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst el = document.getElementById('app');\nconst text = el.innerHTML;\n// el could be null\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Non-Null Assertion**\n\n**Fix:**\n```typescript\nconst el = document.getElementById('app');\nif (!el) throw new Error('Element not found');\nconst text = el.innerHTML;\n// Or: const text = el!.innerHTML;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_non-null_assertion"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst jwt = require('jsonwebtoken');\nconst token = jwt.sign({ userId }, secret);\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing JWT Typing**\n\n**Fix:**\n```typescript\nimport jwt from 'jsonwebtoken';\ninterface JwtPayload {\n  userId: string;\n  iat?: number;\n  exp?: number;\n}\nconst token: string = jwt.sign({ userId }, secret, {\n  expiresIn: '24h',\n});\nconst decoded: JwtPayload = jwt.verify(token, secret) as JwtPayload;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_jwt_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst { name, email } = user;\nconst picked = { name, email };\n// Manual\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Pick**\n\n**Fix:**\n```typescript\nfunction pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n  const result = {} as Pick<T, K>;\n  for (const key of keys) result[key] = obj[key];\n  return result;\n}\nconst picked = pick(user, ['name', 'email']);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_pick"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config = {\n  host: 'localhost',\n  port: 3000,\n  extra: 'value',\n};\n// Allows extra properties\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing satisfies**\n\n**Fix:**\n```typescript\nconst config = {\n  host: 'localhost',\n  port: 3000,\n  extra: 'value',\n} satisfies ServerConfig;\n// Validates structure, preserves type\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_satisfies"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst calculate = (a: number, b: number) => {\n  return a + b;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing explicit return type**\n\n**Fix:**\n```typescript\nconst calculate = (a: number, b: number): number => {\n  return a + b;\n};\n// Explicit return types document intent and catch bugs\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_explicit_return_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nenum Status {\n  Active,\n  Inactive,\n  Pending,\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Const Enum**\n\n**Fix:**\n```typescript\nconst enum Status {\n  Active,\n  Inactive,\n  Pending,\n}\n// Inlined at compile time\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_const_enum"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Result {\n  value: any;\n}\n// Not generic - loses type information\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Generic extends vs implements**\n\n**Fix:**\n```typescript\nclass Result<T> {\n  constructor(public value: T) {}\n  isSuccess(): this is Success<T> {\n    return true;\n  }\n}\nclass Success<T> extends Result<T> {}\nclass Failure<E> extends Result<E> {}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "generic_extends_vs_implements"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Event = 'click' | 'hover' | 'focus';\n// Manual\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Template Literal Type**\n\n**Fix:**\n```typescript\ntype Action = 'click' | 'hover' | 'focus';\ntype EventName = `${Action}Event`;\n// 'clickEvent' | 'hoverEvent' | 'focusEvent'\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_template_literal_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nString.prototype.startsWith = function() {};\n// Not typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Global Augmentation**\n\n**Fix:**\n```typescript\ndeclare global {\n  interface String {\n    startsWith(search: string): boolean;\n  }\n}\nexport {};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_global_augmentation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"skipLibCheck\": true\n  }\n}\n// Hides type errors in dependencies\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Using skipLibCheck true blindly**\n\n**Fix:**\n```typescript\n// skipLibCheck: true is reasonable for performance,\n// but fix root causes:\n// 1. Update dependencies\n// 2. Use @ts-ignore sparingly\n// 3. Prefer type-safe alternatives\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "using_skiplibcheck_true_blindly"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nexport { User };\n// Emits even if only type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Export Type Syntax**\n\n**Fix:**\n```typescript\nexport type { User };\n// Type-only export\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_export_type_syntax"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [theme, setTheme] = useState('light');\n// Lost on refresh\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Persistence**\n\n**Fix:**\n```typescript\nconst [theme, setTheme] = useState<string>(() => {\n  return localStorage.getItem('theme') ?? 'light';\n});\nuseEffect(() => {\n  localStorage.setItem('theme', theme);\n}, [theme]);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_persistence"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Mutable<T> = T;\n// Doesn't remove readonly\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using keyof with mapped type**\n\n**Fix:**\n```typescript\ntype Mutable<T> = {\n  -readonly [K in keyof T]: T[K];\n};\n// -readonly modifier removes readonly flag\n// Also: -?, +?, +readonly, -readonly\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_keyof_with_mapped_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n{\"compilerOptions\": {\n  \"module\": \"ESNext\"\n}}\n// Uses classic resolution\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing moduleResolution**\n\n**Fix:**\n```typescript\n{\"compilerOptions\": {\n  \"module\": \"ESNext\",\n  \"moduleResolution\": \"bundler\"\n}}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_moduleresolution"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction create() { return { id: 1, name: 'test' }; }\ntype Item = { id: number; name: string; };\n// Duplicated\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing ReturnType**\n\n**Fix:**\n```typescript\nfunction create() { return { id: 1, name: 'test' }; }\ntype Item = ReturnType<typeof create>;\n// Derived from function\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_returntype"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Temperature {\n  _celsius = 0;\n  get celsius() { return this._celsius; }\n  set celsius(value) { this._celsius = value; }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Getter/Setter Typing**\n\n**Fix:**\n```typescript\nclass Temperature {\n  private _celsius: number = 0;\n  get celsius(): number { return this._celsius; }\n  set celsius(value: number) { this._celsius = value; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_getter/setter_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { User } from './user';\n// Unclear if type or value\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Import Kind**\n\n**Fix:**\n```typescript\nimport type { User } from './user';\n// Explicit type import\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_import_kind"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction range(start: number, end: number): number[] {\n  const result = [];\n  for (let i = start; i < end; i++) result.push(i);\n  return result;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Anamorphism**\n\n**Fix:**\n```typescript\ninterface Coalgebra<A, B> {\n  empty: (a: A) => boolean;\n  head: (a: A) => B;\n  tail: (a: A) => A;\n}\nfunction ana<B, A>(coalgebra: Coalgebra<B, A>): (seed: B) => A[] {\n  return (seed) => {\n    const result: A[] = [];\n    let current = seed;\n    while (!coalgebra.empty(current)) {\n      result.push(coalgebra.head(current));\n      current = coalgebra.tail(current);\n    }\n    return result;\n  };\n}\nconst range = ana({\n  empty: (s) => s >= end,\n  head: (s) => s,\n  tail: (s) => s + 1,\n})(start);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_anamorphism"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst resolvers = {\n  Query: {\n    user: (_, { id }) => db.user(id),\n  }\n};\n// No type checking on resolvers\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not typing context for GraphQL**\n\n**Fix:**\n```typescript\n// With graphql-codegen:\n// 1. Generate types from schema\n// 2. Use typed resolvers\n\nimport { Resolvers } from './generated/types';\n\nconst resolvers: Resolvers = {\n  Query: {\n    user: (_, { id }, context) => context.db.user(id),\n  }\n};\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_typing_context_for_graphql"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst value = Object.values(Status).filter(v => typeof v === 'number');\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum Value Typing**\n\n**Fix:**\n```typescript\ntype StatusValues = Status[StatusKey];\n// Or iterate with Object.entries\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_value_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Range {\n  start: number;\n  end: number;\n  constructor(range: [number, number]) {\n    [this.start, this.end] = range;\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Constructor Overload**\n\n**Fix:**\n```typescript\nclass Range {\n  start: number;\n  end: number;\n  constructor(range: [number, number]);\n  constructor(start: number, end: number);\n  constructor(start: number | [number, number], end?: number) {\n    if (Array.isArray(start)) {\n      [this.start, this.end] = start;\n    } else {\n      this.start = start;\n      this.end = end!;\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_constructor_overload"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction log(obj: object) {\n  console.log(obj);\n  // object accepts arrays, functions, etc.\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Using object type**\n\n**Fix:**\n```typescript\nfunction log(obj: Record<string, unknown>) {\n  console.log(obj);\n  // Record<string, unknown> is the type-safe version of \"plain object\"\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "using_object_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function callApi() {\n  return fetch('/api');\n}\n// No circuit breaker\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Circuit Breaker**\n\n**Fix:**\n```typescript\ntype State = 'closed' | 'open' | 'half-open';\nclass CircuitBreaker {\n  private state: State = 'closed';\n  private failures = 0;\n  private threshold = 5;\n  async call<T>(fn: () => Promise<T>): Promise<T> {\n    if (this.state === 'open') throw new Error('Circuit open');\n    try {\n      const result = await fn();\n      this.failures = 0;\n      this.state = 'closed';\n      return result;\n    } catch {\n      this.failures++;\n      if (this.failures >= this.threshold) this.state = 'open';\n      throw new Error('Circuit open after threshold');\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_circuit_breaker"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction create() { return { id: 1, name: 'test' }; }\ntype Item = { id: number; name: string; };\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing ReturnType Extraction**\n\n**Fix:**\n```typescript\nfunction create() { return { id: 1, name: 'test' }; }\ntype Item = ReturnType<typeof create>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_returntype_extraction"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(val: string | null) {\n  if (val) {\n    return val.length;\n  }\n  return 0;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with truthiness**\n\n**Fix:**\n```typescript\n// Truthiness narrowing\nfunction process(val: string | null): number {\n  if (val != null) {\n    return val.length; // val is string\n  }\n  return 0;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_truthiness"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Get = 'getUser' | 'getPost';\ntype Handlers = Record<Get, () => void>;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Indexed Access with Template**\n\n**Fix:**\n```typescript\ntype Entity = 'user' | 'post';\ntype Action = `get${Entity}`;\ntype Handlers = Record<Action, () => void>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_indexed_access_with_template"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst data = input.map(transform).filter(valid).slice(0, 10);\n// Hard to read\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Transform Pipeline**\n\n**Fix:**\n```typescript\nconst pipeline = pipe(\n  map(transform),\n  filter(valid),\n  take(10)\n);\nconst data = pipeline(input);\n// Composable pipeline\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_transform_pipeline"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function fetchUser(id: number): Promise<User> {\n  const response = await fetch(`/api/users/${id}`);\n  if (!response.ok) throw new Error('Not found');\n  return response.json();\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Result pattern**\n\n**Fix:**\n```typescript\ntype Result<T, E> = { ok: true; data: T } | { ok: false; error: E };\nasync function fetchUser(id: number): Promise<Result<User, Error>> {\n  const response = await fetch(`/api/users/${id}`);\n  if (!response.ok) return { ok: false, error: new Error('Not found') };\n  return { ok: true, data: await response.json() };\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_result_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype StringOrNum = string | number;\ntype Processed<T> = T;\n// Doesn't differentiate based on input type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Manual type branching**\n\n**Fix:**\n```typescript\ntype Processed<T> = T extends string\n  ? T extends `${number}`\n    ? number\n    : T\n  : T extends number\n    ? string\n    : T;\n// Conditional types branch based on type relationships\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "manual_type_branching"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction merge<A, B, C>(a: A, b: B): A & B {\n  return { ...a, ...b };\n  // C is declared but unused\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Multiple generic parameters unused**\n\n**Fix:**\n```typescript\nfunction merge<A, B>(a: A, b: B): A & B {\n  return { ...a, ...b };\n}\n// Only declare generics you actually use\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "multiple_generic_parameters_unused"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ncatch (error) {\n  throw error;\n}\n// Passes through raw error\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Mapping**\n\n**Fix:**\n```typescript\ncatch (error) {\n  if (error instanceof TypeError) {\n    throw new ValidationError('Invalid input');\n  }\n  throw new AppError('Unexpected error', 'UNEXPECTED');\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_mapping"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass NotFoundError extends Error {\n  constructor(resource: string) {\n    super(`${resource} not found`);\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Custom error missing name property**\n\n**Fix:**\n```typescript\nclass NotFoundError extends Error {\n  constructor(public resource: string) {\n    super(`${resource} not found`);\n    this.name = 'NotFoundError';\n    Object.setPrototypeOf(this, new.target.prototype);\n  }\n}\n// name property for instanceof checks\n// setPrototypeOf for proper instanceof behavior\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "custom_error_missing_name_property"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype StringKeys = 'name' | 'email';\n// Manual\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Extract**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  age: number;\n}\ntype StringKeys = Extract<keyof User, 'name' | 'email'>;\n// Extract matching keys\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_extract"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handle(state: 'a' | 'b' | 'c') {\n  if (state === 'a') { }\n  else if (state === 'b') { }\n  // Missing 'c' case\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Never Check**\n\n**Fix:**\n```typescript\nfunction handle(state: 'a' | 'b' | 'c'): void {\n  switch (state) {\n    case 'a': break;\n    case 'b': break;\n    case 'c': break;\n    default: {\n      const _exhaustive: never = state;\n      throw new Error(`Unhandled: ${_exhaustive}`);\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_never_check"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config = {\n  host: 'localhost',\n  port: 3000,\n} as ServerConfig;\n// Loses specific type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with satisfies**\n\n**Fix:**\n```typescript\nconst config = {\n  host: 'localhost',\n  port: 3000,\n} satisfies ServerConfig;\n// Validates + preserves literal types\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_satisfies"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction forEach(items: string[], callback: any) {\n  items.forEach(item => callback(item));\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Callback Type**\n\n**Fix:**\n```typescript\nfunction forEach(items: string[], callback: (item: string, index: number) => void): void {\n  items.forEach((item, index) => callback(item, index));\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_callback_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntest('adds numbers', () => {\n  expect(add(1, 2)).toBe(3);\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Typing**\n\n**Fix:**\n```typescript\nimport { describe, it, expect } from '@jest/globals';\ndescribe('add', () => {\n  it('should add two numbers', () => {\n    expect(add(1, 2)).toBe(3);\n  });\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Repository {\n  find(id: any): any;\n  save(entity: any): void;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using generic constraint for method params**\n\n**Fix:**\n```typescript\ninterface Repository<T, ID = number> {\n  find(id: ID): T | undefined;\n  save(entity: T): void;\n  findAll(): T[];\n}\n// Generic interface constrains method types\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_generic_constraint_for_method_params"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction parse(input: any): any {\n  return JSON.parse(input);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: unknown Instead of any**\n\n**Fix:**\n```typescript\nfunction parse(input: string): unknown {\n  return JSON.parse(input);\n}\n// unknown forces type checking before use\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "unknown_instead_of_any"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// Using a library without types\nimport * as _ from 'lodash';\n// No type definitions\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing @types package**\n\n**Fix:**\n```typescript\n// npm install --save-dev @types/lodash\n// TypeScript will automatically use @types/* packages\n// For libraries without types: create a .d.ts file\n// Or contribute types to DefinitelyTyped\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_@types_package"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype NonNullable<T> = T;\n// Doesn't handle unions properly\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using distributive conditional**\n\n**Fix:**\n```typescript\ntype NonNullable<T> = T extends null | undefined ? never : T;\n// Distributive: applied to each member of union\n// NonNullable<string | null | undefined> => string\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_distributive_conditional"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function getData(): Promise<Data> {\n  return fetch('/api').then(r => r.json());\n}\n// No cache on failure\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Fallback Cache**\n\n**Fix:**\n```typescript\nclass CachedFetcher<T> {\n  private cache: T | null = null;\n  constructor(private fetch: () => Promise<T>) {}\n  async get(): Promise<T> {\n    try { this.cache = await this.fetch(); }\n    catch { if (!this.cache) throw new Error('No cache and fetch failed'); }\n    return this.cache;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_fallback_cache"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst result = trim(toUpper(replace(str, /pattern/g, '')));\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Pipe Operator Pattern**\n\n**Fix:**\n```typescript\nfunction pipe<T>(value: T, ...fns: Array<(val: T) => T>): T {\n  return fns.reduce((acc, fn) => fn(acc), value);\n}\nconst result = pipe(str, s => replace(s, /pattern/g, ''), toUpper, trim);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_pipe_operator_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(first: string, rest: unknown[]) { }\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Rest Tuple**\n\n**Fix:**\n```typescript\nfunction process(first: string, ...rest: number[]): void { }\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_rest_tuple"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handleClick(event) {\n  const value = event.target.value;\n  // event: any\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Untyped event handler**\n\n**Fix:**\n```typescript\nfunction handleClick(event: React.ChangeEvent<HTMLInputElement>) {\n  const value = event.target.value;\n  // Properly typed - value is string\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "untyped_event_handler"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst STATUS_ACTIVE = 'active';\nconst STATUS_INACTIVE = 'inactive';\nconst STATUS_PENDING = 'pending';\n// String literals - no type safety\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using enum for constants**\n\n**Fix:**\n```typescript\nenum Status {\n  Active = 'active',\n  Inactive = 'inactive',\n  Pending = 'pending'\n}\n// Or const enum for compile-time only:\n// const enum Status { Active = 'active', ... }\n// Or string union type:\n// type Status = 'active' | 'inactive' | 'pending'\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_enum_for_constants"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nlet config = getConfig();\n// Implicit any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Implicit any in Variable**\n\n**Fix:**\n```typescript\ninterface Config { url: string; timeout: number; }\nlet config: Config = getConfig();\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "implicit_any_in_variable"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Dog extends Animal {\n  bark() { return 'Woof!'; }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Inheritance Typing**\n\n**Fix:**\n```typescript\nabstract class Animal {\n  abstract speak(): string;\n}\nclass Dog extends Animal {\n  speak(): string { return 'Woof!'; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_inheritance_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  age: number;\n}\ninterface UserUpdate {\n  name?: string;\n  email?: string;\n  age?: number;\n}\n// Duplicated\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Manual partial type**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  age: number;\n}\ntype UserUpdate = Partial<User>;\n// Partial makes all properties optional\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "manual_partial_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// Custom types not found\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing typeRoots**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"typeRoots\": [\"./node_modules/@types\", \"./types\"]\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_typeroots"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Logger {\n  log(msg: string) { console.log(msg); }\n}\nconst logger1 = new Logger();\nconst logger2 = new Logger();\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Singleton Pattern**\n\n**Fix:**\n```typescript\nclass Logger {\n  private static instance: Logger;\n  private constructor() {}\n  static getInstance(): Logger {\n    if (!Logger.instance) Logger.instance = new Logger();\n    return Logger.instance;\n  }\n  log(msg: string) { console.log(msg); }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_singleton_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype DeepReadonly<T> = {\n  readonly [K in keyof T]: T[K];\n};\n// Only shallow\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Recursive Type**\n\n**Fix:**\n```typescript\ntype DeepReadonly<T> = {\n  readonly [K in keyof T]: T[K] extends object\n    ? DeepReadonly<T[K]>\n    : T[K];\n};\n// Recursive readonly\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_recursive_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst archive = archiver('zip');\narchive.file('file.txt', { name: 'dest.txt' });\narchive.finalize();\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Archiver Typing**\n\n**Fix:**\n```typescript\nimport archiver from 'archiver';\nimport { Writable } from 'stream';\nconst archive = archiver('zip', { zlib: { level: 9 } });\narchive.pipe(output as Writable);\narchive.file('file.txt', { name: 'dest.txt' });\nawait archive.finalize();\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_archiver_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst groups: Record<string, Item[]> = {};\nfor (const item of items) {\n  if (!groups[item.category]) groups[item.category] = [];\n  groups[item.category].push(item);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Grouping**\n\n**Fix:**\n```typescript\nconst groups = items.reduce<Record<string, Item[]>>((acc, item) => {\n  const key = item.category;\n  if (!acc[key]) acc[key] = [];\n  acc[key].push(item);\n  return acc;\n}, {});\n// Or:\nconst groups = Object.groupBy(items, item => item.category);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_grouping"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nuseEffect(() => {\n  fetchUser(userId).then(setUser);\n});\n// Missing dependency array\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not typing useEffect dependencies**\n\n**Fix:**\n```typescript\nuseEffect(() => {\n  let ignore = false;\n  fetchUser(userId).then(u => {\n    if (!ignore) setUser(u);\n  });\n  return () => { ignore = true; };\n}, [userId]);\n// Dependency array + cleanup for stale closures\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_typing_useeffect_dependencies"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Base {\n  log() { console.log('base'); }\n}\nclass Child extends Base {\n  log() { super.log(); console.log('child'); }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Method Overriding**\n\n**Fix:**\n```typescript\nclass Base {\n  log(): void { console.log('base'); }\n}\nclass Child extends Base {\n  override log(): void {\n    super.log();\n    console.log('child');\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_method_overriding"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry { operation(); } catch (e) {\n  throw new Error('Operation failed');\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error.cause**\n\n**Fix:**\n```typescript\ntry { operation(); } catch (cause) {\n  throw new Error('Operation failed', { cause });\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error.cause"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction calculateDiscount(price: number, type: string) {\n  if (type === 'vip') return price * 0.8;\n  if (type === 'regular') return price * 0.9;\n  return price;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Strategy Pattern**\n\n**Fix:**\n```typescript\ninterface DiscountStrategy {\n  calculate(price: number): number;\n}\nclass VipDiscount implements DiscountStrategy {\n  calculate(price: number): number { return price * 0.8; }\n}\nclass RegularDiscount implements DiscountStrategy {\n  calculate(price: number): number { return price * 0.9; }\n}\nfunction calculateDiscount(price: number, strategy: DiscountStrategy): number {\n  return strategy.calculate(price);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_strategy_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst pair = ['a', 1];\n// (string | number)[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Tuple Length**\n\n**Fix:**\n```typescript\nconst pair: [string, number] = ['a', 1];\n// Typed tuple\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_tuple_length"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(items: any[]) {\n  return items.map(item => item.name);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: any Array**\n\n**Fix:**\n```typescript\ninterface Item { name: string; }\nfunction process(items: Item[]) {\n  return items.map(item => item.name);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "any_array"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst data = rawData as any;\nconst name = data.name;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Type assertion with as any**\n\n**Fix:**\n```typescript\n// Fix the type definition instead:\ninterface ResponseData {\n  name: string;\n  [key: string]: unknown;\n}\nconst data = rawData as ResponseData;\nconst name = data.name;\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "type_assertion_with_as_any"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction fail(msg: string) {\n  throw new Error(msg);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Never Return**\n\n**Fix:**\n```typescript\nfunction fail(msg: string): never {\n  throw new Error(msg);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_never_return"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry {\n  await connect();\n} catch (e) {\n  throw new Error('Failed to connect');\n  // Loses original error details\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing error cause chaining**\n\n**Fix:**\n```typescript\ntry {\n  await connect();\n} catch (e) {\n  throw new Error('Failed to connect', {\n    cause: e instanceof Error ? e : undefined\n  });\n  // Error.cause preserves the original error\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_error_cause_chaining"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst fetchEpic = action$ =>\n  action$.pipe(\n    ofType(FETCH_REQUEST),\n    switchMap(() => ajax('/api').pipe(map(res => fetchSuccess(res))))\n  );\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Epics Typing**\n\n**Fix:**\n```typescript\nconst fetchEpic: Epic<Action, Action> = (action$) =>\n  action$.pipe(\n    ofType(ActionTypes.FETCH_REQUEST),\n    switchMap(() => ajax<User>('/api').pipe(\n      map((res) => ({ type: ActionTypes.FETCH_SUCCESS, data: res.response })),\n      catchError((error) => of({ type: ActionTypes.FETCH_ERROR, error }))\n    ))\n  );\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_epics_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst visibleItems = state.items.filter(i => !i.hidden);\n// Recalculates every time\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Selector Memoization**\n\n**Fix:**\n```typescript\nconst selectVisibleItems = createSelector(\n  [selectItems],\n  (items) => items.filter(i => !i.hidden)\n);\n// Memoized selector\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_selector_memoization"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nerrors.forEach(e => logger.error(e));\n// Logs all errors\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Sampling**\n\n**Fix:**\n```typescript\nfunction sampleErrors(errors: Error[], sampleRate: number = 0.1): Error[] {\n  return errors.filter(() => Math.random() < sampleRate);\n}\nsampleErrors(errors).forEach(e => logger.error(e));\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_sampling"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\napp.get('/users/:id', (req, res) => {\n  const id = req.params.id;\n  res.json(user);\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Express Request Typing**\n\n**Fix:**\n```typescript\nimport { Request, Response } from 'express';\napp.get('/users/:id', (req: Request<{ id: string }>, res: Response<User>) => {\n  const id = req.params.id;\n  res.json(user);\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_express_request_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handle(data) {\n  console.log(data);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Implicit any in Parameter**\n\n**Fix:**\n```typescript\nfunction handle(data: unknown) {\n  console.log(data);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "implicit_any_in_parameter"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nexport { User };\n// Emits even if only type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Export Type**\n\n**Fix:**\n```typescript\nexport type { User };\n// Type-only export\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_export_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst common = arr1.filter(x => arr2.includes(x));\n// O(n*m)\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Intersect**\n\n**Fix:**\n```typescript\nfunction intersect<T>(a: T[], b: T[]): T[] {\n  const setB = new Set(b);\n  return a.filter(x => setB.has(x));\n}\n// O(n+m)\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_intersect"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction findUser(id: number): User {\n  return users.find(u => u.id === id);\n  // Returns User | undefined\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing null in union**\n\n**Fix:**\n```typescript\nfunction findUser(id: number): User | undefined {\n  return users.find(u => u.id === id);\n}\n// Enable strictNullChecks to catch this\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_null_in_union"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst processed = transform(data);\nconsole.log(processed);\nconst final = format(processed);\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Tap Function**\n\n**Fix:**\n```typescript\nfunction tap<T>(value: T, fn: (val: T) => void): T {\n  fn(value);\n  return value;\n}\nconst final = data\n  |> transform\n  |> tap(console.log)\n  |> format;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_tap_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { a, b, c, d, e } from 'lib';\n// Many imports\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Namespace Import**\n\n**Fix:**\n```typescript\nimport * as Lib from 'lib';\n// Namespace import\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_namespace_import"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n{\n  \"main\": \"dist/index.js\"\n}\n// No types field\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing types field in package.json**\n\n**Fix:**\n```typescript\n{\n  \"main\": \"dist/index.js\",\n  \"types\": \"dist/index.d.ts\"\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_types_field_in_package.json"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction combine(a: string | number, b: string | number): string | number {\n  if (typeof a === 'string') return a + b;\n  return a + b;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Function Overload**\n\n**Fix:**\n```typescript\nfunction combine(a: string, b: string): string;\nfunction combine(a: number, b: number): number;\nfunction combine(a: string | number, b: string | number): string | number {\n  return a + b;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_function_overload"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface A { a: string; }\ninterface B { b: number; }\nfunction process(obj: A | B) {\n  if ('a' in obj) {\n    return obj.a;\n  }\n  return obj.b;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing in Guard**\n\n**Fix:**\n```typescript\ninterface A { a: string; }\ninterface B { b: number; }\nfunction process(obj: A | B): string | number {\n  if ('a' in obj) {\n    return obj.a; // Narrowed to A\n  }\n  return obj.b; // Narrowed to B\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_in_guard"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst set = new Set<string>();\n// Mutable\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing ReadonlySet**\n\n**Fix:**\n```typescript\nconst set: ReadonlySet<string> = new Set(['a', 'b']);\n// Cannot mutate\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_readonlyset"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nthrow 'Something went wrong';\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Throwing String**\n\n**Fix:**\n```typescript\nthrow new Error('Something went wrong');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "throwing_string"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Props {\n  children: any;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing React.ReactNode**\n\n**Fix:**\n```typescript\ninterface Props {\n  children: React.ReactNode;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_react.reactnode"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass AppError extends Error { }\n// No error code\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Custom Error with Code**\n\n**Fix:**\n```typescript\nclass AppError extends Error {\n  constructor(message: string, public code: string) {\n    super(message);\n    this.name = 'AppError';\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_custom_error_with_code"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction isString(value: unknown): boolean {\n  return typeof value === 'string';\n}\n// Returns boolean, no narrowing\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Predicate**\n\n**Fix:**\n```typescript\nfunction isString(value: unknown): value is string {\n  return typeof value === 'string';\n}\n// Type predicate enables narrowing\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_predicate"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(value: string | number) {\n  if (typeof value === 'string') {\n    return value.length;\n  }\n  return value.toString().length;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing typeof Guard**\n\n**Fix:**\n```typescript\nfunction process(value: string | number): number {\n  if (typeof value === 'string') {\n    return value.length;\n  }\n  // TypeScript narrows to number\n  return value.toString().length;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_typeof_guard"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface ErrorInfo {\n  componentStack: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Boundary Type**\n\n**Fix:**\n```typescript\ninterface ErrorBoundaryProps {\n  children: React.ReactNode;\n  fallback?: React.ReactNode;\n}\ninterface ErrorBoundaryState {\n  error: Error | null;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_boundary_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function fetchUser(id: number): Promise<User> { }\n// No error handling type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Task Pattern**\n\n**Fix:**\n```typescript\ntype Task<E, A> = () => Promise<Either<E, A>>;\nasync function fetchUser(id: number): Task<Error, User> {\n  return async () => {\n    try {\n      const response = await fetch(`/api/users/${id}`);\n      return { right: await response.json() as User };\n    } catch (e) {\n      return { left: e as Error };\n    }\n  };\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_task_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst module = require('./module');\n// any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Require Typing**\n\n**Fix:**\n```typescript\nconst module: typeof import('./module') = require('./module');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_require_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst xhr = new XMLHttpRequest();\nxhr.open('GET', url);\nxhr.send();\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing XMLHttpRequest Typing**\n\n**Fix:**\n```typescript\nconst xhr = new XMLHttpRequest();\nxhr.open('GET', url);\nxhr.responseType = 'json';\nxhr.send();\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_xmlhttprequest_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handle(error: unknown) {\n  if (error instanceof Error) {\n    console.error(error.message);\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing instanceof Guard**\n\n**Fix:**\n```typescript\nfunction handle(error: unknown): void {\n  if (error instanceof TypeError) {\n    console.error('Type error:', error.message);\n  } else if (error instanceof Error) {\n    console.error('Error:', error.message);\n  } else {\n    console.error('Unknown error:', error);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_instanceof_guard"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype State = 'loading' | 'success' | 'error';\nfunction process(state: State) {\n  if (state === 'loading') { showSpinner(); }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Equality Guard**\n\n**Fix:**\n```typescript\ntype State = 'loading' | 'success' | 'error';\nfunction process(state: State) {\n  if (state === 'loading') {\n    showSpinner(); // Narrowed to 'loading'\n  } else if (state === 'success') {\n    showData(); // Narrowed to 'success'\n  } else {\n    showError(); // Narrowed to 'error'\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_equality_guard"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst sorted = [...arr].sort();\n// Mutates copy\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Array.toSorted**\n\n**Fix:**\n```typescript\nconst sorted = arr.toSorted((a, b) => a - b);\n// Non-mutating, typed\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_array.tosorted"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry {\n  JSON.parse(input);\n} catch (e) {\n  // e is unknown in strict mode\n  handleParseError(e);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing instanceof check in catch**\n\n**Fix:**\n```typescript\ntry {\n  JSON.parse(input);\n} catch (e) {\n  if (e instanceof SyntaxError) {\n    handleParseError(e.message);\n  } else {\n    throw e;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_instanceof_check_in_catch"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Collection {\n  items: any[] = [];\n  add(item: any) { this.items.push(item); }\n  get(index: number): any { return this.items[index]; }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Generic**\n\n**Fix:**\n```typescript\nclass Collection<T> {\n  private items: T[] = [];\n  add(item: T): void { this.items.push(item); }\n  get(index: number): T | undefined { return this.items[index]; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_generic"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Host = string;\n// Duplicated type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Indexed Access Type**\n\n**Fix:**\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\ntype Host = Config['host'];\n// Derived from Config\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_indexed_access_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype UserId = number;\ntype ProductId = number;\n// No distinction between them\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using branded types**\n\n**Fix:**\n```typescript\ntype UserId = number & { __brand: 'UserId' };\ntype ProductId = number & { __brand: 'ProductId' };\n\n// Type-safe constructors:\nconst asUserId = (n: number): UserId => n as UserId;\nconst asProductId = (n: number): ProductId => n as ProductId;\n\n// Can't mix them:\n// findUser(asProductId(1)); // Error!\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_branded_types"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Animal = { type: 'dog'; bark(): void } | { type: 'cat'; meow(): void };\nfunction makeSound(a: Animal) {\n  if ('bark' in a) a.bark();\n  else a.meow();\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Narrowing with in operator**\n\n**Fix:**\n```typescript\ntype Animal =\n  | { type: 'dog'; bark(): void }\n  | { type: 'cat'; meow(): void };\nfunction makeSound(a: Animal) {\n  if (a.type === 'dog') a.bark();\n  else a.meow();\n  // Discriminant narrowing is clearer than 'in'\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "narrowing_with_in_operator"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Collection {\n  map(fn: function) { return this.items.map(fn); }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing This Parameter**\n\n**Fix:**\n```typescript\nclass Collection<T> {\n  items: T[] = [];\n  map<U>(fn: (this: void, item: T, index: number) => U): U[] {\n    return this.items.map(fn);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_this_parameter"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction first<T>(items: T[]): T {\n  return items[0];\n}\n// Returns T but could be undefined\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Generic Constraint**\n\n**Fix:**\n```typescript\nfunction first<T>(items: T[]): T | undefined {\n  return items[0];\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_generic_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Adder = (a: number, b: number) => number;\nconst add: Adder = (a, b) => a + b;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Callable Type**\n\n**Fix:**\n```typescript\ninterface Adder {\n  (a: number, b: number): number;\n}\nconst add: Adder = (a, b) => a + b;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_callable_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { User } from './user';\n// Import emits even if only type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Import**\n\n**Fix:**\n```typescript\nimport type { User } from './user';\n// Type-only import, no runtime cost\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_import"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst watcher = chokidar.watch('src');\nwatcher.on('change', (path) => { });\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Chokidar Typing**\n\n**Fix:**\n```typescript\nimport chokidar, { FSWatcher } from 'chokidar';\nconst watcher: FSWatcher = chokidar.watch('src');\nwatcher.on('change', (path: string) => { });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_chokidar_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Counter {\n  count = 0;\n  increment() { this.count++; }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Private Fields**\n\n**Fix:**\n```typescript\nclass Counter {\n  private count: number = 0;\n  increment(): void { this.count++; }\n  getCount(): number { return this.count; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_private_fields"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nbeforeEach(() => { setup(); });\nafterEach(() => { teardown(); });\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Hook Typing**\n\n**Fix:**\n```typescript\nimport { beforeEach, afterEach } from '@jest/globals';\nbeforeEach<ReturnType<typeof setup>>(() => setup());\nafterEach(() => teardown());\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_hook_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface PublicUser {\n  name: string;\n  email: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Omit Constraint**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  password: string;\n}\ntype PublicUser = Omit<User, 'password'>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_omit_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass User { name: string; }\ntype UserInstance = { name: string; };\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing InstanceType**\n\n**Fix:**\n```typescript\nclass User { name: string; }\ntype UserInstance = InstanceType<typeof User>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_instancetype"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Reverse<T extends any[]> = T extends [infer F, ...infer R]\n  ? [...Reverse<R>, F]\n  : T;\n// Recursive reverse\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Level Reverse**\n\n**Fix:**\n```typescript\n// Type-level reverse\ntype Reverse<T extends any[]> =\n  T extends [infer F, ...infer R]\n    ? [...Reverse<R>, F]\n    : T;\ntype Result = Reverse<[1, 2, 3]>; // [3, 2, 1]\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_level_reverse"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handleStatus(status: Status) {\n  if (status === Status.Active) { }\n  else if (status === Status.Inactive) { }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum Exhaustiveness**\n\n**Fix:**\n```typescript\nfunction handleStatus(status: Status): void {\n  switch (status) {\n    case Status.Active: break;\n    case Status.Inactive: break;\n    case Status.Pending: break;\n    default: {\n      const _exhaustive: never = status;\n      throw new Error(`Unhandled: ${_exhaustive}`);\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_exhaustiveness"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Length<T extends any[]> = T['length'];\n// Gets array length at type level\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Level Computation**\n\n**Fix:**\n```typescript\n// Type-level length\ntype Length<T extends any[]> = T['length'];\ntype L = Length<[1, 2, 3]>; // 3\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_level_computation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst map = new Map<string, number>();\n// Mutable\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing ReadonlyMap**\n\n**Fix:**\n```typescript\nconst map: ReadonlyMap<string, number> = new Map([\n  ['a', 1],\n  ['b', 2],\n]);\n// Cannot mutate\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_readonlymap"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Email = string;\n// No validation at type level\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using template literal types for validation**\n\n**Fix:**\n```typescript\ntype Email = `${string}@${string}.${string}`;\n// Template literal type constrains the shape\n// Note: this is compile-time only, not runtime validation\n// For runtime: use Zod, io-ts, or zod-to-json-schema\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_template_literal_types_for_validation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n/// <reference path=\"./types.d.ts\" />\n// Deprecated\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing triple-slash directive**\n\n**Fix:**\n```typescript\nimport type { User } from './types';\n// Use imports instead\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_triple-slash_directive"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype StringOrNumber = string | number;\n// Not conditional\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Conditional Type**\n\n**Fix:**\n```typescript\ntype ToArray<T> = T extends any ? T[] : never;\ntype StringArray = ToArray<string>; // string[]\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_conditional_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Map {\n  [key: string]: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Record**\n\n**Fix:**\n```typescript\ntype Map = Record<string, number>;\n// Built-in Record type\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_record"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface A { type: 'a' }\ninterface B { type: 'b' }\nconst x: A | B = ...;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Type vs Interface for union**\n\n**Fix:**\n```typescript\n// This is fine, but for complex unions, use type:\ntype Action =\n  | { type: 'ADD'; payload: number }\n  | { type: 'REMOVE'; payload: string }\n  | { type: 'RESET' };\n// type is required for unions, intersections, mapped types\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "type_vs_interface_for_union"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Dog { bark() {} }\nclass Cat { meow() {} }\nfunction makeSound(animal: Dog | Cat) {\n  if (animal instanceof Dog) animal.bark();\n  else animal.meow();\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Type Guard Method**\n\n**Fix:**\n```typescript\nclass Dog { isDog(): this is Dog { return true; } bark() {} }\nclass Cat { isCat(): this is Cat { return true; } meow() {} }\nfunction makeSound(animal: Dog | Cat) {\n  if (animal.isDog()) animal.bark();\n  else animal.meow();\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_type_guard_method"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype PartialUser = Partial<User>;\n// Only shallow\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing DeepPartial**\n\n**Fix:**\n```typescript\ntype DeepPartial<T> = {\n  [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];\n};\n// Recursive partial\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_deeppartial"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Celsius = number;\ntype Fahrenheit = number;\n// Interchangeable\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Nominal Typing**\n\n**Fix:**\n```typescript\n// Nominal types via branding\ntype Celsius = number & { brand: 'celsius' };\ntype Fahrenheit = number & { brand: 'fahrenheit' };\n// Cannot be used interchangeably\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_nominal_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction combine(a: number[], b: string[]): (number | string)[] {\n  return [...a, ...b];\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Variadic Tuple**\n\n**Fix:**\n```typescript\nfunction combine<T extends unknown[], U extends unknown[]>(a: T, b: U): [...T, ...U] {\n  return [...a, ...b];\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_variadic_tuple"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handle(result: Result) {\n  if (result.ok) {\n    return result.data;\n  }\n  throw result.error;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with discriminated union**\n\n**Fix:**\n```typescript\ntype Result<T, E> =\n  | { ok: true; data: T }\n  | { ok: false; error: E };\nfunction handle(result: Result<string, Error>) {\n  if (result.ok) {\n    return result.data; // Narrowed to string\n  }\n  throw result.error; // Narrowed to Error\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_discriminated_union"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst colors = ['red', 'green', 'blue'];\n// string[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Const Assertion**\n\n**Fix:**\n```typescript\nconst colors = ['red', 'green', 'blue'] as const;\n// readonly ['red', 'green', 'blue']\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_const_assertion"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function fetchData() {\n  return fetch('/api').then(r => r.json());\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Promise type**\n\n**Fix:**\n```typescript\nasync function fetchData(): Promise<unknown> {\n  const response = await fetch('/api');\n  return response.json();\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_promise_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst user = await fetchUser(id);\nconst posts = await fetchPosts(userId);\nconst comments = await fetchComments(postId);\n// Scattered calls\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Facade Pattern**\n\n**Fix:**\n```typescript\nclass UserFacade {\n  async getProfile(id: number): Promise<Profile> {\n    const [user, posts, comments] = await Promise.all([\n      fetchUser(id),\n      fetchPosts(id),\n      fetchComments(id),\n    ]);\n    return { user, posts, comments };\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_facade_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry { parse(); } catch (error) {\n  console.log(error.message);\n  // error is unknown\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with catch**\n\n**Fix:**\n```typescript\n// Catch narrowing (TS 4.0+)\ntry { parse(); } catch (error) {\n  if (error instanceof Error) {\n    console.error(error.message);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_catch"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype OptionalUser = {\n  name?: string;\n  email?: string;\n};\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Generic Utility**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\ntype OptionalUser = Partial<User>;\n// Built-in Partial utility\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_generic_utility"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\napp.use((req, res, next) => {\n  res.header('Access-Control-Allow-Origin', '*');\n  next();\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing CORS Typing**\n\n**Fix:**\n```typescript\nimport cors from 'cors';\napp.use(cors({\n  origin: ['https://example.com'],\n  methods: ['GET', 'POST'],\n  credentials: true,\n}));\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_cors_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst result = await Promise.race([fetch(url), timeout]);\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Promise.race typing**\n\n**Fix:**\n```typescript\nconst result = await Promise.race<\n  [Promise<Response>, Promise<never>]\n>([fetch(url), timeout]);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_promise.race_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface UpdateUser {\n  name?: string;\n  email?: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Partial Constraint**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\ntype UpdateUser = Partial<User>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_partial_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Counter {\n  count = 0;\n  increment() { this.count++; }\n}\nconst counter = new Counter();\nsetTimeout(counter.increment, 1000);\n// Lost context\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Function Binding Type**\n\n**Fix:**\n```typescript\nclass Counter {\n  count = 0;\n  increment = (): void => { this.count++; };\n}\n// Arrow function preserves this\nsetTimeout(counter.increment, 1000);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_function_binding_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Config {\n  url: string;\n  constructor(url: string) { this.url = url; }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Readonly**\n\n**Fix:**\n```typescript\nclass Config {\n  constructor(public readonly url: string) {}\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_readonly"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction createUser(): User {\n  return { id: 1, name: 'Alice' };\n}\ninterface Creator {\n  result: User; // Duplicated return type\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using ReturnType**\n\n**Fix:**\n```typescript\nfunction createUser(): User {\n  return { id: 1, name: 'Alice' };\n}\ntype Creator = {\n  result: ReturnType<typeof createUser>;\n  // Infers User from the function\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_returntype"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(val: string | number) {\n  if (typeof val === 'string') {\n    return val.length;\n  }\n  return val.toString().length;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with typeof**\n\n**Fix:**\n```typescript\n// typeof narrowing is built-in\nfunction process(val: string | number): number {\n  if (typeof val === 'string') {\n    return val.length; // val is string\n  }\n  return val.toString().length; // val is number\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_typeof"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype DeepReadonly<T> = { readonly [K in keyof T]: T[K]; };\n// Only shallow\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Recursive Conditional**\n\n**Fix:**\n```typescript\ntype DeepReadonly<T> = {\n  readonly [K in keyof T]: T[K] extends object\n    ? DeepReadonly<T[K]>\n    : T[K];\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_recursive_conditional"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction Button(props) {\n  return <button onClick={props.onClick}>{props.children}</button>;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Component Props typing**\n\n**Fix:**\n```typescript\ninterface ButtonProps {\n  onClick: () => void;\n  children: React.ReactNode;\n  variant?: 'primary' | 'secondary';\n}\nfunction Button({ onClick, children, variant = 'primary' }: ButtonProps) {\n  return <button onClick={onClick}>{children}</button>;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_component_props_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst VERSION: string;\n// Not defined anywhere\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing ambient declaration**\n\n**Fix:**\n```typescript\ndeclare const VERSION: string;\n// Ambient declaration\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_ambient_declaration"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype UnwrapPromise<T> = T extends Promise<unknown>\n  ? T : T;\n  // Doesn't extract the inner type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing infer in conditional type**\n\n**Fix:**\n```typescript\ntype UnwrapPromise<T> = T extends Promise<infer U>\n  ? U\n  : T;\n// infer creates a new type variable from the matched pattern\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_infer_in_conditional_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction getProp(obj: object, key: string) {\n  return obj[key]; // No type safety\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing keyof constraint**\n\n**Fix:**\n```typescript\nfunction getProp<T, K extends keyof T>(obj: T, key: K): T[K] {\n  return obj[key];\n  // K is constrained to valid keys of T\n  // Return type is T[K]\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_keyof_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Emitter {\n  events: { [key: string]: Function[] } = {};\n  on(event: string, fn: Function) { this.events[event].push(fn); }\n  emit(event: string) { this.events[event].forEach(fn => fn()); }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Event Emitter**\n\n**Fix:**\n```typescript\ninterface EventMap { [key: string]: unknown; }\nclass Emitter<T extends EventMap = EventMap> {\n  private events: { [K in keyof T]?: Array<(arg: T[K]) => void> } = {};\n  on<K extends keyof T>(event: K, fn: (arg: T[K]) => void): void {\n    if (!this.events[event]) this.events[event] = [];\n    this.events[event]!.push(fn);\n  }\n  emit<K extends keyof T>(event: K, arg: T[K]): void {\n    this.events[event]?.forEach(fn => fn(arg));\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_event_emitter"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Message =\n  | { type: 'text'; content: string }\n  | { type: 'image'; url?: string };\n// url is optional - confusing with discriminant\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Optional discriminant field**\n\n**Fix:**\n```typescript\ntype Message =\n  | { type: 'text'; content: string }\n  | { type: 'image'; url: string };\n// Discriminant variants should have required fields\n// Use separate optional fields if truly optional\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "optional_discriminant_field"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction isString(val: unknown): boolean {\n  return typeof val === 'string';\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Predicate Return**\n\n**Fix:**\n```typescript\nfunction isString(val: unknown): val is string {\n  return typeof val === 'string';\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_predicate_return"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config: Record<string, string> = {};\nconst port = config.port; // string, not number\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing index signature guard**\n\n**Fix:**\n```typescript\nconst config: Record<string, string> = {};\nconst port = config['port']; // string\nconst parsedPort = parseInt(port, 10);\n// Record<string, string> means all values are strings\n// Use specific type for known keys\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_index_signature_guard"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst roles = ['admin', 'user', 'guest'];\n// Type: string[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing const assertion**\n\n**Fix:**\n```typescript\nconst roles = ['admin', 'user', 'guest'] as const;\n// Type: readonly ['admin', 'user', 'guest']\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_const_assertion"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface API {\n  get: (url: string) => any;\n  post: (url: string, body: any) => any;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Generic function in interface**\n\n**Fix:**\n```typescript\ninterface API {\n  get<T>(url: string): Promise<T>;\n  post<T, B>(url: string, body: B): Promise<T>;\n  delete<T>(url: string): Promise<T>;\n}\n// Generic methods preserve type information\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "generic_function_in_interface"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst response = await fetch(url);\nconst data = await response.json();\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Fetch Response Typing**\n\n**Fix:**\n```typescript\ninterface UserResponse { id: number; name: string; }\nconst response = await fetch(url);\nif (!response.ok) throw new Error(`HTTP ${response.status}`);\nconst data: UserResponse = await response.json();\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_fetch_response_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst Input = forwardRef((props, ref) => {\n  return <input ref={ref} />;\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing forwardRef typing**\n\n**Fix:**\n```typescript\ninterface InputProps {\n  value: string;\n  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n}\nconst Input = forwardRef<HTMLInputElement, InputProps>(({ value, onChange }, ref) => {\n  return <input ref={ref} value={value} onChange={onChange} />;\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_forwardref_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction* fetchData() {\n  yield take(FETCH_REQUEST);\n  yield put(fetchSuccess(yield call(api)));\n}\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Saga Typing**\n\n**Fix:**\n```typescript\nfunction* fetchData(): SagaIterator {\n  yield take(ActionTypes.FETCH_REQUEST);\n  const data = yield call(api.fetchData);\n  yield put({ type: ActionTypes.FETCH_SUCCESS, data });\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_saga_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype ConfigKey = 'host' | 'port';\n// Manual\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing keyof operator**\n\n**Fix:**\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\ntype ConfigKey = keyof Config; // 'host' | 'port'\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_keyof_operator"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// file1.d.ts\ndeclare module 'express' {\n  interface Request { user: User; }\n}\n// file2.d.ts\ndeclare module 'express' {\n  interface Request { tenant: Tenant; }\n}\n// Both augment - fine, but be careful\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Module augmentation conflict**\n\n**Fix:**\n```typescript\n// Module augmentation is additive (declaration merging)\n// Both files work together:\ndeclare module 'express' {\n  interface Request {\n    user?: User;\n    tenant?: Tenant;\n  }\n}\n// Group related augmentations in one file\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "module_augmentation_conflict"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction getUser(id: number): User | null {\n  return users.find(u => u.id === id) || null;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Maybe Pattern**\n\n**Fix:**\n```typescript\ntype Maybe<T> = { isJust: true; value: T } | { isJust: false };\nfunction just<T>(value: T): Maybe<T> { return { isJust: true, value }; }\nfunction nothing<T>(): Maybe<T> { return { isJust: false }; }\nfunction getUser(id: number): Maybe<User> {\n  return users.find(u => u.id === id)\n    ? just(users.find(u => u.id === id)!)\n    : nothing();\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_maybe_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst path = require('path');\nconst fullPath = path.join(base, relative);\n// string\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Path.join Typing**\n\n**Fix:**\n```typescript\nimport { join } from 'path';\nconst fullPath: string = join(base, relative);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_path.join_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst user = users.find(u => u.id === id);\n// Type: User | undefined\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Array.find Typing**\n\n**Fix:**\n```typescript\nconst user = users.find((u): u is User => u.id === id);\n// Type: User\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_array.find_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction createPoint(x: number, y: number) { return { x, y }; }\nfunction distance(a: { x: number; y: number }, b: { x: number; y: number }) { }\n// Global namespace pollution\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Namespace**\n\n**Fix:**\n```typescript\nnamespace Geometry {\n  export interface Point { x: number; y: number; }\n  export function create(x: number, y: number): Point { return { x, y }; }\n  export function distance(a: Point, b: Point): number {\n    return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_namespace"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst url = 'https://api.com' + path;\n// String concatenation\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing URL Typing**\n\n**Fix:**\n```typescript\nconst url = new URL(path, 'https://api.com');\n// Type-safe URL construction\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_url_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass User {\n  name: string;\n  email: string;\n  constructor(name: string, email: string) {\n    this.name = name;\n    this.email = email;\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Access Modifier**\n\n**Fix:**\n```typescript\nclass User {\n  constructor(\n    public readonly name: string,\n    public readonly email: string\n  ) {}\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_access_modifier"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype User = { name: string; };\nasync function fetchUser(): Promise<User> { }\ntype FetchedUser = Promise<User>;\n// Still Promise\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Awaited**\n\n**Fix:**\n```typescript\ntype User = { name: string; };\nasync function fetchUser(): Promise<User> { }\ntype FetchedUser = Awaited<ReturnType<typeof fetchUser>>;\n// Unwraps Promise\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_awaited"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst path = require('path');\nconst ext = path.extname(filename);\n// any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Path Typing**\n\n**Fix:**\n```typescript\nimport { extname } from 'path';\nconst ext: string = extname(filename);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_path_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction getStatus(code: number): string {\n  if (code === 200) return 'OK';\n  if (code === 404) return 'Not Found';\n  // Missing default return - implicit undefined\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing noImplicitReturns**\n\n**Fix:**\n```typescript\nfunction getStatus(code: number): string {\n  if (code === 200) return 'OK';\n  if (code === 404) return 'Not Found';\n  return 'Unknown'; // Explicit return\n}\n// Enable noImplicitReturns to catch this\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_noimplicitreturns"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nstate.user.name = 'New Name';\n// Direct mutation\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Immutability**\n\n**Fix:**\n```typescript\nsetState(prev => ({ ...prev, user: { ...prev.user, name: 'New Name' } }));\n// Immutable update\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_immutability"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction log(method: Function) {\n  return function(...args: any[]) {\n    console.log('calling', method.name);\n    return method(...args);\n  };\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Decorator Pattern**\n\n**Fix:**\n```typescript\nfunction log(target: any, propertyKey: string, descriptor: PropertyDescriptor) {\n  const original = descriptor.value;\n  descriptor.value = function(...args: unknown[]) {\n    console.log(`calling ${propertyKey}`);\n    return original.apply(this, args);\n  };\n  return descriptor;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_decorator_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst callbacks: Array<() => void> = [];\nfunction subscribe(cb: () => void) { callbacks.push(cb); }\nfunction emit() { callbacks.forEach(cb => cb()); }\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Observer Pattern**\n\n**Fix:**\n```typescript\ninterface Observer<T> { update(value: T): void; }\nclass Subject<T> {\n  private observers: Observer<T>[] = [];\n  subscribe(observer: Observer<T>) { this.observers.push(observer); }\n  unsubscribe(observer: Observer<T>) {\n    this.observers = this.observers.filter(o => o !== observer);\n  }\n  emit(value: T) {\n    this.observers.forEach(o => o.update(value));\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_observer_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handleChange(e: any) {\n  setValue(e.target.value);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Event typing**\n\n**Fix:**\n```typescript\nfunction handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n  setValue(e.target.value);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_event_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry { parse(); } catch (error) {\n  console.log(error.message);\n  // error is unknown\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with catch**\n\n**Fix:**\n```typescript\ntry { parse(); } catch (error) {\n  if (error instanceof Error) {\n    console.error(error.message);\n  }\n  // error narrowed in block\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_catch"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Store<T> {\n  private value: T;\n  constructor(value: T) { this.value = value; }\n  get() { return this.value; }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Default Generic**\n\n**Fix:**\n```typescript\nclass Store<T = null> {\n  private value: T;\n  constructor(value: T) { this.value = value; }\n  get(): T { return this.value; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_default_generic"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function* gen() {\n  yield 1;\n  yield 2;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Async Generator return**\n\n**Fix:**\n```typescript\nasync function* gen(): AsyncGenerator<number> {\n  yield 1;\n  yield 2;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_async_generator_return"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass User {\n  name: string;\n  email: string;\n  age: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Optional Property**\n\n**Fix:**\n```typescript\nclass User {\n  name: string;\n  email: string;\n  age?: number;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_optional_property"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst flat = nested.reduce((acc, item) => {\n  acc.push(...item.children);\n  return acc;\n}, []);\n// Imperative\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Flattener**\n\n**Fix:**\n```typescript\nfunction flatten<T>(items: { children: T[] }[]): T[] {\n  return items.flatMap(item => item.children);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_flattener"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction setStatus(status: number) {\n  this.status = status;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum Validation**\n\n**Fix:**\n```typescript\nfunction setStatus(status: Status): void {\n  if (!(status in Status)) {\n    throw new Error(`Invalid status: ${status}`);\n  }\n  this.status = status;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_validation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst Context = createContext(null);\n// Type: null\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Context Typing**\n\n**Fix:**\n```typescript\ninterface StateContextType {\n  count: number;\n  increment: () => void;\n  decrement: () => void;\n}\nconst Context = createContext<StateContextType | null>(null);\nconst value = useContext(Context);\nif (!value) throw new Error('Context not found');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_context_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handle(error: unknown) {\n  if (error instanceof Error) {\n    console.error(error.message);\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with instanceof**\n\n**Fix:**\n```typescript\n// instanceof narrowing\nfunction handle(error: unknown): void {\n  if (error instanceof TypeError) {\n    console.error('TypeError:', error.message);\n  } else if (error instanceof Error) {\n    console.error('Error:', error.message);\n  } else {\n    console.error('Unknown:', error);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_instanceof"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass User { constructor(name: string, email: string) { } }\ntype UserParams = [string, string];\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing ConstructorParameters**\n\n**Fix:**\n```typescript\nclass User { constructor(public name: string, public email: string) { } }\ntype UserParams = ConstructorParameters<typeof User>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_constructorparameters"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction createUser(input: any) {\n  return db.insert(input);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Input Validation Type**\n\n**Fix:**\n```typescript\ninterface CreateUserInput {\n  name: string;\n  email: string;\n  age?: number;\n}\nfunction validateInput(input: unknown): input is CreateUserInput {\n  return (\n    typeof input === 'object' &&\n    input !== null &&\n    'name' in input &&\n    'email' in input &&\n    typeof (input as any).name === 'string' &&\n    typeof (input as any).email === 'string'\n  );\n}\nfunction createUser(input: unknown): User {\n  if (!validateInput(input)) throw new Error('Invalid input');\n  return db.insert(input);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_input_validation_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nenum Status {\n  Active = 'active',\n  Inactive = 'inactive',\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum Like Object**\n\n**Fix:**\n```typescript\n// Enum-like object with as const\nconst Status = {\n  Active: 'active',\n  Inactive: 'inactive',\n} as const;\ntype Status = typeof Status[keyof typeof Status];\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_like_object"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry { process(); } catch (error: any) {\n  console.log(error);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error type in catch**\n\n**Fix:**\n```typescript\ntry { process(); } catch (error: unknown) {\n  if (error instanceof Error) {\n    console.error(error.message);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_type_in_catch"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';\ntype SafeMethods = 'GET' | 'DELETE';\n// Manually listing subset\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using Extract**\n\n**Fix:**\n```typescript\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';\ntype SafeMethods = Extract<HttpMethod, 'GET' | 'DELETE'>;\n// Extract filters union types to matching members\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_extract"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Api {\n  getUsers() { return fetch('/api/users'); }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Decorator**\n\n**Fix:**\n```typescript\nfunction logged(target: any, propertyKey: string, descriptor: PropertyDescriptor) {\n  const original = descriptor.value;\n  descriptor.value = function(...args: unknown[]) {\n    console.log(`[${propertyKey}]`, args);\n    return original.apply(this, args);\n  };\n  return descriptor;\n}\nclass Api {\n  @logged\n  getUsers() { return fetch('/api/users'); }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_decorator"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { User } from './user';\n// Emits import even if only used as type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing verbatimModuleSyntax**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\"compilerOptions\": {\n  \"verbatimModuleSyntax\": true\n}}\n// Use 'import type' for type-only imports\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_verbatimmodulesyntax"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst errors: Error[] = [];\nfor (const task of tasks) {\n  try { await task(); }\n  catch (e) { errors.push(e as Error); }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Aggregate Error**\n\n**Fix:**\n```typescript\nconst results = await Promise.allSettled(tasks.map(t => t()));\nconst errors = results\n  .filter((r): r is PromiseRejectedResult => r.status === 'rejected')\n  .map(r => r.reason as Error);\nif (errors.length) throw new AggregateError(errors);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_aggregate_error"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction greet(name: string, greeting: string | undefined) {\n  greeting = greeting || 'Hello';\n  return `${greeting}, ${name}`;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Default Parameters**\n\n**Fix:**\n```typescript\nfunction greet(name: string, greeting: string = 'Hello'): string {\n  return `${greeting}, ${name}`;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_default_parameters"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nif (status === 'draft') { }\nelse if (status === 'pending') { }\nelse if (status === 'published') { }\n// Long if-else chain\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Pattern**\n\n**Fix:**\n```typescript\ninterface DocumentState {\n  canEdit(): boolean;\n  canPublish(): boolean;\n}\nclass DraftState implements DocumentState {\n  canEdit(): boolean { return true; }\n  canPublish(): boolean { return true; }\n}\nclass PublishedState implements DocumentState {\n  canEdit(): boolean { return false; }\n  canPublish(): boolean { return false; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfs.watchFile('config.json', (curr, prev) => { });\n// curr and prev are any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing fs.watchFile**\n\n**Fix:**\n```typescript\nimport { Stats } from 'fs';\nfs.watchFile('config.json', (curr: Stats, prev: Stats) => {\n  console.log('Changed:', curr.mtime > prev.mtime);\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_fs.watchfile"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  age: number;\n}\ntype UserDisplay = {\n  name: string;\n  email: string;\n};\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Pick Utility**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  age: number;\n}\ntype UserDisplay = Pick<User, 'name' | 'email'>;\n// Select specific properties\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_pick_utility"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype API<T> = {\n  [K in keyof T as `get${string & K}`]: () => T[K];\n};\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing KeyRemapping**\n\n**Fix:**\n```typescript\n// Key remapping with 'as'\ntype API<T> = {\n  [K in keyof T as `get${Capitalize<string & K>}`]: () => T[K];\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_keyremapping"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface NestedConfig {\n  db: { host: string; port: number };\n  cache: { enabled: boolean; ttl: number };\n}\n// Partial only makes top-level optional\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing deep partial**\n\n**Fix:**\n```typescript\ntype DeepPartial<T> = {\n  [P in keyof T]?: T[P] extends object\n    ? DeepPartial<T[P]>\n    : T[P];\n};\n\ninterface NestedConfig {\n  db: { host: string; port: number };\n  cache: { enabled: boolean; ttl: number };\n}\ntype PartialConfig = DeepPartial<NestedConfig>;\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_deep_partial"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst value = obj['key'];\n// Allowed for index signatures\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing noPropertyAccessFromIndexSignature**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\"compilerOptions\": {\n  \"noPropertyAccessFromIndexSignature\": true\n}}\n// Forces bracket notation for index signatures\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_nopropertyaccessfromindexsignature"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\nconst c: Config = { host: 'localhost', port: 80, debug: true };\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Excess property check bypass**\n\n**Fix:**\n```typescript\n// TypeScript allows excess properties in object literals\n// Fix: either add the property or use type assertion with intent\ninterface Config {\n  host: string;\n  port: number;\n  debug?: boolean; // Add if valid\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "excess_property_check_bypass"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Result = { ok: true; data: Value } | { ok: false; error: Error };\n// Correct, but verbose\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Using boolean discriminant**\n\n**Fix:**\n```typescript\ntype Result<T, E = Error> =\n  | { ok: true; data: T; error?: never }\n  | { ok: false; data?: never; error: E };\n// Generics make it reusable. 'never' prevents the other field\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "using_boolean_discriminant"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Coord {\n  0: number;\n  1: number;\n  length: 2;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Manual tuple type**\n\n**Fix:**\n```typescript\ntype Coord = [x: number, y: number];\n// Tuple types are cleaner for fixed-length arrays\nconst [x, y] = coord;\n// Destructuring works with proper types\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "manual_tuple_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype ConfigKey = 'host' | 'port';\n// Duplicated\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing keyof**\n\n**Fix:**\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\ntype ConfigKey = keyof Config;\n// Auto-derived\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_keyof"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Event = 'onClick' | 'onHover' | 'onFocus';\n// Manual\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Template Literal Types**\n\n**Fix:**\n```typescript\ntype Action = 'click' | 'hover' | 'focus';\ntype Event = `on${Capitalize<Action>}`;\n// 'onClick' | 'OnHover' | 'OnFocus'\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_template_literal_types"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst city = user && user.address && user.address.city;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with optional chaining**\n\n**Fix:**\n```typescript\nconst city = user?.address?.city;\n// Type: string | undefined\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_optional_chaining"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry { process(); } catch (e) {\n  console.log(e);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing try/catch typing**\n\n**Fix:**\n```typescript\ntry { process(); } catch (error) {\n  if (error instanceof Error) {\n    logger.error(error.message);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_try/catch_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst controller = new AbortController();\nconst signal = controller.signal;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing AbortController Typing**\n\n**Fix:**\n```typescript\nasync function fetchWithTimeout(url: string, timeout: number): Promise<Response> {\n  const controller = new AbortController();\n  const id = setTimeout(() => controller.abort(), timeout);\n  try {\n    return await fetch(url, { signal: controller.signal });\n  } finally {\n    clearTimeout(id);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_abortcontroller_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst combined = [...arr1, ...arr2.filter(x => !arr1.includes(x))];\n// O(n*m)\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Union**\n\n**Fix:**\n```typescript\nfunction union<T>(a: T[], b: T[]): T[] {\n  return [...new Set([...a, ...b])];\n}\n// O(n+m)\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_union"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst dto = { id: entity.id, name: entity.name };\n// Manual mapping\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Mapper**\n\n**Fix:**\n```typescript\nfunction mapEntityToDto(entity: Entity): EntityDto {\n  return {\n    id: entity.id,\n    name: entity.name,\n    createdAt: entity.createdAt.toISOString(),\n  };\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_mapper"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// Declarations output in wrong location\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing rootDir**\n\n**Fix:**\n```typescript\n{\"compilerOptions\": {\n  \"rootDir\": \"src\",\n  \"outDir\": \"dist\"\n}}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_rootdir"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nenum Direction {\n  Up = 0,\n  Down = 1,\n  Left = 2,\n  Right = 3,\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing String Enum**\n\n**Fix:**\n```typescript\nenum Direction {\n  Up = 'UP',\n  Down = 'DOWN',\n  Left = 'LEFT',\n  Right = 'RIGHT',\n}\n// String enums are safer\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_string_enum"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\njest.stub(global, 'setTimeout').returns(undefined);\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Stub Typing**\n\n**Fix:**\n```typescript\nconst original = global.setTimeout;\nbeforeEach(() => {\n  global.setTimeout = jest.fn((cb) => { cb(); } as any);\n});\nafterEach(() => {\n  global.setTimeout = original;\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_stub_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction useDebounce(value, delay) {\n  const [debounced, setDebounced] = useState(value);\n  // ...\n}\n// No type inference for consumers\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Untyped custom hook**\n\n**Fix:**\n```typescript\nfunction useDebounce<T>(value: T, delay: number): T {\n  const [debounced, setDebounced] = useState<T>(value);\n  useEffect(() => {\n    const timer = setTimeout(() => setDebounced(value), delay);\n    return () => clearTimeout(timer);\n  }, [value, delay]);\n  return debounced;\n}\n// Generic hook - preserves value type\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "untyped_custom_hook"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\n// Used only for types\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type-only Interface**\n\n**Fix:**\n```typescript\n// Interface is type-only by default\n// No runtime emission\ninterface Config {\n  host: string;\n  port: number;\n}\n// Use 'satisfies' to validate runtime objects\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type-only_interface"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ndeclare namespace jQuery {\n  function ajax(url: string): Promise<any>;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Ambient Namespace**\n\n**Fix:**\n```typescript\n// Ambient namespace for untyped libraries\ndeclare namespace jQuery {\n  interface AjaxSettings {\n    url: string;\n    method?: string;\n  }\n  function ajax(settings: AjaxSettings): Promise<any>;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_ambient_namespace"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction identity<T>(arg: T): T {\n  return arg;\n}\n// No constraint\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Generic extends**\n\n**Fix:**\n```typescript\nfunction identity<T extends object>(arg: T): T {\n  return arg;\n}\n// Constrains to objects\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_generic_extends"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Result = { data: T } | { error: string };\n// No discriminant - can't narrow\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing discriminant property**\n\n**Fix:**\n```typescript\ntype Result<T, E = Error> =\n  | { ok: true; data: T }\n  | { ok: false; error: E };\n// 'ok' field discriminates between variants\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_discriminant_property"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nexport interface Config {\n  host: string;\n  port: number;\n}\n// Runtime value exported unnecessarily\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using export type**\n\n**Fix:**\n```typescript\nexport type Config = {\n  host: string;\n  port: number;\n};\n// Or for interfaces that are only used as types:\nexport type { Config } from './config';\n// export type is type-only, stripped at compile time\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_export_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst rateLimit = require('express-rate-limit');\napp.use(rateLimit({ windowMs: 15 * 60 * 1000, max: 100 }));\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Rate Limit Typing**\n\n**Fix:**\n```typescript\nimport rateLimit from 'express-rate-limit';\nconst limiter = rateLimit({\n  windowMs: 15 * 60 * 1000,\n  max: 100,\n  message: 'Too many requests',\n});\napp.use(limiter);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_rate_limit_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction parse(input: string | number): string | number {\n  return typeof input === 'string' ? parseInt(input) : String(input);\n}\n// Return type is union - caller must check\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using function overloads**\n\n**Fix:**\n```typescript\nfunction parse(input: string): number;\nfunction parse(input: number): string;\nfunction parse(input: string | number): string | number {\n  return typeof input === 'string' ? parseInt(input) : String(input);\n}\n// Overloads give precise return types per input type\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_function_overloads"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction divide(a: number, b: number): number {\n  if (b === 0) throw new Error('Division by zero');\n  return a / b;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Either Pattern**\n\n**Fix:**\n```typescript\ntype Either<L, R> = { left: L; right?: never } | { left?: never; right: R };\nfunction divide(a: number, b: number): Either<string, number> {\n  if (b === 0) return { left: 'Division by zero' };\n  return { right: a / b };\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_either_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Store {\n  data: { [key: string]: any } = {};\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Index Signature**\n\n**Fix:**\n```typescript\nclass Store<T> {\n  private data: Record<string, T> = {};\n  set(key: string, value: T): void { this.data[key] = value; }\n  get(key: string): T | undefined { return this.data[key]; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_index_signature"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype ElementType<T> = T extends Array<infer U> ? U : T;\n// Extract array element type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Infer in Conditional**\n\n**Fix:**\n```typescript\ntype ElementType<T> = T extends Array<infer U> ? U : T;\ntype Num = ElementType<number[]>; // number\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_infer_in_conditional"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\njest.mock('./api', () => ({\n  fetchUser: jest.fn(),\n}));\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Mock Typing**\n\n**Fix:**\n```typescript\nimport { FetchMock } from 'jest-fetch-mock';\nconst fetchMock = fetch as FetchMock;\nfetchMock.mockResolvedValue({ json: () => Promise.resolve({ id: 1 }) });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_mock_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst emitter = new EventTarget();\nemitter.dispatchEvent(new CustomEvent('data', { detail: data }));\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing EventTarget typing**\n\n**Fix:**\n```typescript\ninterface Events {\n  data: { value: string };\n  error: { error: Error };\n}\nconst emitter = new EventTarget();\nemitter.dispatchEvent(new CustomEvent<Events['data']>('data', { detail: { value: 'test' } }));\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_eventtarget_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction add(a: number, b: number) { return a + b; }\nfunction subtract(a: number, b: number) { return a - b; }\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Higher-Order Function**\n\n**Fix:**\n```typescript\ntype BinaryOp = (a: number, b: number) => number;\nfunction createOp(op: (a: number, b: number) => number): BinaryOp {\n  return op;\n}\nconst add = createOp((a, b) => a + b);\nconst subtract = createOp((a, b) => a - b);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_higher-order_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst userName = state.user.name;\n// May throw if user is null\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Selector Typing**\n\n**Fix:**\n```typescript\nconst userName = state.user?.name ?? 'Anonymous';\n// Safe access\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_selector_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nwindow.CUSTOM_VAR = 'value';\n// Property doesn't exist on Window\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing global declaration**\n\n**Fix:**\n```typescript\n// globals.d.ts\ndeclare global {\n  interface Window {\n    CUSTOM_VAR: string;\n  }\n}\nexport {};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_global_declaration"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(value: string | null) {\n  if (value) {\n    return value.length;\n  }\n  return 0;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Truthiness Guard**\n\n**Fix:**\n```typescript\nfunction process(value: string | null): number {\n  if (value != null) {\n    return value.length;\n  }\n  return 0;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_truthiness_guard"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function stream() {\n  return { async iterator() { yield 1; } };\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing AsyncIterable**\n\n**Fix:**\n```typescript\nasync function* stream(): AsyncIterable<number> {\n  yield 1;\n  yield 2;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_asynciterable"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Validator {\n  static patterns = {};\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Static Block**\n\n**Fix:**\n```typescript\nclass Validator {\n  private static patterns: Record<string, RegExp> = {};\n  static {\n    this.patterns.email = /^[^@]+@[^@]+\\.[^@]+$/;\n    this.patterns.phone = /^\\d{3}-\\d{3}-\\d{4}$/;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_static_block"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Getters = {\n  getName: () => string;\n  getEmail: () => string;\n};\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Mapped Type with as**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\ntype Getters = {\n  [K in keyof User as `get${Capitalize<K>}`]: () => User[K];\n};\n// { getName: () => string; getEmail: () => string; }\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_mapped_type_with_as"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nerrors.forEach(e => { try { process(e); } catch { /* lost */ } });\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Dead Letter Queue**\n\n**Fix:**\n```typescript\ninterface DeadLetterQueue<T> {\n  enqueue(item: T): void;\n  dequeue(): T | null;\n  size(): number;\n}\nclass DLQ<T> implements DeadLetterQueue<T> {\n  private queue: T[] = [];\n  enqueue(item: T): void { this.queue.push(item); }\n  dequeue(): T | null { return this.queue.shift() ?? null; }\n  size(): number { return this.queue.length; }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_dead_letter_queue"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst colors = ['red', 'green', 'blue'];\n// Type: string[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with as const**\n\n**Fix:**\n```typescript\nconst colors = ['red', 'green', 'blue'] as const;\n// Type: readonly ['red', 'green', 'blue']\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_as_const"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst merged = { ...a, ...b };\n// Shallow merge\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Merge**\n\n**Fix:**\n```typescript\nfunction deepMerge<T extends Record<string, unknown>>(target: T, source: Partial<T>): T {\n  const result = { ...target };\n  for (const key in source) {\n    if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n      result[key] = deepMerge(result[key] as any, source[key] as any);\n    } else {\n      (result as any)[key] = source[key];\n    }\n  }\n  return result;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_merge"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry {\n  riskyOperation();\n} catch (e) {\n  // e: unknown in strict mode\n  log(e.message); // Compile error\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not typing caught error**\n\n**Fix:**\n```typescript\ntry {\n  riskyOperation();\n} catch (e: unknown) {\n  if (e instanceof Error) {\n    logger.error(e.message, e.stack);\n  } else {\n    logger.error('Unknown error:', e);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_typing_caught_error"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function retry(fn: () => Promise<any>, attempts: number) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await fn(); }\n    catch { if (i === attempts - 1) throw; }\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Handling in Retry**\n\n**Fix:**\n```typescript\nasync function retry<T>(fn: () => Promise<T>, attempts: number = 3, delay: number = 1000): Promise<T> {\n  for (let i = 0; i < attempts; i++) {\n    try { return await fn(); }\n    catch (error) {\n      if (i === attempts - 1) throw error;\n      await new Promise(resolve => setTimeout(resolve, delay * (i + 1)));\n    }\n  }\n  throw new Error('Unreachable');\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_handling_in_retry"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction subtract(a: number, b: number) { return a - b; }\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Flip Function**\n\n**Fix:**\n```typescript\nfunction flip<T, U, R>(fn: (a: T, b: U) => R): (a: U, b: T) => R {\n  return (a, b) => fn(b, a);\n}\nconst subtract = flip((b, a) => a - b);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_flip_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// index.ts\nexport { User } from './user';\nexport { Post } from './post';\nexport { Comment } from './comment';\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Barrel Export**\n\n**Fix:**\n```typescript\n// index.ts\nexport * from './user';\nexport * from './post';\nexport * from './comment';\n// Barrel exports\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_barrel_export"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Point {\n  x: number;\n  y: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Using interface for everything**\n\n**Fix:**\n```typescript\n// Use type aliases for unions, intersections, tuples\n// Use interfaces for object shapes with declaration merging\ntype Point = { x: number; y: number };\ntype Position = Point & { z: number };\ntype ColorPoint = Point | { color: string };\n// Interfaces support declaration merging and implements\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "using_interface_for_everything"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction log(msg: string) {\n  console.log(msg);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Void Return**\n\n**Fix:**\n```typescript\nfunction log(msg: string): void {\n  console.log(msg);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_void_return"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// utils.ts\nexport function helper() { return 42; }\n// No declaration file for library consumers\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing declaration for .d.ts files**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"declaration\": true,\n    \"declarationMap\": true,\n    \"declarationDir\": \"dist/types\"\n  }\n}\n// Generates .d.ts files for library consumers\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_declaration_for_.d.ts_files"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { describe, it, expect } from 'vitest';\ndescribe('add', () => {\n  it('adds numbers', () => {\n    expect(add(1, 2)).toBe(3);\n  });\n});\n// Fine, but no type testing\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing vitest/typed testing**\n\n**Fix:**\n```typescript\n// Add type-level tests:\nimport { expectTypeOf } from 'vitest';\ndescribe('add', () => {\n  it('returns number', () => {\n    expectTypeOf(add(1, 2)).toBeNumber();\n  });\n  it('adds numbers', () => {\n    expect(add(1, 2)).toBe(3);\n  });\n});\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_vitest/typed_testing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype GetAPIResponse<T> = T extends 'user'\n  ? { name: string; email: string }\n  : T extends 'post'\n    ? { title: string; body: string }\n    : T extends 'comment'\n      ? { text: string; author: string }\n      : never;\n// Hard to maintain\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Complex conditional without helper**\n\n**Fix:**\n```typescript\ntype APIEndpoints = {\n  user: { name: string; email: string };\n  post: { title: string; body: string };\n  comment: { text: string; author: string };\n};\ntype GetAPIResponse<T extends keyof APIEndpoints> = APIEndpoints[T];\n// Lookup type - single source of truth\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "complex_conditional_without_helper"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Action = { type: 'ADD'; value: number } | { type: 'SET'; value: string };\nfunction handle(a: Action) {\n  if (typeof a.type === 'string') { /* not helpful */ }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Narrowing with typeof instead of discriminant**\n\n**Fix:**\n```typescript\ntype Action = { type: 'ADD'; value: number } | { type: 'SET'; value: string };\nfunction handle(a: Action) {\n  if (a.type === 'ADD') {\n    // a is narrowed to { type: 'ADD'; value: number }\n    console.log(a.value); // number\n  }\n  if (a.type === 'SET') {\n    // a is narrowed to { type: 'SET'; value: string }\n    console.log(a.value); // string\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "narrowing_with_typeof_instead_of_discriminant"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Filter<T extends any[], U> = T extends [infer F, ...infer R]\n  ? F extends U\n    ? [...Filter<R, U>]\n    : [...Filter<R, U>]\n  : [];\n// Filters type array\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Level Filter**\n\n**Fix:**\n```typescript\n// Type-level filter\ntype Filter<T extends any[], U> = T extends [infer F, ...infer R]\n  ? F extends U\n    ? [F, ...Filter<R, U>]\n    : Filter<R, U>\n  : [];\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_level_filter"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Config {\n  host: string;\n  port: number;\n}\n// Used as type only\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Only Interface**\n\n**Fix:**\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\n// No runtime cost\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_only_interface"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function retry(fn: () => Promise<any>, count: number) {\n  for (let i = 0; i < count; i++) {\n    try { return await fn(); }\n    catch { if (i === count - 1) throw; }\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Retry with Backoff**\n\n**Fix:**\n```typescript\nasync function retry<T>(\n  fn: () => Promise<T>,\n  maxAttempts: number = 3,\n  baseDelay: number = 1000\n): Promise<T> {\n  for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n    try { return await fn(); }\n    catch (error) {\n      if (attempt === maxAttempts) throw error;\n      const delay = baseDelay * Math.pow(2, attempt - 1);\n      await new Promise(r => setTimeout(r, delay));\n    }\n  }\n  throw new Error('Unreachable');\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_retry_with_backoff"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction throwError(msg: string): never {\n  console.log(msg);\n  return;\n  // Doesn't actually return never\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Never type misunderstanding**\n\n**Fix:**\n```typescript\nfunction throwError(msg: string): never {\n  throw new Error(msg);\n  // never means this function never returns\n  // Use for: infinite loops, always throwing, exhaustive checks\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "never_type_misunderstanding"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst add = (a: number, b: number) => a + b;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Function Return Type**\n\n**Fix:**\n```typescript\nconst add = (a: number, b: number): number => a + b;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_function_return_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst data = await fetch(url);\n// No timeout\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Timeout Wrapper**\n\n**Fix:**\n```typescript\nasync function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {\n  const controller = new AbortController();\n  const id = setTimeout(() => controller.abort(), ms);\n  try { return await promise; }\n  finally { clearTimeout(id); }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_timeout_wrapper"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nlet sum = 0;\nfor (const n of nums) sum += n;\n// Imperative\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Fold Pattern**\n\n**Fix:**\n```typescript\nfunction fold<A, B>(fn: (acc: B, item: A) => B, initial: B): (arr: A[]) => B {\n  return (arr) => arr.reduce(fn, initial);\n}\nconst sum = fold<number, number>((acc, n) => acc + n, 0)(nums);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_fold_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction createUser(name: string, email?: string, age?: number) {\n  return { name, email, age };\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Builder Pattern**\n\n**Fix:**\n```typescript\nclass UserBuilder {\n  private name: string = '';\n  private email: string = '';\n  private age: number | undefined;\n  setName(name: string): this { this.name = name; return this; }\n  setEmail(email: string): this { this.email = email; return this; }\n  setAge(age: number): this { this.age = age; return this; }\n  build(): User {\n    if (!this.name) throw new Error('Name required');\n    return { name: this.name, email: this.email, age: this.age };\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_builder_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry {\n  parseJSON(data);\n} catch (e) {\n  // Swallows all errors\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Empty catch block**\n\n**Fix:**\n```typescript\ntry {\n  parseJSON(data);\n} catch (e) {\n  if (e instanceof SyntaxError) {\n    console.error('Invalid JSON:', e.message);\n    return fallbackValue;\n  }\n  throw e; // Re-throw unexpected errors\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "empty_catch_block"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function readFile(path: string) {\n  const content = fs.readFileSync(path, 'utf-8');\n  return content;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing File Type**\n\n**Fix:**\n```typescript\nimport * as fs from 'fs/promises';\nasync function readFile(path: string): Promise<string> {\n  return fs.readFile(path, 'utf-8');\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_file_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction isString(val: unknown): boolean {\n  return typeof val === 'string';\n}\n// No type narrowing on use\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Generic utility function missing**\n\n**Fix:**\n```typescript\nfunction isString(val: unknown): val is string {\n  return typeof val === 'string';\n}\n// Type predicate narrows the type in conditionals\n// Usage: if (isString(val)) { val.toUpperCase() }\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "generic_utility_function_missing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Config {\n  apiUrl: string;\n  timeout: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing readonly**\n\n**Fix:**\n```typescript\ninterface Config {\n  readonly apiUrl: string;\n  readonly timeout: number;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_readonly"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst Vinyl = require('vinyl');\nconst file = new Vinyl({ path: 'file.txt' });\n// any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Vinyl Typing**\n\n**Fix:**\n```typescript\nimport { File as VinylFile } from 'vinyl';\nconst file = new VinylFile({ path: 'file.txt' });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_vinyl_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst formData = new FormData();\nformData.append('name', value);\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing FormData Typing**\n\n**Fix:**\n```typescript\nconst formData = new FormData();\nformData.append('name', name);\nformData.append('file', file);\nconst response = await fetch(url, {\n  method: 'POST',\n  body: formData,\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_formdata_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Result {\n  data: any;\n  error: any;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Generic in Interface**\n\n**Fix:**\n```typescript\ninterface Result<T, E = Error> {\n  data?: T;\n  error?: E;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_generic_in_interface"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\n// Can use type alias\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Alias vs Interface**\n\n**Fix:**\n```typescript\n// Use type alias for unions/intersections/tuples\ntype UserId = string | number;\ntype UserTuple = [string, number];\ntype UserUnion = Admin | Guest;\n// Use interface for object shapes\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_alias_vs_interface"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nnamespace Utils {\n  export function add(a: number, b: number) { return a + b; }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Namespace Declaration Merging**\n\n**Fix:**\n```typescript\n// Namespaces can merge\nnamespace Utils {\n  export function add(a: number, b: number) { return a + b; }\n}\nnamespace Utils {\n  export function subtract(a: number, b: number) { return a - b; }\n}\n// Both available as Utils.add and Utils.subtract\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_namespace_declaration_merging"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst fd = await fs.open('file.txt', 'r');\nconst content = await fs.read(fd, buffer, 0, buffer.length, 0);\nawait fd.close();\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing FileHandle Typing**\n\n**Fix:**\n```typescript\nconst fd: fs.FileHandle = await fs.open('file.txt', 'r');\ntry {\n  const { bytesRead } = await fd.read(buffer, 0, buffer.length, 0);\n  return buffer.subarray(0, bytesRead);\n} finally {\n  await fd.close();\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_filehandle_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config = {\n  host: 'localhost',\n  port: 3000\n};\nconst typedConfig: Config = config;\n// Type assertion - doesn't check config\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using satisfies operator**\n\n**Fix:**\n```typescript\nconst config = {\n  host: 'localhost',\n  port: 3000\n} satisfies Config;\n// satisfies checks that config matches Config\n// while preserving the specific type of config\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_satisfies_operator"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\ninterface ReadonlyConfig {\n  readonly host: string;\n  readonly port: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Manual readonly type**\n\n**Fix:**\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\ntype ReadonlyConfig = Readonly<Config>;\n// Readonly makes all properties readonly\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "manual_readonly_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config: any = {};\nconfig.host = 'localhost';\nconfig.port = 3000;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Record Typing**\n\n**Fix:**\n```typescript\ntype Config = Record<string, string | number>;\nconst config: Config = {\n  host: 'localhost',\n  port: 3000,\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_record_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\napp.post('/users', (req, res) => {\n  const { name, email } = req.body;\n  // req.body is any\n  createUser({ name, email });\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Zod schema validation**\n\n**Fix:**\n```typescript\nimport { z } from 'zod';\nconst userSchema = z.object({\n  name: z.string().min(1).max(100),\n  email: z.string().email()\n});\n\napp.post('/users', (req, res) => {\n  const result = userSchema.safeParse(req.body);\n  if (!result.success) {\n    return res.status(400).json({ errors: result.error.errors });\n  }\n  createUser(result.data);\n});\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_zod_schema_validation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Config {\n  host: string;\n  port: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Required Utility**\n\n**Fix:**\n```typescript\ninterface Config {\n  host?: string;\n  port?: number;\n}\ntype RequiredConfig = Required<Config>;\n// Makes all properties required\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_required_utility"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  id: number;\n  name: string;\n  email: string;\n  password: string;\n}\ntype SafeUser = {\n  id: number;\n  name: string;\n  email: string;\n};\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Manual omit type**\n\n**Fix:**\n```typescript\ninterface User {\n  id: number;\n  name: string;\n  email: string;\n  password: string;\n}\ntype SafeUser = Omit<User, 'password'>;\n// Omit excludes specific properties\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "manual_omit_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst name = (value as string).toUpperCase();\n// Unsafe assertion\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Type Assertion Instead of Narrowing**\n\n**Fix:**\n```typescript\nif (typeof value === 'string') {\n  const name = value.toUpperCase();\n}\n// Type narrowing is safe\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "type_assertion_instead_of_narrowing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst result = c(b(a(input)));\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Function Composition**\n\n**Fix:**\n```typescript\nfunction compose<T, U, V>(f: (t: U) => V, g: (t: T) => U): (t: T) => V {\n  return (t: T) => f(g(t));\n}\nconst result = compose(c, compose(b, a))(input);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_function_composition"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Admin {\n  name: string;\n  email: string;\n  role: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Interface Extension**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\ninterface Admin extends User {\n  role: string;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_interface_extension"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst hasAdmin = roles.includes('admin');\n// Inferred\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Array.includes Typing**\n\n**Fix:**\n```typescript\nconst roles = ['admin', 'user'] as const;\nconst hasAdmin = roles.includes('admin');\n// Type-safe with as const\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_array.includes_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nerrors.forEach(e => sendError(e));\n// Individual sends\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Batching**\n\n**Fix:**\n```typescript\nasync function batchSend(errors: Error[], batchSize: number = 10): Promise<void> {\n  for (let i = 0; i < errors.length; i += batchSize) {\n    const batch = errors.slice(i, i + batchSize);\n    await sendErrors(batch);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_batching"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype AllStatus = 'draft' | 'published' | 'archived';\ntype ActiveStatus = 'draft' | 'published';\n// Manually listing subset\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using Exclude**\n\n**Fix:**\n```typescript\ntype AllStatus = 'draft' | 'published' | 'archived';\ntype ActiveStatus = Exclude<AllStatus, 'archived'>;\n// Exclude removes specific members from union\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_exclude"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function getData() {\n  const response = await fetch('/api');\n  return response.json();\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing async error handling**\n\n**Fix:**\n```typescript\nasync function getData() {\n  try {\n    const response = await fetch('/api');\n    if (!response.ok) throw new Error(`HTTP ${response.status}`);\n    return await response.json();\n  } catch (error) {\n    logger.error('Fetch failed', error);\n    throw error;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_async_error_handling"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  id: number;\n  name: string;\n}\n// id should never change\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing readonly**\n\n**Fix:**\n```typescript\ninterface User {\n  readonly id: number;\n  name: string;\n}\n// readonly prevents assignment after initialization\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_readonly"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Math {\n  add: any;\n  subtract: any;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Function Signature in Interface**\n\n**Fix:**\n```typescript\ninterface Math {\n  add(a: number, b: number): number;\n  subtract(a: number, b: number): number;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_function_signature_in_interface"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype ElementType<T> = T extends Array<infer U> ? U : T;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Conditional Type with infer**\n\n**Fix:**\n```typescript\n// Extract array element type\ntype ElementType<T> = T extends Array<infer U> ? U : T;\ntype Num = ElementType<number[]>; // number\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_conditional_type_with_infer"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Options {\n  host?: string;\n  port?: number;\n}\n// Need a version with all required\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using Required**\n\n**Fix:**\n```typescript\ninterface Options {\n  host?: string;\n  port?: number;\n}\ntype ResolvedOptions = Required<Options>;\n// Required makes all properties required\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_required"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype UserId = number;\n// Same as any number\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Branded Type**\n\n**Fix:**\n```typescript\n// Branded type for type safety\ntype UserId = number & { readonly brand: unique symbol };\nfunction makeUserId(id: number): UserId {\n  return id as UserId;\n}\nconst id: UserId = makeUserId(42);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_branded_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { User } from './user';\n// Emits even if only type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Import Syntax**\n\n**Fix:**\n```typescript\nimport type { User } from './user';\n// Type-only, no runtime cost\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_import_syntax"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst UserCard: React.FC<UserCardProps> = ({ name }) => {\n  return <div>{name}</div>;\n};\n// FC has implicit children: ReactNode\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using React.FC**\n\n**Fix:**\n```typescript\ninterface UserCardProps {\n  name: string;\n  children?: React.ReactNode;\n}\n\nfunction UserCard({ name, children }: UserCardProps) {\n  return <div>{name}{children}</div>;\n}\n// React.FC is discouraged - explicit props type is clearer\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_react.fc"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nuser.address.city = 'New City';\n// Direct mutation\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Lens Pattern**\n\n**Fix:**\n```typescript\ntype Lens<S, A> = {\n  get: (s: S) => A;\n  set: (a: A, s: S) => S;\n};\nconst cityLens: Lens<User, string> = {\n  get: (u) => u.address.city,\n  set: (city, u) => ({ ...u, address: { ...u.address, city } }),\n};\nconst updated = cityLens.set('New City', user);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_lens_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nglobal.myVar = value;\n// Property doesn't exist on Global\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Global Typing**\n\n**Fix:**\n```typescript\ndeclare global {\n  var myVar: string;\n}\nexport {};\nglobal.myVar = value;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_global_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst results = await Promise.all([a(), b(), c()]);\n// One failure kills all\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Handling in Promise.all**\n\n**Fix:**\n```typescript\nconst results = await Promise.allSettled([a(), b(), c()]);\nconst successes = results\n  .filter((r): r is PromiseFulfilledResult<any> => r.status === 'fulfilled')\n  .map(r => r.value);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_handling_in_promise.all"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst circle = new Circle(5);\nconst rect = new Rect(3, 4);\n// Direct instantiation\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Factory Method**\n\n**Fix:**\n```typescript\ninterface Shape { area(): number; }\nclass ShapeFactory {\n  static createCircle(radius: number): Circle { return new Circle(radius); }\n  static createRect(width: number, height: number): Rect { return new Rect(width, height); }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_factory_method"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype ToArray<T> = [T];\n// Works but doesn't handle edge cases\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing extends never branch**\n\n**Fix:**\n```typescript\ntype ToArray<T> = T extends never ? [] : [T];\n// Handles the never case explicitly\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_extends_never_branch"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nif (type === 'circle') return new Circle();\nif (type === 'rect') return new Rect();\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Factory Pattern**\n\n**Fix:**\n```typescript\ninterface Shape { area(): number; }\nclass ShapeFactory {\n  static create(type: 'circle' | 'rect'): Shape {\n    switch (type) {\n      case 'circle': return new Circle();\n      case 'rect': return new Rect();\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_factory_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { utils } from '../../../../shared/utils';\nimport { models } from '../../../../models';\n// Deep relative imports\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing path mapping**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@shared/*\": [\"src/shared/*\"],\n      \"@models/*\": [\"src/models/*\"]\n    }\n  }\n}\n// Absolute imports from project root\nimport { utils } from '@shared/utils';\nimport { User } from '@models/user';\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_path_mapping"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { Observable } from 'rxjs';\nObservable.prototype.myMethod = function() {};\n// Extension not typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing module augmentation**\n\n**Fix:**\n```typescript\n// augmentation.d.ts\nimport 'rxjs';\ndeclare module 'rxjs' {\n  interface Observable<T> {\n    myMethod(): void;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_module_augmentation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n{\"compilerOptions\": {\n  \"target\": \"ES2020\"\n}}\n// May include DOM types unnecessarily\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing lib**\n\n**Fix:**\n```typescript\n{\"compilerOptions\": {\n  \"target\": \"ES2020\",\n  \"lib\": [\"ES2020\"]\n}}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_lib"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst element = document.getElementById('app')!;\nconst text = element.textContent!;\nconst trimmed = text.trim()!;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Non-null assertion abuse**\n\n**Fix:**\n```typescript\nconst element = document.getElementById('app');\nif (!element) throw new Error('App element not found');\nconst text = element.textContent;\nif (text === null) return;\nconst trimmed = text.trim();\n// Prefer explicit checks over non-null assertions\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "non-null_assertion_abuse"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype GetKey<T, K> = T[K];\n// Fails if K is not a key of T\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using keyof with conditional**\n\n**Fix:**\n```typescript\ntype GetKey<T, K extends keyof T> = T[K];\n// K is constrained to keys of T\n// Type error if K is invalid\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_keyof_with_conditional"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction* ids() {\n  yield 1;\n  yield 2;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Generator Return Type**\n\n**Fix:**\n```typescript\nfunction* ids(): Generator<number> {\n  yield 1;\n  yield 2;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_generator_return_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nnew Class();\n// No typing\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Constructor Type**\n\n**Fix:**\n```typescript\ninterface Newable<T> {\n  new (...args: any[]): T;\n}\nfunction create<T>(cls: Newable<T>): T {\n  return new cls();\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_constructor_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst module = await import('./module');\n// any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Dynamic Import Typing**\n\n**Fix:**\n```typescript\ntype Module = typeof import('./module');\nconst module: Module = await import('./module');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_dynamic_import_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface RequiredConfig {\n  host: string;\n  port: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Required Constraint**\n\n**Fix:**\n```typescript\ninterface Config {\n  host?: string;\n  port?: number;\n}\ntype RequiredConfig = Required<Config>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_required_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction sum(a: number, b: number, c: number) {\n  return a + b + c;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Rest Parameters**\n\n**Fix:**\n```typescript\nfunction sum(...args: number[]): number {\n  return args.reduce((acc, val) => acc + val, 0);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_rest_parameters"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n{\"compilerOptions\": {\n  \"target\": \"ES2020\",\n  \"module\": \"commonjs\"\n}}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing strict mode**\n\n**Fix:**\n```typescript\n{\"compilerOptions\": {\n  \"target\": \"ES2020\",\n  \"module\": \"ESNext\",\n  \"strict\": true,\n  \"esModuleInterop\": true,\n  \"skipLibCheck\": true,\n  \"forceConsistentCasingInFileNames\": true\n}}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_strict_mode"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry { operation(); } catch {\n  throw new Error('Failed');\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Cause Chain**\n\n**Fix:**\n```typescript\ntry { operation(); } catch (cause) {\n  throw new Error('Failed', {\n    cause: cause instanceof Error ? cause : undefined,\n  });\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_cause_chain"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst headers = {\n  'Content-Type': 'application/json',\n  'Authorization': `Bearer ${token}`,\n};\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing HTTP Headers Typing**\n\n**Fix:**\n```typescript\nconst headers: HeadersInit = {\n  'Content-Type': 'application/json',\n  'Authorization': `Bearer ${token}`,\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_http_headers_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(val: unknown) {\n  if (Array.isArray(val)) {\n    return val.length;\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with Array.isArray**\n\n**Fix:**\n```typescript\n// Array.isArray narrowing\nfunction process(val: unknown): number {\n  if (Array.isArray(val)) {\n    return val.length; // val is unknown[]\n  }\n  return 0;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_array.isarray"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry { return await fetch(url); }\n    catch (error) {\n      throw new Error('Failed');\n    }\n// Loses original error\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Decorrelation**\n\n**Fix:**\n```typescript\ntry { return await fetch(url); }\n    catch (cause) {\n      throw new Error('Request failed', {\n        cause: cause instanceof Error ? cause : new Error(String(cause)),\n      });\n    }\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_decorrelation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  id: number;\n  name: string;\n  email: string;\n  password: string;\n}\ninterface PublicUser {\n  id: number;\n  name: string;\n  email: string;\n}\n// Manually picking fields\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Manual pick type**\n\n**Fix:**\n```typescript\ninterface User {\n  id: number;\n  name: string;\n  email: string;\n  password: string;\n}\ntype PublicUser = Pick<User, 'id' | 'name' | 'email'>;\n// Pick selects specific properties\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "manual_pick_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Map<T extends any[], U> = T extends [infer F, ...infer R]\n  ? [U, ...Map<R, U>]\n  : [];\n// Maps all elements to U\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Level Map**\n\n**Fix:**\n```typescript\n// Type-level map\ntype Map<T extends any[], U> = T extends [infer F, ...infer R]\n  ? [U, ...Map<R, U>]\n  : [];\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_level_map"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport './polyfills';\n// May be tree-shaken\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Side-Effect Import**\n\n**Fix:**\n```typescript\nimport 'core-js/stable';\n// Side-effect only import\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_side-effect_import"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction add(a: number, b: number, c: number) { return a + b + c; }\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Partial Application**\n\n**Fix:**\n```typescript\nfunction add(a: number) {\n  return (b: number) => {\n    return (c: number): number => a + b + c;\n  };\n}\nconst add5 = add(5);\nconst result = add5(3)(2); // 10\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_partial_application"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Mutable<T> = { -readonly P: T[P]; };\n// Custom utility\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Mutable**\n\n**Fix:**\n```typescript\ntype Mutable<T> = {\n  -readonly [K in keyof T]: T[K];\n};\n// Remove readonly from all properties\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_mutable"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntest.each([\n  [1, 2, 3],\n  [0, 0, 0],\n])('adds %d + %d = %d', (a, b, expected) => {\n  expect(a + b).toBe(expected);\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Test Parameterized Typing**\n\n**Fix:**\n```typescript\ntest.each<[number, number, number]>([\n  [1, 2, 3],\n  [0, 0, 0],\n])('adds %d + %d = %d', (a, b, expected) => {\n  expect(add(a, b)).toBe(expected);\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_test_parameterized_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Document = { content: string; };\n// No state tracking\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Phantom Type**\n\n**Fix:**\n```typescript\n// Phantom type for state\ntype Document<S> = { content: string; _state: S; };\ntype Draft = Document<'draft'>;\ntype Published = Document<'published'>;\n// State is tracked at type level\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_phantom_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport * as Types from './types';\n// Namespace import\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Namespace**\n\n**Fix:**\n```typescript\nimport type * as Types from './types';\n// Type-only namespace\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_namespace"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype User = { name: string; email: string; };\n// Use interface for object shapes\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Type Alias vs Interface**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n}\n// Interfaces support declaration merging\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "type_alias_vs_interface"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction logItems(items: string[]): void {\n  for (const item of items) {\n    console.log(item);\n  }\n}\n// Function doesn't mutate the array\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Generic array type instead of readonly**\n\n**Fix:**\n```typescript\nfunction logItems(items: readonly string[]): void {\n  for (const item of items) {\n    console.log(item);\n  }\n}\n// readonly signals: this function won't modify the array\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "generic_array_type_instead_of_readonly"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst user = input as User;\n// Unsafe cast\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Validator**\n\n**Fix:**\n```typescript\nfunction validateUser(input: unknown): input is User {\n  return (\n    typeof input === 'object' &&\n    input !== null &&\n    'id' in input &&\n    'name' in input &&\n    typeof (input as any).id === 'number' &&\n    typeof (input as any).name === 'string'\n  );\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_validator"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [users, posts] = await Promise.all([\n  fetchUsers(),\n  fetchPosts(),\n]);\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Promise.all typing**\n\n**Fix:**\n```typescript\nconst [users, posts] = await Promise.all<\n  [Promise<User[]>, Promise<Post[]>]\n>([\n  fetchUsers(),\n  fetchPosts(),\n]);\n// Preserves tuple types\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_promise.all_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst value = input.replace(/</g, '&lt;').replace(/>/g, '&gt;');\n// Manual sanitization\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Sanitize Typing**\n\n**Fix:**\n```typescript\nimport { escape } from 'html-escaper';\nconst safe: string = escape(input);\n// Proper HTML escaping\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_sanitize_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n{\"compilerOptions\": {\n  \"declaration\": true\n}}\n// No source mapping\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing declaration map**\n\n**Fix:**\n```typescript\n{\"compilerOptions\": {\n  \"declaration\": true,\n  \"declarationMap\": true\n}}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_declaration_map"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntsc && node dist/index.js\n// Compile then run\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using ts-node for dev**\n\n**Fix:**\n```typescript\n// tsconfig.json has \"sourceMap\": true\nnpx ts-node src/index.ts\n// Or: tsx src/index.ts (faster)\n// Direct TypeScript execution without compilation step\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_ts-node_for_dev"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config = {\n  host: 'localhost',\n  port: 3000,\n} as ServerConfig;\n// Loses specific type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with satisfies**\n\n**Fix:**\n```typescript\n// satisfies operator (TS 4.9+)\nconst config = {\n  host: 'localhost',\n  port: 3000,\n} satisfies ServerConfig;\n// Validates AND preserves literal types\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_satisfies"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction validate(value: string): void {\n  if (value.length === 0) {\n    throw 'Value is required';\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Throwing string instead of Error**\n\n**Fix:**\n```typescript\nfunction validate(value: string): void {\n  if (value.length === 0) {\n    throw new ValidationError('Value is required');\n  }\n}\n// Always throw Error instances - strings lack stack traces\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "throwing_string_instead_of_error"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function* fetchAll() {\n  for (let i = 0; ; i++) {\n    yield await fetchPage(i);\n    // One failure stops all iteration\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Error handling in async iterator**\n\n**Fix:**\n```typescript\nasync function* fetchAll() {\n  for (let i = 0; ; i++) {\n    try {\n      const page = await fetchPage(i);\n      if (!page.items.length) break;\n      yield* page.items;\n    } catch (e) {\n      if (e instanceof NotFoundError) break;\n      throw e;\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "error_handling_in_async_iterator"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst name = Status[Status.Active];\n// Reverse mapping\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum Reverse Mapping**\n\n**Fix:**\n```typescript\n// Reverse mapping exists for numeric enums\n// For string enums, use a map:\nconst StatusNames: Record<Status, string> = {\n  [Status.Active]: 'Active',\n  [Status.Inactive]: 'Inactive',\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_reverse_mapping"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function retry(fn: () => Promise<any>) {\n  try { return await fn(); }\n  catch { return await fn(); }\n}\n// Retries all errors\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Retryable Errors**\n\n**Fix:**\n```typescript\nclass RetryableError extends Error { }\nclass FatalError extends Error { }\nasync function retry<T>(fn: () => Promise<T>, max: number = 3): Promise<T> {\n  for (let i = 0; i < max; i++) {\n    try { return await fn(); }\n    catch (error) {\n      if (error instanceof FatalError) throw error;\n      if (i === max - 1) throw error;\n    }\n  }\n  throw new Error('Unreachable');\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_retryable_errors"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction expensive(n: number) {\n  // Computation\n  return n * n;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Memoization Pattern**\n\n**Fix:**\n```typescript\nfunction memoize<T extends (...args: any[]) => any>(fn: T): T {\n  const cache = new Map<string, ReturnType<T>>();\n  return ((...args: Parameters<T>): ReturnType<T> => {\n    const key = JSON.stringify(args);\n    if (!cache.has(key)) cache.set(key, fn(...args));\n    return cache.get(key)!;\n  }) as T;\n}\nconst expensive = memoize((n: number) => n * n);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_memoization_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst emitter = new EventEmitter();\nemitter.on('data', (data) => { });\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Event Emitter Typing**\n\n**Fix:**\n```typescript\ninterface Events {\n  data: [string];\n  error: [Error];\n}\nconst emitter = new EventEmitter();\nemitter.on('data', (data: string) => { });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_event_emitter_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst stream = fs.createReadStream('file.txt');\nstream.on('data', (chunk) => { });\n// chunk is any\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Stream Typing**\n\n**Fix:**\n```typescript\nimport { Readable } from 'stream';\nconst stream = fs.createReadStream('file.txt');\nstream.on('data', (chunk: Buffer) => { });\n// Explicit Buffer type\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_stream_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Color = 'red' | 'green' | 'blue';\ntype BackgroundColor = 'bg-red' | 'bg-green' | 'bg-blue';\n// Duplicated\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing template literal types**\n\n**Fix:**\n```typescript\ntype Color = 'red' | 'green' | 'blue';\ntype BackgroundColor = `bg-${Color}`;\n// Template literal types generate derived string types\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_template_literal_types"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst result = a.map((val, i) => val + b[i]);\n// Assumes same length\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing ZipWith Pattern**\n\n**Fix:**\n```typescript\nfunction zipWith<A, B, C>(fn: (a: A, b: B) => C): (a: A[], b: B[]) => C[] {\n  return (arrA, arrB) => {\n    const len = Math.min(arrA.length, arrB.length);\n    return Array.from({ length: len }, (_, i) => fn(arrA[i], arrB[i]));\n  };\n}\nconst result = zipWith((a, b) => a + b)(arrA, arrB);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_zipwith_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction assertParam(val: unknown, name: string) {\n  if (!val) throw new Error(`${name} required`);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Param Assertion**\n\n**Fix:**\n```typescript\nfunction assertParam<T>(val: T, name: string): asserts val is NonNullable<T> {\n  if (val == null) {\n    throw new TypeError(`${name} is required`);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_param_assertion"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst items: string[] = ['a', 'b'];\n// Mutable\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Readonly Array**\n\n**Fix:**\n```typescript\nconst items: readonly string[] = ['a', 'b'];\n// Immutable array\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_readonly_array"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nthrow new Error('Not found');\nthrow new Error('Validation failed');\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Subclass**\n\n**Fix:**\n```typescript\nclass NotFoundError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = 'NotFoundError';\n  }\n}\nclass ValidationError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = 'ValidationError';\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_subclass"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype ToArray<T> = T[];\ntype Result = ToArray<string | number>;\n// (string | number)[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Union Distribution**\n\n**Fix:**\n```typescript\n// Conditional types distribute over unions\ntype ToArray<T> = T extends any ? T[] : never;\ntype Result = ToArray<string | number>;\n// string[] | number[]\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_union_distribution"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [user, setUser] = useState(null);\n// user: null, no type safety\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not typing useState**\n\n**Fix:**\n```typescript\nconst [user, setUser] = useState<User | null>(null);\n// Explicit type - user is User | null\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_typing_usestate"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface UpdateUser {\n  name?: string;\n  email?: string;\n  age?: number;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Partial**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  age: number;\n}\ntype UpdateUser = Partial<User>;\n// All optional\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_partial"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction process(items: unknown[]) {\n  for (const item of items) {\n    if (typeof item === 'string') {\n      console.log(item.toUpperCase());\n    }\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Guard Function**\n\n**Fix:**\n```typescript\nfunction isString(value: unknown): value is string {\n  return typeof value === 'string';\n}\nfunction process(items: unknown[]): void {\n  for (const item of items) {\n    if (isString(item)) {\n      console.log(item.toUpperCase());\n    }\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_guard_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [form, setForm] = useState({});\n// Type: {}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Form typing**\n\n**Fix:**\n```typescript\ninterface FormData {\n  name: string;\n  email: string;\n  age: number;\n}\nconst [form, setForm] = useState<FormData>({ name: '', email: '', age: 0 });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_form_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface StatusMap {\n  pending: string;\n  active: string;\n  inactive: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Manual record type**\n\n**Fix:**\n```typescript\ntype Status = 'pending' | 'active' | 'inactive';\ntype StatusMap = Record<Status, string>;\n// Record creates a mapping type from keys to values\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "manual_record_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction fetchUser(id: number, options: FetchOptions): Promise<User> {\n  // ...\n}\n// Need the parameter types elsewhere\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using Parameters**\n\n**Fix:**\n```typescript\nfunction fetchUser(id: number, options: FetchOptions): Promise<User> {\n  // ...\n}\ntype FetchUserArgs = Parameters<typeof fetchUser>;\n// Extracts [number, FetchOptions] as a tuple type\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_parameters"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Base { }\nclass Child extends Base { }\nclass Grandchild extends Child { }\n// Unintended inheritance\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Class Final**\n\n**Fix:**\n```typescript\nclass Base { }\nfinal class Child extends Base { }\n// Cannot extend further\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_class_final"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [value, setValue] = useState('');\n// No callback type\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Callback Typing**\n\n**Fix:**\n```typescript\ntype SetValue = (value: string | ((prev: string) => string)) => void;\nconst [value, setValue] = useState<string>('');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_callback_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst results = await Promise.allSettled(promises);\nresults.forEach(r => {\n  if (r.status === 'fulfilled') console.log(r.value);\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Promise Settled Result**\n\n**Fix:**\n```typescript\nconst results = await Promise.allSettled<string>(promises);\nresults.forEach((r) => {\n  if (r.status === 'fulfilled') {\n    console.log(r.value); // Typed as string\n  }\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_promise_settled_result"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfor (const key in Status) {\n  if (typeof Status[key] === 'number') {\n    console.log(key, Status[key]);\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Enum Iteration**\n\n**Fix:**\n```typescript\nconst values = Object.values(Status).filter(v => typeof v === 'number') as Status[];\nfor (const value of values) {\n  console.log(Status[value], value);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_enum_iteration"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Shape = { kind: 'circle'; radius: number } | { kind: 'square'; size: number };\nfunction area(s: Shape): number {\n  if (s.kind === 'circle') return Math.PI * s.radius ** 2;\n  return s.size ** 2;\n  // No error if new variant added\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Non-exhaustive union handling**\n\n**Fix:**\n```typescript\ntype Shape = { kind: 'circle'; radius: number } | { kind: 'square'; size: number };\nfunction area(s: Shape): number {\n  switch (s.kind) {\n    case 'circle': return Math.PI * s.radius ** 2;\n    case 'square': return s.size ** 2;\n    default: {\n      const _exhaustive: never = s;\n      throw new Error(`Unhandled shape: ${_exhaustive}`);\n    }\n  }\n}\n// TypeScript catches missing cases at compile time\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "non-exhaustive_union_handling"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst chunks: T[][] = [];\nfor (let i = 0; i < items.length; i += size) {\n  chunks.push(items.slice(i, i + size));\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Chunking**\n\n**Fix:**\n```typescript\nfunction chunk<T>(items: T[], size: number): T[][] {\n  return Array.from({ length: Math.ceil(items.length / size) }, (_, i) =>\n    items.slice(i * size, i * size + size)\n  );\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_chunking"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [state, dispatch] = useReducer(reducer, initialState);\n// dispatch is unknown\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Reducer typing**\n\n**Fix:**\n```typescript\ntype Action = { type: 'increment' } | { type: 'decrement' };\nconst reducer = (state: number, action: Action): number => {\n  switch (action.type) {\n    case 'increment': return state + 1;\n    case 'decrement': return state - 1;\n  }\n};\nconst [state, dispatch] = useReducer<typeof reducer, number, undefined>(reducer, 0);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_reducer_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst diff = arr1.filter(x => !arr2.includes(x));\n// O(n*m)\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Difference**\n\n**Fix:**\n```typescript\nfunction difference<T>(a: T[], b: T[]): T[] {\n  const setB = new Set(b);\n  return a.filter(x => !setB.has(x));\n}\n// O(n+m)\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_difference"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nif (error.rate > threshold) alert();\n// No budget tracking\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Budget**\n\n**Fix:**\n```typescript\nclass ErrorBudget {\n  private failures = 0;\n  private successes = 0;\n  constructor(private target: number) {}\n  record(success: boolean) {\n    if (success) this.successes++;\n    else this.failures++;\n  }\n  get remaining(): number {\n    const total = this.successes + this.failures;\n    return Math.max(0, this.target * total - this.failures);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_budget"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction parse<T extends any>(json: string): T {\n  return JSON.parse(json);\n  // any defeats type safety\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Extends constraint too broad**\n\n**Fix:**\n```typescript\nfunction parse<T extends object>(json: string): T {\n  return JSON.parse(json);\n}\n// Or better: use a schema validation library\n// Don't lie about types at parse time\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "extends_constraint_too_broad"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\napp.use((err, req, res, next) => {\n  res.status(500).json({ error: err.message });\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Express Error Handler Typing**\n\n**Fix:**\n```typescript\nimport { Request, Response, NextFunction } from 'express';\nimport { Errback } from 'express';\napp.use((err: Error, req: Request, res: Response, next: NextFunction) => {\n  res.status(500).json({ error: err.message });\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_express_error_handler_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst csrf = require('csurf');\n// No typing\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing CSRF Token Typing**\n\n**Fix:**\n```typescript\nimport csrf from 'csurf';\nimport { CookieOptions } from 'express-serve-static-core';\nconst protection = csrf({\n  cookie: { secure: true, httpOnly: true } as CookieOptions,\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_csrf_token_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function safe<T>(promise: Promise<T>): Promise<[Error | null, T | null]> {\n  try {\n    const data = await promise;\n    return [null, data];\n  } catch (error) {\n    return [error as Error, null];\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Safe Async Wrapper**\n\n**Fix:**\n```typescript\nasync function safe<T>(promise: Promise<T>): Promise<[Error | null, T | null]> {\n  try {\n    const data = await promise;\n    return [null, data];\n  } catch (error) {\n    return [error instanceof Error ? error : new Error(String(error)), null];\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_safe_async_wrapper"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n{\"compilerOptions\": {\n  \"strict\": false\n}}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing noImplicitAny**\n\n**Fix:**\n```typescript\n{\"compilerOptions\": {\n  \"strict\": true\n  // Enables noImplicitAny among other checks\n}}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_noimplicitany"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst sum = nums.reduce((acc, n) => acc + n, 0);\n// Inferred\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Array.reduce Typing**\n\n**Fix:**\n```typescript\nconst sum: number = nums.reduce<number>((acc, n) => acc + n, 0);\n// Explicit return type\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_array.reduce_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst helmet = require('helmet');\napp.use(helmet());\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Helmet Typing**\n\n**Fix:**\n```typescript\nimport helmet from 'helmet';\napp.use(helmet({\n  contentSecurityPolicy: {\n    directives: {\n      defaultSrc: [\"'self'\"],\n      scriptSrc: [\"'self'\"],\n    },\n  },\n}));\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_helmet_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Handler = (request: Request, response: Response) => void;\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Function Type Alias**\n\n**Fix:**\n```typescript\ntype Handler = (req: Request, res: Response) => void;\n// Shorter parameter names for readability\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_function_type_alias"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Point = { x: number; y: number };\n// Duplicated\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing typeof operator**\n\n**Fix:**\n```typescript\nconst origin = { x: 0, y: 0 };\ntype Point = typeof origin; // { x: number; y: number }\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_typeof_operator"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"moduleResolution\": \"classic\"\n  }\n}\n// Doesn't resolve .js extensions or node_modules\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing module resolution**\n\n**Fix:**\n```typescript\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"moduleResolution\": \"node16\",\n    \"module\": \"Node16\",\n    \"resolvePackageJsonImports\": true\n  }\n}\n// Node16 matches Node.js module resolution\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_module_resolution"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry {\n  await fetchUser(id);\n} catch (error) {\n  console.log('Error');\n  // No type narrowing on error\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Catching generic Error**\n\n**Fix:**\n```typescript\ntry {\n  await fetchUser(id);\n} catch (error) {\n  if (error instanceof ValidationError) {\n    showFormErrors(error.fields);\n  } else if (error instanceof NotFoundError) {\n    showNotFound();\n  } else {\n    showError('Unexpected error');\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "catching_generic_error"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst [form, setForm] = useState({ name: '', email: '' });\n// No validation\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Validation**\n\n**Fix:**\n```typescript\ninterface FormState {\n  name: string;\n  email: string;\n  errors: Partial<Record<keyof FormState, string>>;\n}\nconst [form, setForm] = useState<FormState>({ name: '', email: '', errors: {} });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_validation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction first<T>(arr: T[]): T {\n  return arr[0];\n  // Returns T | undefined\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Generic without constraint**\n\n**Fix:**\n```typescript\nfunction first<T>(arr: readonly T[]): T | undefined {\n  return arr[0];\n}\n// Handle empty arrays. readonly works with mutable arrays too.\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "generic_without_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst cache = new WeakMap();\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing WeakMap Typing**\n\n**Fix:**\n```typescript\nclass Token {\n  private constructor() {}\n}\nconst cache = new WeakMap<object, Token>();\n// Keys must be objects\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_weakmap_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction getId(id: string | number): string {\n  return id.toString(); // Works but hides type issues\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Union type without narrowing**\n\n**Fix:**\n```typescript\nfunction getId(id: string | number): string {\n  if (typeof id === 'string') {\n    return id; // Type narrowed to string\n  }\n  return id.toString(); // Type narrowed to number\n}\n// Explicit narrowing makes intent clear\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "union_type_without_narrowing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst snake = camel.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);\n// Inline\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Data Transformer**\n\n**Fix:**\n```typescript\nfunction camelToSnake(str: string): string {\n  return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);\n}\nfunction snakeToCamel(str: string): string {\n  return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_data_transformer"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype ValueOf<T> = T[keyof T];\n// Gets union of all values\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing keyof Constraint**\n\n**Fix:**\n```typescript\n// Get all possible values\ntype ValueOf<T> = T[keyof T];\ntype UserValues = ValueOf<User>;\n// string | number | boolean\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_keyof_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nclass Animal {\n  speak() { return this; }\n}\nclass Dog extends Animal { }\nconst dog = new Dog().speak();\n// Type: Animal\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Polymorphic This**\n\n**Fix:**\n```typescript\nclass Animal {\n  speak(): this { return this; }\n}\nclass Dog extends Animal { }\nconst dog = new Dog().speak();\n// Type: Dog\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_polymorphic_this"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config = {\n  apiUrl: 'https://api.com',\n  timeout: 5000,\n};\n// Mutable properties\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing as const**\n\n**Fix:**\n```typescript\nconst config = {\n  apiUrl: 'https://api.com',\n  timeout: 5000,\n} as const;\n// All properties readonly\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_as_const"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst id = setInterval(task, 1000);\nclearInterval(id);\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing setInterval typing**\n\n**Fix:**\n```typescript\nconst id: ReturnType<typeof setInterval> = setInterval(task, 1000);\nclearInterval(id);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_setinterval_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Direction = 'up' | 'down' | 'left' | 'right';\n// Manual enum\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with template literal**\n\n**Fix:**\n```typescript\ntype Cardinal = 'north' | 'south' | 'east' | 'west';\ntype Direction = `${Cardinal}`;\n// Template literal type\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_template_literal"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction area(shape: Shape) {\n  if (shape.kind === 'circle') {\n    return Math.PI * shape.radius * shape.radius;\n  }\n  return shape.width * shape.height;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guard**\n\n**Fix:**\n```typescript\nfunction isCircle(shape: Shape): shape is Circle {\n  return shape.kind === 'circle';\n}\nfunction area(shape: Shape) {\n  if (isCircle(shape)) {\n    return Math.PI * shape.radius * shape.radius;\n  }\n  return shape.width * shape.height;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guard"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface A { a: string; }\ninterface B { b: number; }\nfunction process(obj: A | B) {\n  if ('a' in obj) return obj.a;\n  return obj.b;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Guards with in**\n\n**Fix:**\n```typescript\n// 'in' narrowing\nfunction process(obj: A | B): string | number {\n  if ('a' in obj) return obj.a; // obj is A\n  return obj.b; // obj is B\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_guards_with_in"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handle(shape: Shape) {\n  if (shape.kind === 'circle') { }\n  else if (shape.kind === 'rect') { }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Narrowing with switch**\n\n**Fix:**\n```typescript\nfunction handle(shape: Shape) {\n  switch (shape.kind) {\n    case 'circle':\n      // shape is Circle\n      return Math.PI * shape.radius ** 2;\n    case 'rect':\n      // shape is Rect\n      return shape.width * shape.height;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_narrowing_with_switch"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface UserDisplay {\n  name: string;\n  email: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Pick Constraint**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  email: string;\n  age: number;\n}\ntype UserDisplay = Pick<User, 'name' | 'email'>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_pick_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nthrow new Error('Operation failed');\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Context**\n\n**Fix:**\n```typescript\nclass ContextError extends Error {\n  constructor(message: string, public context: Record<string, unknown>) {\n    super(message);\n    this.name = 'ContextError';\n  }\n}\nthrow new ContextError('Operation failed', { input, userId, timestamp: Date.now() });\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_context"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst Context = createContext(null);\n// Type: null\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Context typing**\n\n**Fix:**\n```typescript\ninterface ContextType {\n  user: User | null;\n  setUser: (user: User | null) => void;\n}\nconst Context = createContext<ContextType | null>(null);\nconst context = useContext(Context);\nif (!context) throw new Error('Context not found');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_context_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction create(id: number, name: string) { }\ntype CreateParams = [number, string];\n// Duplicated\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Parameters**\n\n**Fix:**\n```typescript\nfunction create(id: number, name: string) { }\ntype CreateParams = Parameters<typeof create>;\n// Derived from function\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_parameters"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst logger = (store) => (next) => (action) => {\n  console.log(action);\n  return next(action);\n};\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing State Middleware Typing**\n\n**Fix:**\n```typescript\ntype Middleware = (store: Store<State, Action>) => (next: Dispatch<Action>) => (action: Action) => void;\nconst logger: Middleware = (store) => (next) => (action) => {\n  console.log('dispatching', action);\n  return next(action);\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_state_middleware_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface ApiResponse {\n  success: boolean;\n  data?: User;\n  error?: string;\n}\n// Both data and error optional - which is set?\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not using discriminated union for API responses**\n\n**Fix:**\n```typescript\ntype ApiResponse<T, E = string> =\n  | { success: true; data: T; error?: never }\n  | { success: false; data?: never; error: E };\n// Exactly one of data/error is present\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_using_discriminated_union_for_api_responses"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst config: [string, number] = ['host', 3000];\n// Mutable\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Readonly Tuple**\n\n**Fix:**\n```typescript\nconst config: readonly [string, number] = ['host', 3000];\n// Immutable tuple\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_readonly_tuple"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction add(a: number, b: number) {\n  return a + b;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Return Type**\n\n**Fix:**\n```typescript\nfunction add(a: number, b: number): number {\n  return a + b;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_return_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst map = new Map();\nmap.set('key', value);\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Map Typing**\n\n**Fix:**\n```typescript\nconst map = new Map<string, number>();\nmap.set('key', 42);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_map_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst { pipeline } = require('stream/promises');\nawait pipeline(src, transform, dest);\n// No typing\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Stream Pipeline Typing**\n\n**Fix:**\n```typescript\nimport { pipeline } from 'stream/promises';\nimport { Readable, Writable, Transform } from 'stream';\nawait pipeline(\n  src as Readable,\n  transform as Transform,\n  dest as Writable\n);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_stream_pipeline_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntry { return processData(input); }\n    catch { return null; }\n// Silent failure\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Recovery**\n\n**Fix:**\n```typescript\ntry { return { ok: true, data: processData(input) } as const; }\n    catch (error) {\n      logger.error('Processing failed', error);\n      return { ok: false, error: error as Error } as const;\n    }\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_recovery"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function getUser(id: number) {\n  const response = await fetch(`/api/users/${id}`);\n  return response.json();\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Repository Pattern**\n\n**Fix:**\n```typescript\ninterface UserRepository {\n  findById(id: number): Promise<User>;\n  findAll(): Promise<User[]>;\n  create(user: CreateUserDto): Promise<User>;\n  update(id: number, data: Partial<User>): Promise<User>;\n  delete(id: number): Promise<void>;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_repository_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst arr = Array.from(string);\n// Type: string[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Array.from Typing**\n\n**Fix:**\n```typescript\nconst chars = Array.from<string>('hello');\n// Explicit element type\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_array.from_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction create(id: number, name: string) { }\ntype CreateParams = [number, string];\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Parameters Extraction**\n\n**Fix:**\n```typescript\nfunction create(id: number, name: string) { }\ntype CreateParams = Parameters<typeof create>;\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_parameters_extraction"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst Component = ({ name }: { name: string }) => {\n  return <div>{name}</div>;\n};\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing React.FC**\n\n**Fix:**\n```typescript\ninterface Props {\n  name: string;\n}\nconst Component: React.FC<Props> = ({ name }) => {\n  return <div>{name}</div>;\n};\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_react.fc"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction first(items: any[]): any {\n  return items[0];\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Generic**\n\n**Fix:**\n```typescript\nfunction first<T>(items: T[]): T | undefined {\n  return items[0];\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_generic"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface User {\n  name: string;\n  password: string;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Sensitive Data Typing**\n\n**Fix:**\n```typescript\ninterface User {\n  name: string;\n  // Never store plain text passwords\n  passwordHash: string;\n}\ninterface UserCreate {\n  name: string;\n  password: string;\n  // Only during creation, hashed before storage\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_sensitive_data_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function health() {\n  return { status: 'ok' };\n}\n// No dependency checks\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Error Health Check**\n\n**Fix:**\n```typescript\ninterface HealthCheck {\n  name: string;\n  check(): Promise<{ healthy: boolean; details?: string }>;\n}\nasync function health(checks: HealthCheck[]): Promise<HealthStatus> {\n  const results = await Promise.allSettled(checks.map(c => c.check()));\n  const unhealthy = results\n    .filter((r): r is PromiseFulfilledResult<{ healthy: boolean }> =>\n      r.status === 'fulfilled' && !r.value.healthy\n    );\n  return { status: unhealthy.length === 0 ? 'healthy' : 'degraded', checks: results.length };\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_error_health_check"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction getOrThrow(obj: Record<string, unknown>, key: string): unknown {\n  if (!(key in obj)) throw new Error(`Missing ${key}`);\n  return obj[key];\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Prismatic Pattern**\n\n**Fix:**\n```typescript\ntype Optic<S, A> = {\n  view: (s: S) => A;\n  review: (a: A, s: S) => S;\n};\n// Focused access pattern\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_prismatic_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst set = new Set();\nset.add('value');\n// Un typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Set Typing**\n\n**Fix:**\n```typescript\nconst set = new Set<string>();\nset.add('value');\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_set_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction handleError(error: unknown): void {\n  console.log(error.message); // Error - unknown has no message\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Type guard missing for error**\n\n**Fix:**\n```typescript\nfunction handleError(error: unknown): void {\n  if (error instanceof Error) {\n    console.error(error.message, error.stack);\n  } else {\n    console.error('Unknown error:', error);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "type_guard_missing_for_error"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst data = legacyApi.getData();\n// Legacy API returns different format\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Adapter Pattern**\n\n**Fix:**\n```typescript\ninterface UserData { id: number; name: string; }\ninterface LegacyData { userId: number; fullName: string; }\nclass UserAdapter {\n  adapt(legacy: LegacyData): UserData {\n    return { id: legacy.userId, name: legacy.fullName };\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_adapter_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction setUsername(username: string) {\n  this.username = username;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Input Length Validation**\n\n**Fix:**\n```typescript\nfunction setUsername(username: string): void {\n  if (username.length < 3 || username.length > 32) {\n    throw new ValidationError('Username must be 3-32 characters');\n  }\n  this.username = username;\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_input_length_validation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst pair: [string, number] = ['test', 42];\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Tuple Type**\n\n**Fix:**\n```typescript\ntype Pair<K, V> = [key: K, value: V];\nconst pair: Pair<string, number> = ['test', 42];\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_tuple_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function* fetchAll(urls: string[]) {\n  for (const url of urls) {\n    yield await fetch(url);\n  }\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing AsyncIterator**\n\n**Fix:**\n```typescript\nasync function* fetchAll(urls: string[]): AsyncIterableIterator<Response> {\n  for (const url of urls) {\n    yield await fetch(url);\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_asynciterator"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst keys = pairs.map(p => p[0]);\nconst values = pairs.map(p => p[1]);\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Unzip Pattern**\n\n**Fix:**\n```typescript\nfunction unzip<A, B>(pairs: [A, B][]): [A[], B[]] {\n  return [pairs.map(p => p[0]), pairs.map(p => p[1])];\n}\nconst [keys, values] = unzip(pairs);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_unzip_pattern"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction createArray(length: number, value: unknown): unknown[] {\n  return Array(length).fill(value);\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Parameter in Return**\n\n**Fix:**\n```typescript\nfunction createArray<T>(length: number, value: T): T[] {\n  return Array(length).fill(value);\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_parameter_in_return"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { User } from 'lib';\n// May import entire library\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Deep Import**\n\n**Fix:**\n```typescript\nimport { User } from 'lib/models/user';\n// Deep import, smaller bundle\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_deep_import"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Store {\n  [key: string]: any;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Index signature too broad**\n\n**Fix:**\n```typescript\ninterface Store {\n  [key: string]: unknown;\n  // Or be specific:\n  // [key: string]: string | number | boolean;\n}\n// unknown forces type checking on reads\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "index_signature_too_broad"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\napp.get('/users/:id', (req, res) => {\n  const id = req.params.id;\n  // id is string, no validation\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Not typing Express handlers**\n\n**Fix:**\n```typescript\nimport { Request, Response } from 'express';\n\napp.get('/users/:id', (req: Request<{ id: string }>, res: Response) => {\n  const id = req.params.id; // Typed\n  const numId = parseInt(id, 10);\n  if (isNaN(numId)) {\n    return res.status(400).json({ error: 'Invalid ID' });\n  }\n});\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "not_typing_express_handlers"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction multiply(a: number, b: number, c: number) {\n  return a * b * c;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Curried Function**\n\n**Fix:**\n```typescript\nfunction multiply(a: number) {\n  return (b: number) => {\n    return (c: number): number => a * b * c;\n  };\n}\n// Or use auto-curried libraries\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_curried_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nimport { Observable } from 'rxjs';\nObservable.prototype.myMethod = function() {};\n// Extension not typed\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Module Augmentation**\n\n**Fix:**\n```typescript\nimport 'rxjs';\ndeclare module 'rxjs' {\n  interface Observable<T> {\n    myMethod(): void;\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_module_augmentation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Concat<A extends any[], B extends any[]> = [...A, ...B];\n// Type-level array concat\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Type Level Concat**\n\n**Fix:**\n```typescript\n// Type-level concatenation\ntype Concat<A extends any[], B extends any[]> = [...A, ...B];\ntype Result = Concat<[1, 2], [3, 4]>; // [1, 2, 3, 4]\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_type_level_concat"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst files = await glob('*.ts');\n// string[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Glob Typing**\n\n**Fix:**\n```typescript\nconst files: string[] = await glob('*.ts', {\n  absolute: true,\n  cwd: process.cwd(),\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_glob_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst port = process.env.PORT;\n// Type: string | undefined\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Process.env Typing**\n\n**Fix:**\n```typescript\ninterface Env {\n  PORT: string;\n  NODE_ENV: 'development' | 'production';\n  DATABASE_URL: string;\n}\nconst env = process.env as unknown as Env;\nconst port = parseInt(env.PORT, 10);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_process.env_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function getUser(id: number): Promise<User> {\n  const user = await db.find(id);\n  if (!user) throw new NotFoundError('User');\n  return user;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Using Result type instead of exceptions**\n\n**Fix:**\n```typescript\ntype Result<T, E = Error> =\n  | { ok: true; data: T }\n  | { ok: false; error: E };\n\nasync function getUser(id: number): Promise<Result<User>> {\n  const user = await db.find(id);\n  if (!user) return { ok: false, error: new NotFoundError('User') };\n  return { ok: true, data: user };\n}\n// Result type forces callers to handle both cases\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "using_result_type_instead_of_exceptions"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\napp.use((req, res, next) => {\n  console.log(req.method, req.url);\n  next();\n});\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Express Middleware Typing**\n\n**Fix:**\n```typescript\nimport { Request, Response, NextFunction } from 'express';\napp.use((req: Request, res: Response, next: NextFunction) => {\n  console.log(req.method, req.url);\n  next();\n});\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_express_middleware_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nres.setHeader('Content-Security-Policy', \"default-src 'self'\");\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing CSP Header Typing**\n\n**Fix:**\n```typescript\nconst CSP: string = \"default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';\";\nres.setHeader('Content-Security-Policy', CSP);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_csp_header_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction checkString(value: unknown): boolean {\n  return typeof value === 'string';\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Assertion Function**\n\n**Fix:**\n```typescript\nfunction assertString(value: unknown): asserts value is string {\n  if (typeof value !== 'string') {\n    throw new TypeError('Expected string');\n  }\n}\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_assertion_function"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst nums = strings.map(Number);\n// Type: (number | 0)[]\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Array.map Typing**\n\n**Fix:**\n```typescript\nconst nums: number[] = strings.map(s => parseInt(s, 10));\n// Explicit type\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_array.map_typing"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction greet(name) {\n  return `Hello, ${name}`;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Implicit any from missing annotation**\n\n**Fix:**\n```typescript\nfunction greet(name: string): string {\n  return `Hello, ${name}`;\n}\n// Enable noImplicitAny in tsconfig.json\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "implicit_any_from_missing_annotation"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst sum = nums.reduce((a, b) => a + b, 0);\nconst product = nums.reduce((a, b) => a * b, 1);\n// Ad-hoc\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Catamorphism**\n\n**Fix:**\n```typescript\ninterface Algebra<A> {\n  nil: A;\n  cons: (head: number, tail: A) => A;\n}\nfunction cata<A>(algebra: Algebra<A>): (nums: number[]) => A {\n  return (nums) => nums.reduceRight((acc, head) => algebra.cons(head, acc), algebra.nil);\n}\nconst sum = cata({ nil: 0, cons: (h, t) => h + t })(nums);\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_catamorphism"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\n// utils.ts\nexport function add(a: number, b: number): number { return a + b; }\nexport function sub(a: number, b: number): number { return a - b; }\n// Consumers import from deep path\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing export from index**\n\n**Fix:**\n```typescript\n// index.ts\nexport { add, sub } from './utils';\nexport { multiply, divide } from './math';\n\n// Consumer:\nimport { add, multiply } from './lib';\n// Barrel file for clean imports\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_export_from_index"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst arr: string[] = ['a', 'b'];\nconst val = arr[2]; // string, but actually undefined\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing noUncheckedIndexedAccess**\n\n**Fix:**\n```typescript\nconst arr: string[] = ['a', 'b'];\nconst val = arr[2]; // string | undefined\n// Enable noUncheckedIndexedAccess in tsconfig.json\n// Array access may return undefined\n```"
      }
    ],
    "source": "typescript_training",
    "tags": [
      "typescript",
      "missing_nouncheckedindexedaccess"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nfunction identity<T>(arg: T): T {\n  return arg;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Generic Constraint**\n\n**Fix:**\n```typescript\nfunction identity<T extends object>(arg: T): T {\n  return arg;\n}\n// Constrains to objects only\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_generic_constraint"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nconst data = await fetch(url).then(r => r.json());\n// No type safety\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Fetch Response Type**\n\n**Fix:**\n```typescript\ninterface ResponseData {\n  id: number;\n  name: string;\n}\nconst response = await fetch(url);\nif (!response.ok) throw new Error(`HTTP ${response.status}`);\nconst data: ResponseData = await response.json();\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_fetch_response_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ninterface Config {\n  [key: string]: any;\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Unconstrained Index Signature**\n\n**Fix:**\n```typescript\ninterface Config {\n  [key: string]: string | number;\n}\n// Constrains value types\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "unconstrained_index_signature"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\nasync function* stream(): AsyncIterable<any> {\n  yield await fetch('/api');\n}\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing AsyncIterator Element Type**\n\n**Fix:**\n```typescript\nasync function* stream(): AsyncIterableIterator<Response> {\n  yield await fetch('/api');\n}\n// Properly typed async generator\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_async_iterator_element_type"
    ]
  },
  {
    "messages": [
      {
        "role": "user",
        "content": "Review this TypeScript code:\n\n```typescript\ntype Result<T> = Promise<T> | Error;\n// Union of Promise and Error\n```"
      },
      {
        "role": "assistant",
        "content": "**Issue: Missing Result Type Pattern**\n\n**Fix:**\n```typescript\ntype Result<T, E = Error> =\n  | { ok: true; data: T }\n  | { ok: false; error: E };\n// Discriminated union for error handling\n```"
      }
    ],
    "source": "typescript_training_expansion",
    "tags": [
      "typescript",
      "missing_result_type_pattern"
    ]
  }
]