# Type Inference — TypeScript

Source: https://www.geekswithgeeks.com/en/typescript/ts-type-inference

> TypeScript figures out most types on its own.

## TS infers for you

No annotation needed — the initial value tells TS the type, and it's remembered from then on.

```typescript
let count = 5;          // inferred as number
count = "five";
// Error: Type 'string' is not assignable to type 'number'.
```

## When to still annotate

Let inference handle local variables. Annotate function parameters, return types on public APIs, and empty arrays/objects — inference has nothing to go on there.
