---
title: "Comment by renkinjutsushi on \"In Defence of Typescript Enums\" | Hashnode"
description: "What if the UI would send 'Go' to the API but the instruction would need to be translated into the enum value? In this case it would be 2. Would we use a revers"
url: "https://hashnode.com/posts/in-defence-of-typescript-enums/67eae66767c03ec6e67a8760/comment/67f7a175703a4870e57dcaac"
---

[Discussion](https://hashnode.com/posts/in-defence-of-typescript-enums/67eae66767c03ec6e67a8760)

Comment [In Defence of Typescript Enums](https://hashnode.com/posts/in-defence-of-typescript-enums/67eae66767c03ec6e67a8760)

[renkinjutsushi](https://hashnode.com/@renkinjutsushi)

[Apr 10, 2025](https://hashnode.com/posts/in-defence-of-typescript-enums/67eae66767c03ec6e67a8760/comment/67f7a175703a4870e57dcaac)

What if the UI would send 'Go' to the API but the instruction would need to be translated into the enum value? In this case it would be 2.

Would we use a reverse map for the instructions?

i.e.

"const fromInstructions = new Map(\[ \["Stop", TrafficLight.Red\], \["Slow down", TrafficLight.Yellow\], \["Go", TrafficLight.Green\], \]);"

Or do you reckon it would be ok keeping them in the same instructions map?

[Yazan Alaboudi](https://hashnode.com/@alaboudi)

[Apr 10, 2025](https://hashnode.com/posts/in-defence-of-typescript-enums/67eae66767c03ec6e67a8760/comment/67f7a175703a4870e57dcaac#reply-67f7c08522540a9bd8a5c418)

I typically create a map when translating my enum to an API value. And another map when translating from API value to an enum. Each map would basically have a single responsibility.

This all makes sense as serialization and de-serialization are different responsibilities. So you'd have a map for each.
