25
loading...
This website collects cookies to deliver better user experience
false + 1
[] + 5
“ “ + 9
calculateSum()
function to prevent the user from inputting the string value. Because the error is detected in the early stages, it is less expensive as compared to finding out about the bug once it has been delivered to the client.npx create-react-app flowchecker
# or
yarn create-react-app flowchecker
npm install --save-dev flow-bin
# or
yarn add -D flow-bin
“scripts”: {
“flow”: “flow”
}
npm run flow init
# or
yarn flow init
[ignore]
.*/node_modules/.*
.*/src/registerServiceWorker\.js
.*/src/index\.js
.*\.test\.js
[include]
[libs]
[lints]
[options]
all=true
[strict]
// @Flow
npm run flow init
# or
yarn run flow init
No errors!
Done in 0.18s.
// @flow
function calculateSum(a, b) {
return a + b;
}
calculateSum(3, 4); // Works!
// $ExpectError
calculateSum(true, false); // Error!
npx create-react-app my-app --template typescript
# or
yarn create-react-app my-app --template typescript
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
# or
yarn add typescript @types/node @types/react @types/react-dom @types/jest
npm install --save-dev typescript
#or
yarn add --dev typescript
tsc
command, navigate to package.json
and add this command in the scripts section.“scripts”: {
“typecheck”: “tsc”
}
npx tsc --init
# or
yarn run tsc --init
tsconfig.json
file. The TypeScript compiler provides numerous configuration options. For details on the compiler configuration, check this documentation.src
folder.npm run typecheck
# or
yarn typecheck