Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 18, 2024 03:45 am GMT

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 {    ...}

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

type Some = {    ...}

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 =.


Original Link: https://dev.to/oleygon/why-in-typescript-creating-an-enum-doesnt-need-a-but-creating-a-new-type-does-42fk

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To