Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting Flow type in CommonJS?

Is it possible to export and import Flow type definitions in CommonJS world similarly to ES6 like type imports/exports?

like image 643
czerny Avatar asked Jan 23 '18 21:01

czerny


1 Answers

There is no CommonJS-style require for Flow, but Flow's import type/export type syntax can be used alongside CommonJS require calls.

Though the syntax looks similar, import type and export type are not actual JavaScript import/export statements. They must be stripped from your code before your code can be run in current browsers. If you use Babel to compile your code, for example, you use the transform-flow-strip-types plugin to strip Flow types and type imports/exports.

like image 103
Ross Allen Avatar answered Nov 06 '22 21:11

Ross Allen