JS@PayPal 2017: Flow Workshop
For this task you need to install flow.
Instructions
npm install flow-bin
- Edit package.json and add
flow
to scripts. - Run
npm run flow init
to setup your.flowconfig
- Type
npm run flow
Expectation
Flow needs to run when you type: npm run flow
Here we'll be setting up babel to strip flow types.
Instructions
npm install babel-cli babel-preset-env babel-plugin-transform-flow-strip-types
- Edit
.babelrc
to enable thepreset-env
andstrip-types
- Add
"babel": "babel-node",
to thepackage.json
inscripts
- Type
npm run babel index.js
Expectation
Calling npm run babel index.js
should produce "Welcome to the FlowType Workshop"
Go through each function and variable declartion in 1.js
and make
sure that it has the correct flowType. Correct any type errors
or add additional conditional statements needed to satisfy flow.
Expectation
npm run babel 1.js
should display "Hello"npm run flow check-contents < 1.js
should show no errorsnpm run flow coverage 1.js
should show 100% coverage
Go through each function and variable declartion in 1.js
and make
sure that it has the correct flowType. Correct any type errors
or add additional conditional statements needed to satisfy flow.
Expectation
npm run babel 2.js
should display "Hello"npm run flow check-contents < 2.js
should show no errorsnpm run flow coverage 2.js
should show 100% coverage
Create a formatAmount
function in 3.js that takes as params
a string or a number and returns a formatted number string
that is formatted to 2-decimal places.
After ensuring that the flow typing is working, you can change or remove
any input into the formatAmount()
function that is not a string or
a number.
Expectation
npm run babel 3.js
should show 6 numbers formatted w/2-decimal places (i.e. "10.00")npm run flow check-conents < 3.js
should show no errorsnpm run flow coverage 3.js
should show 100%