Flow: share type definitions among libs

Created on 5 May 2017  路  6Comments  路  Source: facebook/flow

It seems type definitions cannot share among different lib file. Is this a bug or any other extra configurations are needed?

./flow/dto/ProductDTO.js

// @flow
export type ProductDTO = {
  id: number,
  name: string,
  img: string,
}

export type TestState = {
  products: Array<ProductDTO>,
}

./flow/redux/ProductStates.js

// @flow
// I even tried to import type { ProductDTO } from '../dto/ProductDTO';
export type ProductState = {
  products: Array<ProductDTO>,
}

example.js

// @flow
const Test1: TestState = {
  products: ['xxx'], // flow error report here as expected
}

const Test2: ProductState = {
  products: ['xxx'], // no error, it seems flow does not recognize ProductState
}

.flowconfig

...
[libs]
flow
...

Most helpful comment

Since https://github.com/flow-typed/flow-typed/issues/16 has been closed, and as stated in the discussion, there isn't a lot that can be done by the flow-typed team to fix the issue. I propose moving the discussion here since it's an already open issue on the topic.

I think this is a serious issue that will only become a bigger the longer it is ignored. I almost chose not use flow at all, because of this issue.

Why has this gone so long without being addressed? How is anyone expected to use flow in a production environment while issues like this remain, for well over a year!

All 6 comments

I'd close this and discuss here: https://github.com/flowtype/flow-typed/issues/16

Since https://github.com/flow-typed/flow-typed/issues/16 has been closed, and as stated in the discussion, there isn't a lot that can be done by the flow-typed team to fix the issue. I propose moving the discussion here since it's an already open issue on the topic.

I think this is a serious issue that will only become a bigger the longer it is ignored. I almost chose not use flow at all, because of this issue.

Why has this gone so long without being addressed? How is anyone expected to use flow in a production environment while issues like this remain, for well over a year!

I think this is a problem of "flow" not "flow-typed". Why are we discussing this problem in "flow-typed" issues?

@kimjuny You're absolutely spot on, it's a "flow" issue, not a "flow-typed" issue. The problem is the
inability to import types from existing libraries into a module declaration for libdefs. Which is why I'd like to move the discussion here.

It seems to me like this shouldn't be that hard of an issue to fix, as importing from other libdefs works, why should it be so hard to allow importing from existing libraries, that already have type definitions, instead of forcing us to duplicate those types in a libdef.

Also this issue has been open for too long with no action, and the thread from flow-typed shows it's an issue many are coming across. I'd love to see someone from the flow team at least acknowledge this issue.

Why has this gone so long without being addressed? How is anyone expected to use flow in a production environment while issues like this remain, for well over a year!

Through my observations I have started to put Facebook OSS into two categories. The first category includes React, React DOM and Jest which are well maintained. Then there is the second category which includes Flow, React Native and Relay which sometimes feel like Facebook is saying "Here's a bunch of code, deal with it". So I don't think Flow maintainers really expect Flow to work in our production environments, but only on Facebook's.

I'm very very grateful for all of Facebook OSS, but it is also really sad that even a simple documentation PR can sit there without even a review for months. No one, literally no one, not even a single Flow maintainer said "Okay, let's crunch these PRs" in at least the last 9 months.

I can't call a project "open source" if I can't get a PR reviewed in 9 months.

This project has a serious maintenance issue.

May some maintainer reply to this issue?

Was this page helpful?
0 / 5 - 0 ratings