til
til copied to clipboard
Flow.js
Flow
Flow is a static type checker for your JavaScript code
- Flow는 자바스크립트 정적 타입 체커입니다.
- Flow 문법으로 작성된 코드는 Babel이나 flow-remove-types로 표준 자바스크립트로 변환되어야 합니다.
create-react-app
으로 생성된 프로젝트는 flow
를 기본으로 지원합니다. 다음과 같은 의존성을 갖습니다.
react-scripts
└ babel-preset-react-app
└ @babel/plugin-transform-flow-strip-types
└@babel/plugin-syntax-flow
flow-bin
을 추가하고, flow init
을 실행하면 사용할 준비가 완료됩니다.
$ yarn add --dev flow-bin
$ yarn run flow init
yarn run flow
명령어로 오류를 확인합니다.
$ yarn run flow
yarn run v1.22.10
No errors!
Done in 0.09s.
flow-typed
flow-typed is a repository of third-party library interface definitions for use with Flow.
flow-typed
는 서드 파티 라이브러리의 타입 정보(Library Definitions)를 제공해주는 저장소 입니다. 다음과 같은 명령어로 사용합니다.
# yarn 설치
$ yarn global add flow-typed
# npm 설치
$ npm i -g flow-typed
# libdefs 검색
$ flow-typed search react-redux
# libdefs 설치
$ flow-typed install [email protected]
• Searching for 1 libdefs...
• rebasing flow-typed cache...
• Installing 1 libDefs...
• react-redux_v7.x.x.js
└> ./flow-typed/npm/react-redux_v7.x.x.js
.flowconfig
파일의[libs]
섹션에 Library Definition이 정의된 경로를 지정할 수 있습니다../flow-typed
는 지정하지 않아도 기본으로 포함됩니다.