Library Definitions
Library Definitions
What’s a “Library Definition”?
Most real JavaScript programs depend on third-party code and not just code immediately under the control of the project. That means a project using Flow may need to reference outside code that either doesn’t have type information or doesn’t have accurate and/or precise type information. In order to handle this, Flow supports the concept of a “library definition” (AKA “libdef”).
A libdef is a special file that informs Flow about the type signature of some specific third-party module or package of modules that your application uses. If you’re familiar with languages that have header files (like C++
), you can think of libdefs as a similar concept.
These special files use the same .js
extension as normal JS code, but they are placed in a directory called flow-typed
in the root directory of your project. Placement i