1
我可以有下列對象在一個文件中是否可以在Flow中導入對象的推斷類型?
type MyType = { createdDate: Date }
export const myObject: MyType = { createdDate: new Date() }
而我感興趣的是進口MyType
我導入myObject
。
我可以有下列對象在一個文件中是否可以在Flow中導入對象的推斷類型?
type MyType = { createdDate: Date }
export const myObject: MyType = { createdDate: new Date() }
而我感興趣的是進口MyType
我導入myObject
。
您type
聲明更改爲以下:
export type MyType = { createdDate: Date }
然後,在任何其他文件,你可以這樣做:
import type MyType from 'file'
通過文件的實際位置更換'file'
。
它不應該是必要的出口型。
您可以通過執行推斷類型:
import typeof { MyType } from 'file';