TypeScript is ~another~ the other static type checker for JavaScript. ATM, TS is a lot more popular than Flow and I believe an important reason why is TS being a lot more approachable than Flow. Flow is very strict and it can be a hassle to keep all the types in working condition (especially for developers without any prior experience with static type systems), causing a lot of : anys and $FlowFixMes being used.
I believe that Flow could achieve the same ease of use of TypeScript with a few additions.
I'd like to propose adding some [option]s to .flowconfig:
typescript_mode (boolean)
Turns on all the options below.
loose_null_checks (boolean)
Allows null and undefined to be assignable to all types.
loose_std_lib (boolean)
Changes select types in standard library definitions that are hard to understand/use with any. (Actual types to change TBD.)
c_sharp_cast_operator (boolean)
Enables C#-like cast operator, but with <> instead of (), just like in TS. Enabling this causes a syntax ambiguity. (<int>myVar vs <div>text</div>). This is solved by disallowing usage of JSX in .js files and only allowing it in .jsx files. The same functionality will be achieved with the as operator (myVar as any) in .jsx files.
c_sharp_namespaces (boolean)
Enables C#-like namespaces. (Refer to TS docs for explanation: https://www.typescriptlang.org/docs/handbook/namespaces.html)
These will be used attract developers who are willing to sacrifice soundness for ease of use and also attract developers who come from C# and want to see familiar syntax and features.
I assume adding/enabling these won't make sense to some developers since sacrificing soundness might seem like defeating the purpose of using a type checker, and adding features from other languages without going through TC39's process risks conflict with future proposals, but TypeScript has proved there is a market for this and it might be a good idea to not keep Flow from enjoying similar popularity.
Flow's focus on strictness is one of the main differentiators between it and TypeScript. Many people prefer looser checking, and that's okay, but my recommendation would be for them to use TypeScript. I don't think it's worth the Flow team spending time on a mode that mimics TypeScript when there is already great software available for that: TypeScript itself.
Most helpful comment
Flow's focus on strictness is one of the main differentiators between it and TypeScript. Many people prefer looser checking, and that's okay, but my recommendation would be for them to use TypeScript. I don't think it's worth the Flow team spending time on a mode that mimics TypeScript when there is already great software available for that: TypeScript itself.