---
title: "Comment by Aditya Mitra on \"Functional TypeScript in Production Systems\" | Hashnode"
description: "Great Article! By the way, I had this question in my mind: Is using enum in switch ... case a good idea?"
url: "https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3/comment/609eac5247373d4cb0564060"
---

[Discussion](https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3)

Comment [Functional TypeScript in Production Systems](https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3)

[Aditya Mitra](https://hashnode.com/@aditya-mitra)

[May 14, 2021](https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3/comment/609eac5247373d4cb0564060)

Great Article!

_By the way, I had this question in my mind:_

Is using `enum` in **switch ... case** a good idea?

[Anthony Manning-Franklin](https://hashnode.com/@Antman261)

[May 15, 2021](https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3/comment/609eac5247373d4cb0564060#reply-609f368147373d4cb05648fe)

I avoid the `enum` type at all costs. They're poorly implemented in TypeScript, they have unexpected behaviour at runtime that can catch developers off guard, and they're overly complex. It's very easy to misuse them, and aligning a team on one way of using them is difficult.

Instead, it's easier to either use union types, i.e.

```
type MyUnion = 'FOO' | 'BAR' | 'FOOBAR';
```

or `as const` objects

```
const SOME_CONSTANTS = {
  FOO: 'SOME_VALUE',
  BAR: 'OTHER_VALUE',
} as const
```

[Aditya Mitra](https://hashnode.com/@aditya-mitra)

[May 15, 2021](https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3/comment/609eac5247373d4cb0564060#reply-609ff8d015f9347ff3d8e2b8)

[Anthony Manning-Franklin](https://hashnode.com/@Antman261)

Thanks a lot for explaining this to me!

[VH](https://hashnode.com/@Silverbullet069)

[Apr 25, 2024](https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3/comment/609eac5247373d4cb0564060#reply-662a7529a1efa063a72e4501)

This is also bugging my mind since using `enum` means you don't need to remember the exact literal string like "PENDING\_VERIFICATION". You just define

```
enum AccountStatus {
  PendingVerification = 'PENDING_VERIFICATION';
  Active = 'ACTIVE',
  Locked = 'LOCKED'
}
```

and use VSCode autocomplete feature. E.g. `AccountStatus.Pend-` => `AccountStatus.PendingVerification`

[Anthony Manning-Franklin](https://hashnode.com/@Antman261)

[Apr 27, 2024](https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3/comment/609eac5247373d4cb0564060#reply-662c6dcdca22fbbd84c9f0d4)

[VH](https://hashnode.com/@Silverbullet069) VSCode will still autocomplete a union of string literals for you, e.g.

```
type Foobar = 'FOO' | 'BAR';

const doFoobar = (prop: Foobar) => prop;
```

When you use `doFoobar` VSCode will suggest/autocomplete once you have typed `doFoobar(`

[VH](https://hashnode.com/@Silverbullet069)

[Apr 27, 2024](https://hashnode.com/posts/functional-typescript-in-production-systems/6097aa0521068818a5c621c3/comment/609eac5247373d4cb0564060#reply-662d111b7133b51519cfc34f)

[Anthony Manning-Franklin](https://hashnode.com/@Antman261) Yep it sure supported autocomplete, my bad @@ and I also found out about how `enum` wasn't that good in TypeScript so I have fully switched to Union Type now.

Ah yes thank you for these awesome blog plots. I have implemented some in my project. I also ask questions in some of your article's comment section. Can you please check them :")
