<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/array-includes-checks-the-value--6ibmom2fj" -->

---
title: Array.includes() checks the value. | daily.dev
description: Using 'Array.includes()' to check a value at runtime may not narrow its TypeScript type inside the 'if' block. TypeScript may still treat the value as a plain...
canonical: https://daily.dev/posts/array-includes-checks-the-value--6ibmom2fj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Array.includes() checks the value. | daily.dev
og:description: Using 'Array.includes()' to check a value at runtime may not narrow its TypeScript type inside the 'if' block. TypeScript may still treat the value as a plain...
og:url: https://daily.dev/posts/array-includes-checks-the-value--6ibmom2fj
og:image: https://api.daily.dev/og/posts/6ibmoM2Fj.png
og:image:alt: Array.includes() checks the value.
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.

# Array.includes() checks the value.

**[nyaomaru](https://daily.dev/sources/graxwfjk0eop4zs3tdzdr)** · [@nyaomaru](https://daily.dev/nyaomaru) · 1 min read · 0 upvotes · 0 comments

## Summary

Using 'Array.includes()' to check a value at runtime may not narrow its TypeScript type inside the 'if' block. TypeScript may still treat the value as a plain 'string' even after the check passes. A type guard can do both jobs: checking the value at runtime and narrowing its type. The 'oneOfValues()' function in the is-kit library provides this type guard.

## Content

A small TypeScript trap. 👀

`Array.includes()` can tell you whether a value exists in an array at runtime.

But even inside the `if`, TypeScript may still see the value as just `string`. 🙀

A type guard can do both:

✅ check the value at runtime

✅ narrow the type

That’s what `oneOfValues()` in is-kit does. 😸

https://github.com/necoz-oss/is-kit

#TypeScript #JavaScript #OpenSource

## Similar posts on daily.dev

- [How to Defend Your JavaScript App Against Unsafe Data with TypeScript Guard Utilities](https://daily.dev/posts/how-to-defend-your-javascript-app-against-unsafe-data-with-typescript-guard-utilities-cuooqjnij) · freeCodeCamp · 5 upvotes · 1 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/array-includes-checks-the-value--6ibmom2fj)

```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":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/array-includes-checks-the-value--6ibmom2fj","headline":"Array.includes() checks the value.","text":"Using 'Array.includes()' to check a value at runtime may not narrow its TypeScript type inside the 'if' block. TypeScript may still treat the value as a plain 'string' even after the check passes. A type guard can do both jobs: checking the value at runtime and narrowing its type. The 'oneOfValues()' function in the is-kit library provides this type guard.","url":"https://daily.dev/posts/array-includes-checks-the-value--6ibmom2fj","datePublished":"2026-11-16T17:42:01.968Z","dateModified":"2026-11-16T17:46:08.226Z","author":{"@type":"Person","name":"nyaomaru","url":"https://daily.dev/nyaomaru","image":"https://avatars.githubusercontent.com/u/90489696?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":450}},"image":"https://media.daily.dev/image/upload/s--PMcUEmS5--/f_auto,pg_1/v1794850922/posts/6ibmoM2Fj?_a=BAMAMiiw0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/graxwfjk0eop4zs3tdzdr","name":"nyaomaru"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"nyaomaru","item":"https://daily.dev/sources/graxwfjk0eop4zs3tdzdr"},{"@type":"ListItem","position":3,"name":"Array.includes() checks the value."}]}
```

