Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use exports as a type because exports is a value

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.

like image 343
damd Avatar asked Mar 27 '18 08:03

damd


People also ask

Can I export type in TypeScript?

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.

What is export in JavaScript?

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.

What is the use of export in TypeScript?

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.

What is difference between export and export default?

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.


1 Answers

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'
like image 64
damd Avatar answered Oct 27 '22 11:10

damd