2017-03-29 11 views
1

をバインドされている私は、次のコンポーネントがあります。フロータイプのインポートタイプ - 名前がすでに

// @flow 

export type id = string; 
export type image = string; 
export type header = string; 
export type text = Array<string>; 
export type brewTime = Array<any>; 

export type TEA_DATA = { 
    id: id, 
    image: image, 
    header: header, 
    text: text, 
    brewTime: brewTime 
}; 

// @flow 

import React from 'react'; 

import TEA_DATA from './Tea.data'; 
import TeaInfo from './TeaInfo.component'; 

const Tea =() => <TeaInfo teaData={TEA_DATA}/>; 

export default Tea; 

をそれから私は、次のTea.data.types.jsファイルを持っていますこれは、インポートするための正しい方法であるflow docsによると

// @flow 

import black from '../images/blacktea.png'; 
import white from '../images/whitetea.png'; 
import oolong from '../images/oolongtea.png'; 
import green from '../images/greentea.png'; 

import type TEA_DATA from './Tea.data.types'; 

const TEA_DATA = [{ 
    id: 'wtid', 
    image: white, 
    header: 'White tea', 
    text: [ 
    "Currently there is no generally accepted definition of white tea and very little international agreement - some sources use the term to refer to tea that is merely dried with no additional processing, some to tea made from the buds and immature tea leaves picked shortly before the buds have fully opened and allowed to wither and dry in natural sun,[citation needed] while others include tea buds and very young leaves which have been steamed or fired before drying. Most definitions agree, however, that white tea is not rolled or oxidized, resulting in a flavour characterized as \"lighter\" than green or traditional black teas.", 
    "In spite of its name, brewed white tea is pale yellow. Its name derives from the fine silvery-white hairs on the unopened buds of the tea plant, which give the plant a whitish appearance. It is harvested primarily in China, mostly in the Fujian province, but more recently produced in Eastern Nepal, Taiwan, Northern Thailand, Galle (Southern Sri Lanka) and India." 
    ], 
    brewTime: { 
    mild: 1, 
    strong: 3 
    } 
}...]; 

export default TEA_DATA; 

:そして、私は、次のtea.data.jsファイルを持っていますデータ型が表示されますが、次のエラーが表示されます。

src/Tea/Tea.data.js:10 10: const TEA_DATA = [{ ^^^^^^^^ TEA_DATA. name is already bound 8: import type TEA_DATA from './Tea.data.types'; ^^^^^^^^ type TEA_DATA

src/Tea/Tea.data.js:58 58: export default TEA_DATA; ^^^^^^^^ TEA_DATA. type referenced from value position 8: import type TEA_DATA from './Tea.data.types'; ^^^^^^^^ type TEA_DATA

私は間違っていますか?

答えて

0

あなたのタイプを何か別の名前にするだけです。フローでは、同じスコープ内で同じ名前の型と値の両方を持つことはできません。タイプTEA_DATAをインポートし、同じファイルに定数TEA_DATAも指定しました。あなただけのタイプTEA_DATA全体ではなく、モジュールをインポートするように

また、この場合、あなたは(非構造のため、中括弧に注意してください)

import type {TEA_DATA} from './Tea.data.types'; 

を使用する必要があります。

関連する問題