如何使用Flow解决Untyped模块错误?

时间:2019-06-23 08:17:23

标签: javascript reactjs flowtype

我遇到流程错误:

  

从未类型化的模块中导入类型使其变为any,而不是   安全!您是要在// @flow的顶部添加../types吗?   (untyped-type-import

这是'../types'文件中的一些代码。

   // @flow
   import type { Account } from '../../props/account'
   import type { Accrual } from '../../props/accrual-prop'
   import type { Amount } from '../../props/amount'
   import type { Customer } from '../../props/customer'
   import type { PaymentTerms } from '../../props/payment-terms'
   import type { NumberSeries } from '../../props/number-series'
   import type { SalesDocumentLock } from '../../props/lock-prop'

    export type Status = 'invoice'|'order'|'offer'

    export type CustomerContact = {
customerContactNumber: number,
name: string,
    }

    export type Employee = {
self?: ?string,
employeeNumber: number,
name: string,
    }

    export type AdditionalExpenseLine = {
additionalExpense: {
    additionalExpenseNumber: number,
    name: string,
    isSystemCreated: boolean
 },
vatAccount: VATAccount,
vatAmount?: ?number,
amount?: number,
grossAmount?:number,
isExcluded: boolean,
salesPricesEnteredInGross : boolean,
vatRate?:number,
additionalExpenseType: AdditionalExpenseType
    }

1 个答案:

答案 0 :(得分:0)

我有一个类似的问题,似乎是由于两个导出功能引起的:

export function foo() {}

还有一个

module.exports = { ... }

在文件中也

一旦我摆脱了export function声明,问题就消失了。 (我的文件中有很多export type条语句,它们很好。)