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)