<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/typescript---readonly-notemptyarray-d6v5vysb2" -->

---
title: Typescript - (ReadOnly)NotEmptyArray | daily.dev
description: TypeScript doesn't have a built-in non-empty array type, but you can define one using a tuple type: `type NotEmptyArray<T> = [T, ...T[]]`. This enforces at...
canonical: https://daily.dev/posts/typescript---readonly-notemptyarray-d6v5vysb2
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Typescript - (ReadOnly)NotEmptyArray | daily.dev
og:description: TypeScript doesn't have a built-in non-empty array type, but you can define one using a tuple type: `type NotEmptyArray<T> = [T, ...T[]]`. This enforces at...
og:url: https://daily.dev/posts/typescript---readonly-notemptyarray-d6v5vysb2
og:image: https://api.daily.dev/og/posts/d6V5Vysb2.png
og:image:alt: Typescript - (ReadOnly)NotEmptyArray
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Typescript - (ReadOnly)NotEmptyArray

**[Playful Programming](https://daily.dev/sources/playfulprogramming)** · [@puppo](https://daily.dev/puppo) · 2 min read · 0 upvotes · 0 comments

## Summary

TypeScript doesn't have a built-in non-empty array type, but you can define one using a tuple type: `type NotEmptyArray<T> = [T, ...T[]]`. This enforces at least one element at compile time. To prevent mutation-related issues (e.g., methods that could empty the array), a `ReadOnlyNotEmptyArray<T>` wraps it with `Readonly<>`. A type guard function `isNotEmptyArray` can narrow a regular array to this type at runtime by checking its length.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://playfulprogramming.com/posts/typescript-readonlynotemptyarray-2id7>

## Similar posts on daily.dev

- [Bring Immutability and Context to Arrays](https://daily.dev/posts/bring-immutability-and-context-to-arrays-mipldambi) · TypeScript.TV · 13 upvotes · 0 comments
- [Beyond the basics: 21 TypeScript features you might not know about](https://daily.dev/posts/beyond-the-basics-21-typescript-features-you-might-not-know-about-oivxxtrie) · DEV · 27 upvotes · 0 comments
- [Experiment: making TypeScript immutable-by-default](https://daily.dev/posts/experiment-making-typescript-immutable-by-default-wsz7yxyng) · Hacker News · 0 upvotes · 0 comments
- [Unlock the Power of TypeScript’s infer Keyword](https://daily.dev/posts/unlock-the-power-of-typescript-s-infer-keyword-0vrqqnsgq) · This is Learning · 32 upvotes · 2 comments
- [Distributive Conditional Types in TypeScript](https://daily.dev/posts/distributive-conditional-types-in-typescript-6tu0eqy5m) · RUBYLAND · 0 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#typescript](https://daily.dev/tags/typescript)

[View this post on daily.dev](https://daily.dev/posts/typescript---readonly-notemptyarray-d6v5vysb2)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Typescript - (ReadOnly)NotEmptyArray","url":"https://daily.dev/posts/typescript---readonly-notemptyarray-d6v5vysb2","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/typescript---readonly-notemptyarray-d6v5vysb2"},"datePublished":"2026-03-16T21:47:45.545Z","dateModified":"2026-03-17T18:00:46.624Z","description":"TypeScript doesn't have a built-in non-empty array type, but you can define one using a tuple type: `type NotEmptyArray<T> = [T, ...T[]]`. This enforces at...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/acef42a3f4a232cf69bbecbbe550de87?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/acef42a3f4a232cf69bbecbbe550de87?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Playful Programming","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Luca Del Puppo","url":"https://daily.dev/puppo","image":"https://avatars.githubusercontent.com/u/2527849?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":980}},"commentCount":0,"discussionUrl":"https://daily.dev/posts/typescript---readonly-notemptyarray-d6v5vysb2","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,typescript","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Playful Programming","item":"https://daily.dev/sources/playfulprogramming"},{"@type":"ListItem","position":3,"name":"Typescript - (ReadOnly)NotEmptyArray"}]}
```

