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

标签 javascript reactjs flowtype

我收到流程错误:

Importing a type from an untyped module makes it any and is not safe! Did you mean to add // @flow to the top of ../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
    }

最佳答案

我遇到了这样的问题,这似乎是由两个导出功能引起的,例如:
export function foo() {}
并且还有一个
module.exports = { ... }
在文件中也是如此。

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

关于javascript - 如何使用 Flow 解决 Untyped 模块错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56722165/

相关文章:

javascript - 在谷歌地图API中自定义自动完成字段

javascript - 我如何在 ng-bind-html 中使用 ng-click

javascript - ReactJS:对 setState 进行计算并更新

reactjs - 将图像文件 react 到canvas,然后转换为base64

typescript - 在 TypeScript 中键入 compose 函数 (Flow $Compose)

flowtype - 在 FreeBSD 上启动 flow-bin 时的 Unix 异常

javascript - 在流程 : test whether variables got set 中编写规范

javascript - 使用 setTimeout 的函数会在后续调用中抛出

javascript - 用于移动浏览器的 Reactjs 中的事件监听器

css - 如何在 Material UI 中设置 ListItem 的选择和悬停颜色?