---
title: "Never type anything as mixed or any · Agent Wranglers"
url: https://agentwranglers.se/playbook/architecture/data-shapes/no-mixed-or-any
updated: 2026-10-20
licence: "All rights reserved"
---

# Never type anything as mixed or any

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Data shapes](https://agentwranglers.se/playbook/architecture/data-shapes)
- Rule: No `mixed`, `any` or untyped value in signatures, properties or docblocks. Each one turns off the type checker for everything it touches.
- How: Replace it with the type, a union of the types, or `unknown` that must be narrowed before use. When data comes from outside, parse it into a type first.
- Check: The build fails on it. Examples are TypeScript `noImplicitAny` with `@typescript-eslint/no-explicit-any`, PHPStan level 10, which checks explicit and implicit `mixed`, and mypy `--disallow-any-explicit`.

Example:

```ts
// Bad: any spreads, and nothing is checked
function total(order: any): any { return order.lines.reduce((sum: any, l: any) => sum + l.price, 0); }

// Good: named types end to end
type OrderLine = { readonly price: number; readonly quantity: number };
function total(lines: readonly OrderLine[]): number { return lines.reduce((sum, line) => sum + line.price * line.quantity, 0); }
```

```python
# Bad
def total(order: Any) -> Any: ...

# Good
@dataclass(frozen=True)
class OrderLine:
    price: int
    quantity: int

def total(lines: list[OrderLine]) -> int:
    return sum(line.price * line.quantity for line in lines)
```

```php
// Bad: mixed turns off the checks
function total(mixed $order): mixed { /* ... */ }

// Good: a list of typed lines
/** @param list<OrderLine> $lines */
function total(array $lines): int { return array_sum(array_map(fn (OrderLine $line) => $line->price * $line->quantity, $lines)); }
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/data-shapes/no-mixed-or-any`.

- Previous: [Wrap domain values in their own types](https://agentwranglers.se/playbook/architecture/data-shapes/value-objects)
- Next: [Convert to arrays and JSON only at the edge](https://agentwranglers.se/playbook/architecture/data-shapes/convert-at-the-edge)
- [Data shapes](https://agentwranglers.se/playbook/architecture/data-shapes)
