DEV Community

Snookums
Snookums

Posted on

Why in Typescript creating an enum doesn't need a =, but creating a new type does?

To create a new enum, the syntax is

enum Some {
    ...
}
Enter fullscreen mode Exit fullscreen mode

But to create a new type, the syntax requires a =:

type Some = {
    ...
}
Enter fullscreen mode Exit fullscreen mode

I wonder why this = is needed?

I think it confuses type and value, and other languages are not like this.

For example, in C++, creating a struct doesn't need a =.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay