【问题标题】:How to solve Untyped module error with Flow?如何使用 Flow 解决 Untyped 模块错误?
【发布时间】:2019-11-05 09:50:49
【问题描述】:

我在流程中遇到错误:

从无类型模块导入类型使其成为any,而不是 安全的!您的意思是在../types 的顶部添加// @flow 吗? (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
    }

【问题讨论】:

  • 到目前为止,您采取了哪些修复措施?如果不查看更多文件或有关错误的更多信息,很难判断出了什么问题。显然,您在此文件的顶部有 // @flow,因此 Flow 推荐的明显修复不适用。

标签: javascript reactjs flowtype


【解决方案1】:

我遇到了这样的问题,这似乎是由以下两个导出功能引起的:

export function foo() {}

还有一个

module.exports = { ... }

也在文件中。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-19
    • 2018-03-24
    • 2021-01-05
    • 1970-01-01
    • 1970-01-01
    • 2021-08-31
    相关资源
    最近更新 更多