Blueprint: Flow types?

Created on 14 Apr 2017  路  4Comments  路  Source: palantir/blueprint

Hey there,

First off, awesome tool! Thank you so much for the hard work you've put into. We're loving developing with it.

I was just wondering if it would be possible to generate flow types alongside the typescript definition files. I'm not sure if this is standard practice yet, but it appears that there are tools like https://github.com/joarwilk/flowgen that could make it easier to do this.

Thanks again!
Thomas

core question

Most helpful comment

What's wrong with import * as React from "react"? Worked fine for us since day one. And have you tried tslint or its vscode extension?

I haven't used Flow myself, but I think TypeScript has done everything right from a language perspective (and it's only getting better). Most notably, types are literally part of the source code, not post-fact annotations, so you can't escape thinking about types. If you're using VS Code, there's no excuse to not use TypeScript (it was built for that)!

We rarely use Babel here because tsc handles everything we want (JSX, decorators, polyfills for assign, etc.)--another winning feature in my mind: one less mammoth tool to worry about. Just throw that compiled output into webpack and you've got a browser-ready bundle (or use ts-loader).

Incremental conversion from JS to TS has improved dramatically in recent releases. You can set allowJs in tsconfig to support importing .js files (they'll all be typed as any but at least it works). It will also infer any for node modules that lack typings. So you can convert modules as you're ready and interoperate with untyped code.

I say give it another shot!

All 4 comments

Thanks @tnrich, glad you're enjoying Blueprint!

Unfortunately I don't see us adding support for Flow any time soon because the burden of maintaining support for a tool we don't use is simply too great for our small team. TypeScript just works so damn well and the ecosystem (@types etc) is so much more mature than Flow's.

Converting the typings yourself seems pretty straightforward with a tool like that, if you _must_ use flow. But why not just use TypeScript for your static analysis?

@giladgray Thanks for getting back to me so quickly!

To answer your question, we actually did try to use TypeScript for static analysis but had some issues with it.

Small things, like "import React from 'react'" (https://github.com/DefinitelyTyped/DefinitelyTyped/issues/5128) and and the vscode tslinter were not working for us.

Then there's also the fact that flow is being developed by facebook (and thus most likely will integrate with it better).

Finally, we are worried that by switching to typescript we'll need to manually go through many of our existing react components and make numerous small changes to them once we compile them using the ts compiler instead of babel. Also, being new to typescript, there are probably other issues we don't even know about now that might arise related to things like code-splitting, code-optimization, server-rendering, etc.

Maybe those aren't real issues but it was enough to make us want to stick with flow for right now. It felt like with flow there was less buy-in necessary.

Thanks!

What's wrong with import * as React from "react"? Worked fine for us since day one. And have you tried tslint or its vscode extension?

I haven't used Flow myself, but I think TypeScript has done everything right from a language perspective (and it's only getting better). Most notably, types are literally part of the source code, not post-fact annotations, so you can't escape thinking about types. If you're using VS Code, there's no excuse to not use TypeScript (it was built for that)!

We rarely use Babel here because tsc handles everything we want (JSX, decorators, polyfills for assign, etc.)--another winning feature in my mind: one less mammoth tool to worry about. Just throw that compiled output into webpack and you've got a browser-ready bundle (or use ts-loader).

Incremental conversion from JS to TS has improved dramatically in recent releases. You can set allowJs in tsconfig to support importing .js files (they'll all be typed as any but at least it works). It will also infer any for node modules that lack typings. So you can convert modules as you're ready and interoperate with untyped code.

I say give it another shot!

closing as we will not support flow types OOTB.

Was this page helpful?
0 / 5 - 0 ratings