Skip to content

Latest commit

Β 

History

History

flow

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Parcel with Flow

Parcel supports using Flow types out of the box.

In this example we use the .flowconfig file to instruct Parcel to use Flow and the // @flow pragma at the top of each JS file to specify those files to be type-checked.

To run Flow, either install it as an editor indtegration, or run either yarn run flow or npm run flow.

Running Flow over this example should result in the following error:

Error β”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆβ”ˆ src/index.js:7:28
Cannot assign banana.color to bananaColor because string [1] is incompatible with boolean [2].

     src/index.js
      4β”‚ import banana from "/fruits/banana";
      5β”‚
      6β”‚ let ripeApple: boolean = apple.ripe;
 [2]  7β”‚ let bananaColor: boolean = banana.color;
      8β”‚
      9β”‚ console.log("is the apple ripe?", ripeApple);
     10β”‚ console.log("what is the banana's color?", bananaColor);

     src/fruits/banana.js
 [1]  4β”‚   color: "green",

Further Reading:

For an example supporting Parcel's Absolute Module Resolution, see Parcel Absolute Module Resolution with Flow.