How to solve Untyped module error with Flow?

Viewed 2768

I am getting an error with flow:

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)

This is some of the code in '../types' file .

   // @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 Answers

I had a problem like this that seemed to be caused by both exporting functions like:

export function foo() {}

and also having a

module.exports = { ... }

in the file as well.

Once I got rid of the export function statements the problem went away. (I had many export type statements in the file, and they were fine.)

Related