Hallucinated API
.flatten(), .contains(), .substr() — methods AI invents
warningAI Quality
hallucinated-apiWhy this matters
AI tools confidently use methods that don't exist in the runtime you're targeting. .flatten() instead of .flat(), .contains() instead of .includes(), or methods from different languages entirely.
✗ Bad
const nested = [[1, 2], [3, 4]];
const flat = nested.flatten();
const hasAdmin = roles.contains("admin");
const prefix = name.substr(0, 3);✓ Good
const nested = [[1, 2], [3, 4]];
const flat = nested.flat();
const hasAdmin = roles.includes("admin");
const prefix = name.slice(0, 3);How to fix
Check MDN or TypeScript docs when a method call looks unfamiliar. Common AI hallucinations: .flatten()→.flat(), .contains()→.includes(), .substr()→.slice().