[Flow]在libs中共享类型定义

时间:2017-05-05 06:02:48

标签: reactjs react-native flowtype

似乎类型定义不能在不同的lib文件之间共享。这是一个bug还是需要任何其他额外配置?

./流量/ DTO / ProductDTO.js

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

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

./流动/终极版/ 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

...

[库]

...

0 个答案:

没有答案