Avoid syntax collision with flow.js and TypeScript #14
Replies: 2 comments
-
personally I would not try to avoid syntax collisions, as I would leave it to the TypeScript team to figure out how to solve that problem. Typescript enums are quite hard to work with and I usually avoid them if I can, and rather use either a |
Beta Was this translation helpful? Give feedback.
-
If |
Beta Was this translation helpful? Give feedback.
-
Should we try to avoid syntax collision with
flow.js
andTypeScript
since this proposal will have different semantics than they provided?Avoid syntax collision
This limits our design space because we cannot design a syntax that is ambiguous when the parse supports both ECMAScript enum and TypeScript enum.
Here is an example of TypeScript enum:
Here is an example of Flow.js enum:
Avoid syntax collision creates an ecosystem split because of TypeScript/flow.js users, both TypeScript/flow.js enum and ECMAScript enum are available. Having two enums in TypeScript/flow.js will create confusion for their users.
TypeScript/flow.js enum is shorter than the ECMAScript enum, which might encourage developers to use the TypeScript/flow.js enum if it's possible.
A possible solution is enforcing developers to write the expected member type (#16). The solution given in that issue also resolve the syntax collision.
Not avoid syntax collision
flow.js
andTypeScript
must use a compiler flag--useECMAScriptEnum
like what TypeScript did to the class field--useDefineForClassField
.This also creates a split in the ecosystem. When a library ships
.d.ts
that includes an enum, it doesn't clear if the enum has semantics specified in this proposal, or it's a TypeScript enum.Beta Was this translation helpful? Give feedback.
All reactions