Cannot use exports as a type because exports is a value
Asked Answered
N

2

7

I get this error when running flow check, but I'm not sure what it means.

Cannot use exports as a type because exports is a value. To get the type of a value use typeof.

The error location is 0:1 (at the @flow comment). Here's the code:

/* @flow */
import Chunk from '../models/Chunk'

export interface IChunkSorter {
  sort(chunks: Chunk[]): Chunk[];
}

Any ideas? I've googled for the error message but there's literally no results.

Nonscheduled answered 27/3, 2018 at 8:55 Comment(2)
What is the definition of a Chunk? If it is a type, you should import it with import type .... Otherwise define type ChunkType = typeof Chunk and use it sort(chunks: ChunkType[]): ChunkType[]; – Budweis
@AlekseyL. Chunk is a class and I still get the same error when I use what you suggested :/ – Nonscheduled
N
20

The problem was in a completely different file where I was importing IChunkSorter incorrectly. I was using:

import type IChunkSorter from './IChunkSorter'

This fixed it:

import type { IChunkSorter } from './IChunkSorter'
Nonscheduled answered 28/3, 2018 at 10:0 Comment(2)
This was the only result! Thanks! πŸ˜ƒ – Crewel
Thanks! Mine was because I did export type and included an enum. This answer made me realize that. – Deduct
I
0

I had the same issue when exporting an enum as a type. I fixed the issue by exporting the enum as I would do with a regular constant: export MyEnum.

Inlay answered 3/11, 2023 at 15:56 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.