flow icon indicating copy to clipboard operation
flow copied to clipboard

Please consider using a different file extension.

Open Gozala opened this issue 8 years ago • 5 comments

Disclaimer

Recently I have decided to give a typescript a try for a smaller scale project to see how it compares to flow. My hope is to provide some constructive feedback in regards to where typescript falls behind the typescript.


In my experience typescript's did a better choice going with .ts and .d.ts file extensions over overloading .js file with added @flow pragma. I can see no advantages of using .js file extension but several disadvantages:

  • Tooling support. I run into different issues with different tools (mostly editors) as typically file extension are they way the detect the source language, but that is not the case with flow.
  • package entry point. This maybe solved differently, but having a different file extension makes it not issue. In ts if you choose to output result along the side with a source dependent code that imports modules will end up importing typed modules instead of compiled versions. In flow you either work your way around it or flow ends up analyzing untyped compiled output of the dependency.
  • misleading. You'd be surprised how often I have to answer why does these .js files look weird, and after explaining a followup question of why flow does not uses a separate file extension.
  • forget pragma If you forgot pragma or have a typo behavior becomes surprising.

Gozala avatar Jun 23 '17 20:06 Gozala

In a thread of yours from a while back @jeffmo left a pretty detailed comment: https://github.com/facebook/flow/issues/1996#issuecomment-230919868. Doesn't the .js.flow extension meet your needs?

popham avatar Jun 26 '17 19:06 popham

It can be used to workaround some i of the problems stated, but .js.flow is far from mainstream and overall story in comparison to .ts is far more confusing and clear

Gozala avatar Jun 27 '17 05:06 Gozala

@Gozala Does this option fit your needs? https://flow.org/en/docs/config/options/#toc-module-file-ext-string

TrySound avatar Jun 27 '17 12:06 TrySound

I would like to concur this issue. I recently had a friend asking whether a file was JS or TS (he knew only these two). It was very confusing for him that the JS file extension was overloaded for a different syntax. It would be great to help new developers by making the flow typedness explicit by removing support for .js files and enforce naming files ending in .js.flow.

TimvdLippe avatar Jul 11 '18 18:07 TimvdLippe

I agree that defaulting to .js, .jsx, .mjs, and .cjs is not great because it introduces a variety of issues that clash with JavaScript tools and workflows. (And namely Flow is not JavaScript.)

Maybe .flow would work instead of .js.flow?

Clashing with JavaScript file naming isn't helping with searchability either. So on a slightly related note, it might even be useful to rename (or longname, and keep "Flow" the shortname) the project to FlowScript because when searching for "flow anything" on Google the results are not very useful, often leading to pages unrelated to Flow (including lots of TypeScript pages). ~~This also would allow the possibility of .fs extensions~~ nevermind that's already F#.

trusktr avatar Dec 13 '24 03:12 trusktr