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.
Use a named export to export a type in TypeScript, e.g. export type Person = {} . The exported type can be imported by using a named import as import {Person} from './another-file' . You can have as many named exports as necessary in a single file.
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the import declaration or dynamic import.
TypeScript supports export = to model the traditional CommonJS and AMD workflow. The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.
Exports without a default tag are Named exports. Exports with the default tag are Default exports. Using one over the other can have effects on your code readability, file structure, and component organization. Named and Default exports are not React-centric ideas.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With