Default member type (number, string, or symbol?) #16
Replies: 2 comments 6 replies
-
Despite it being in conflict with TypeScript enums, I believe that there should either be no default. From TypeScript's perspective, that would be the easiest way to distinguish between a TypeScript If a default is preferred, in my opinion the next best option would for it to be an ADT enum. In that case, TypeScript would:
|
Beta Was this translation helpful? Give feedback.
-
I support enforcing the type to disambiguate the syntax. Enforcing developers to specify the default value type will have another problem. Because TypeScript and Flow.js can be used without types specified, it will encourage developers to use TS/flow enum if it is possible (because it is shorter). |
Beta Was this translation helpful? Give feedback.
-
What should be the default member type of an enum?
We may specify the type by a flow.js-like syntax:
But what should happen if no member type is specified?
Should it be number, string, symbol, or bigint?
If we enforce developers to specify a member type, we can ignore this problem and it also creates a different syntax to resolve the syntax collision with TypeScript and flow.js (#14)
Beta Was this translation helpful? Give feedback.
All reactions