DEV Community

Chuks Festus
Chuks Festus

Posted on

static type JavaScript

Has anyone used both flow and typescript? After trying graphql I'm sold on this whole type system and don't know which to go for. Typescript has a lot of hype though but is it really just hype or is it as great as people make it seem.

PS: I don't use vscode so saying one has a great support for it doesn't do it for me, I'm a sublime person

Top comments (13)

Collapse
 
devkevyn profile image
devkevyn • Edited

Edit: I was wrong. I mistook flow for proptypes (2am replying lol). Anyway, guy replying to this sums it up right. But, personally I stick to typescript simply because its more widely supported (easier to ask solutions for) and Microsoft does a good job updating it (great documentation too). And frankly, a bit of a C# fan here.

After using both on a react project before, I lean more towards typescript. It reads much better as a programming language compared to flow's hybrid approach with keywords and comments. Also flow's static type checking is runtime compared to typescript's compile time which is much better at detecting problems earlier. Lastly, flow's limited to react so if you use other js based libraries you'll still switch to typescript for ur static typing needs

Collapse
 
cheshireswift profile image
☕ツ

Unless I'm very mistaken, this is not correct regarding Flow.

Flow types are stripped out at runtime; it is checked using an ongoing language server (which in practice is how Typescript is generally checked), and it isn't React specific any more than Typescript is Angular specific. In both cases they're just ways for specifying types on top of Javascript, and all support for libraries just comes from type definitions someone else has written up.

The main difference between the two is that Typescript is more popular so has a much better pool of prewritten typedefs for external libraries.

(p.s. Thinking about the specifics of what you've said, are you thinking of prop-types? Because Flow is a separate thing, much closer to TS than it is to prop-types.)

Collapse
 
devkevyn profile image
devkevyn • Edited

My mistake. I was thinking of prop types! You're right about all of those. I mistakingly interchanged them (was replying to this at 2 am). Thanks for correcting me.

Thread Thread
 
cheshireswift profile image
☕ツ

No worries, we've all been there 😁

Collapse
 
chuksfestus profile image
Chuks Festus

Hmm thanks alot this helped

Collapse
 
yawaramin profile image
Yawar Amin

I would recommend editing this comment to retract it, because people inevitably will not read replies :-)

Collapse
 
devkevyn profile image
devkevyn

Done

Collapse
 
vonheikemen profile image
Heiker

Haven't use either but i think typescript has a much bigger community, which in turn means is easier to find libraries that are build with typescript or have better support for it via type files.

If you install a typescript language server you can use it in sublime with this plugin.

Collapse
 
chuksfestus profile image
Chuks Festus

Yea that was what I noticed first but then I also heard flow has great react support

Collapse
 
vonheikemen profile image
Heiker

create-react-app added support for typescript, it is my undestanding that the team behind create-react-app doesn't add features based on hype. At the very least typescript's integration with react should be as good as flow.

Thread Thread
 
chuksfestus profile image
Chuks Festus

Oh great

Thread Thread
 
cheshireswift profile image
☕ツ

Having used both on a few React projects, Typescript + React is absolutely fine.

Collapse
 
yawaramin profile image
Yawar Amin

Either is good, TypeScript is more widely supported as people pointed out. Just curious to know if you looked at ReasonML? It has pretty great support for React thanks to the ReasonReact library binding, plus compile-time GraphQL support so that for example if you try to access a property missing from your query you get a compile error instead of runtime. Check out dev.to/iwilsonq/reasonml-with-grap...