> For the complete documentation index, see [llms.txt](https://notes.eliasnorrby.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.eliasnorrby.com/typescript/inferring-an-array-type.md).

# Inferring the type of elements in an array

```typescript
type Unarray<T> = T extends Array<infer U> ? U : T
```
