<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/stop-using-enum-in-typescript-try-as-const--z9mxie9i5" -->

---
title: Stop using "enum" in TypeScript. Try "as const" | daily.dev
description: TypeScript enums compile into extra JS objects and numeric enums allow assigning arbitrary numbers, undermining type safety. Using `as const` instead provides...
canonical: https://daily.dev/posts/stop-using-enum-in-typescript-try-as-const--z9mxie9i5
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Stop using "enum" in TypeScript. Try "as const" | daily.dev
og:description: TypeScript enums compile into extra JS objects and numeric enums allow assigning arbitrary numbers, undermining type safety. Using `as const` instead provides...
og:url: https://daily.dev/posts/stop-using-enum-in-typescript-try-as-const--z9mxie9i5
og:image: https://api.daily.dev/og/posts/Z9mxiE9I5.png
og:image:alt: Stop using "enum" in TypeScript. Try "as const"
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.

# Stop using "enum" in TypeScript. Try "as const"

**[Sandhya K](https://daily.dev/sources/f8a71aothmgqz4gvfzpti)** · [@sandhyak](https://daily.dev/sandhyak) · 1 min read · 216 upvotes · 30 comments

## Summary

TypeScript enums compile into extra JS objects and numeric enums allow assigning arbitrary numbers, undermining type safety. Using `as const` instead provides the same autocomplete and type checking with zero runtime overhead, works with plain string literals, and avoids extra imports, resulting in smaller bundles.

## Content

![image.png](https://media.daily.dev/image/upload/s--yFtwEYq0--/f_auto/v1790574163/ugc/content_a1915bdc-3034-4cc0-9f02-b42b791ab106?_a=BAMAMicg0)

Enums compile into extra JS objects, and numeric ones let you assign any number. `as const` gives you the same autocomplete and type safety with zero runtime overhead, and it works with plain strings, so you can pass `'active'` without importing anything. Your bundle and your teammates will thank you.

## Community discussion

Top comments from developers on daily.dev.

**@luukoosterhuis** · 45 upvotes

> Besides the fact that they eventually generate the same thing is there a difference in the code: While enum generates a list of const string values, const can contain other types like objects. And that's typical freedom for javascript, but enum gives you more strictness and direction of what it is supposed to do.
>
>
> Call it syntatic sugar, but otherwise it's the same as saying you should not use class, because javascript just interprets it as functions...

**@suarezluis** · 20 upvotes

> The part I dislike most is this:
>
> ```
> type Status = typeof STATUS[keyof typeof STATUS];
> ```
>
> It’s noisy, harder to scan, and now you have both `Status` and `STATUS`, which is visually awkward.
>
> For most app code, I’d still use:
>
> ```
> enum Status {
>   Active = 'active',
>   Inactive = 'inactive',
> }
> ```
>
> The extra emitted JS is tiny and almost never worth optimizing away unless you're building a library where bundle output matters a lot.
>
> If you specifically want **zero enum runtime machinery**, I think this is cleaner:
>
> ```
> const Status = {
>   Active: 'active',
>   Inactive: 'inactive',
> } as...

**@ristotoldsep** · 3 upvotes

> For a few string values, `as const` feels like the less dramatic choice.

**@deepjoshi\_dev** · 2 upvotes

> I kind of have a mixed up feeling about it because I usually use enums a lot.

**@deondazy** · 2 upvotes

> These “Stop using X language feature and use Y instead” posts irks me so bad 🤦🏻‍♂️

## Similar posts on daily.dev

- [Why TypeScript Enums Are Dead](https://daily.dev/posts/why-typescript-enums-are-dead-gev3gojxj) · TypeScript.TV · 62 upvotes · 0 comments
- [TypeScript 5.8 Production Migration: Adopting Erasable Syntax for Node.js 23\+](https://daily.dev/posts/typescript-5-8-production-migration-adopting-erasable-syntax-for-node-js-23--yvv1s2bui) · SitePoint · 0 upvotes · 0 comments
- [TypeScript levels up with type stripping](https://daily.dev/posts/typescript-levels-up-with-type-stripping-gb9bktba8) · InfoWorld · 1 upvotes · 0 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/stop-using-enum-in-typescript-try-as-const--z9mxie9i5)

```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/stop-using-enum-in-typescript-try-as-const--z9mxie9i5","headline":"Stop using \"enum\" in TypeScript. Try \"as const\"","text":"TypeScript enums compile into extra JS objects and numeric enums allow assigning arbitrary numbers, undermining type safety. Using `as const` instead provides the same autocomplete and type checking with zero runtime overhead, works with plain string literals, and avoids extra imports, resulting in smaller bundles.","url":"https://daily.dev/posts/stop-using-enum-in-typescript-try-as-const--z9mxie9i5","datePublished":"2026-09-28T05:43:00.625Z","dateModified":"2026-09-29T02:07:26.375Z","author":{"@type":"Person","name":"Sandhya K","url":"https://daily.dev/sandhyak","image":"https://media.daily.dev/image/upload/s--SE6L2St6--/f_auto/v1788238316/avatars/avatar_F8a71aOthmGqz4gVFZpTi?_a=BAMAMicg0","description":"Full-stack AI Engineer","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":2330}},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":216},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":30}],"comment":[{"@type":"Comment","text":"Besides the fact that they eventually generate the same thing is there a difference in the code: While enum generates a list of const string values, const can contain other types like objects. And that’s typical freedom for javascript, but enum gives you more strictness and direction of what it is supposed to do.\nCall it syntatic sugar, but otherwise it’s the same as saying you should not use class, because javascript just interprets it as functions…","datePublished":"2026-09-28T07:31:46.348Z","url":"https://daily.dev/posts/Z9mxiE9I5#c-O9rXHK6ib","author":{"@type":"Person","name":"Luuk Oosterhuis","url":"https://daily.dev/luukoosterhuis","image":"https://avatars.githubusercontent.com/u/304927767?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":45}},{"@type":"Comment","text":"The part I dislike most is this:\ntype Status = typeof STATUS[keyof typeof STATUS];\n\nIt’s noisy, harder to scan, and now you have both Status and STATUS, which is visually awkward.\nFor most app code, I’d still use:\nenum Status {\n  Active = \u0026#x27;active\u0026#x27;,\n  Inactive = \u0026#x27;inactive\u0026#x27;,\n}\n\nThe extra emitted JS is tiny and almost never worth optimizing away unless you’re building a library where bundle output matters a lot.\nIf you specifically want zero enum runtime machinery, I think this is cleaner:\nconst Status = {\n  Active: \u0026#x27;active\u0026#x27;,\n  Inactive: \u0026#x27;inactive\u0026#x27;,\n} as const;\n\ntype Status = (typeof Status)[keyof typeof Status];\n\nThen usage still feels enum-like:\nconst status: Status = Status.Active;\n\nThat gives you plain JS values, type safety, autocomplete, and Status.Active instead of sprinkling 'active' strings everywhere.\nAlso, the screenshot’s claim that plain strings are a benefit:\nconst s: Status = \u0026#x27;active\u0026#x27;;\n\nis actually something I often don’t want. Status.Active is more explicit and makes refactoring/searching easier.","datePublished":"2026-09-28T16:32:50.148Z","url":"https://daily.dev/posts/Z9mxiE9I5#c-E2D8RUvGy","author":{"@type":"Person","name":"Luis Suarez","url":"https://daily.dev/suarezluis","image":"https://lh3.googleusercontent.com/a/ACg8ocIkZ4jJX1QlSsOVmnRyYLceA95xo22EEwJ-N6aSU-YMXCrEv2mc=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":20}},{"@type":"Comment","text":"For a few string values, as const feels like the less dramatic choice.","datePublished":"2026-09-28T09:41:39.412Z","url":"https://daily.dev/posts/Z9mxiE9I5#c-2i2FKuuNm","author":{"@type":"Person","name":"Risto Tõldsep","url":"https://daily.dev/ristotoldsep","image":"https://lh3.googleusercontent.com/a/ACg8ocLDWc6mZn0JwNmXXw6WY0L_HJ6pegzRttooC5VgtXESHSj3MNYx=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"I kind of have a mixed up feeling about it because I usually use enums a lot.","datePublished":"2026-09-28T13:33:11.475Z","url":"https://daily.dev/posts/Z9mxiE9I5#c-lga8sAMCf","author":{"@type":"Person","name":"Deep Joshi","url":"https://daily.dev/deepjoshi_dev","image":"https://media.daily.dev/image/upload/s--TdY8j8Aa--/f_auto/v1776506972/avatars/avatar_aSUkzUQS97QJpQRxKMe49?_a=BAMAMiWQ0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"These “Stop using X language feature and use Y instead” posts irks me so bad 🤦🏻‍♂️","datePublished":"2026-09-29T19:03:14.754Z","url":"https://daily.dev/posts/Z9mxiE9I5#c-sMhxAIjIN","author":{"@type":"Person","name":"Deon","url":"https://daily.dev/deondazy","image":"https://media.daily.dev/image/upload/f_auto/v1636547078/avatars/HI5WU320eZ0AAfMlgSIeb"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/f8a71aothmgqz4gvfzpti","name":"Sandhya K"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Sandhya K","item":"https://daily.dev/sources/f8a71aothmgqz4gvfzpti"},{"@type":"ListItem","position":3,"name":"Stop using \"enum\" in TypeScript. Try \"as const\""}]}
```

