Using Flow types with modules

Exporting data types (including generics, interfaces, and so on) is quite similar to normal exports, except that you must include the word type. If you wanted to use the conversion type elsewhere, in the original module, you would add the following:

export type { conversion };

Correspondingly, wherever you wanted to import that type, you would add something like this:

import type { conversion } from "./module_conversions.js";

Note, however, an important detail: you cannot export or import data types in the same sentence in which you deal with standard JS elements: export and export type are distinct, separate statements, and so are import and import type.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset