Javascript 如何使用流解决非类型化模块错误?
我在flow中遇到一个错误: 从非类型化模块导入类型将使其成为任何类型,而不是 安全!您的意思是将Javascript 如何使用流解决非类型化模块错误?,javascript,reactjs,flowtype,Javascript,Reactjs,Flowtype,我在flow中遇到一个错误: 从非类型化模块导入类型将使其成为任何类型,而不是 安全!您的意思是将/@flow添加到./类型的顶部吗? (非类型类型导入) 这是“../types”文件中的一些代码 // @flow import type { Account } from '../../props/account' import type { Accrual } from '../../props/accrual-prop' import type { Amount }
/@flow
添加到./类型的顶部吗?
(非类型类型导入
)
这是“../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
}
我遇到了这样一个问题,这似乎是由以下两个导出函数引起的:
导出函数foo(){}
还有一个
module.exports={…}
也在文件中
一旦我去掉了导出函数
语句,问题就消失了。(我在文件中有许多导出类型语句,它们都很好。)到目前为止,您采取了哪些步骤来修复?如果看不到更多的文件或关于错误的更多信息,就很难判断出问题出在哪里。显然,您在该文件的顶部有/@flow
,因此flow推荐的明显修复方案不适用。