package
A command line tool for working with flow and flow-runtime.
npm install flow-runtime-cliGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
A command line interface for working with flow-runtime and Flow.
Discovers imported and global type dependencies in your source code and produces a single file containing the flow-runtime type definitions for those dependencies.
Let's say you have some code like this:
/* @flow */
function get (store: Storage, key: string) {
return store.getItem(key);
}
get(localStorage, 'foo');Storage is a global type, built in to Flow, but flow-runtime itself doesn't know anything about it - if you compile this code, flow-runtime will emit a warning about being unable to resolve a type called "Storage".
A possible solution to this would be to include all the type definitions which come with Flow as part of flow-runtime, but this is wasteful - the file would be very large and most definitions would go unused.
To solve this problem, flow-runtime-cli:
flow-typed or wherever specified by your .flowconfig file.import t from "flow-runtime";
t.declare(
t.class(
"Storage",
t.object(
t.property("length", t.number()),
t.property(
"getItem",
t.function(t.param("key", t.string()), t.return(t.nullable(t.string())))
),
t.property(
"setItem",
t.function(
t.param("key", t.
You can then import this file once, in your entry point, and flow-runtime will be able to validates values of this type.
npm install flow-runtime-clior
yarn add flow-runtime-cliIf your source files are in a folder called src, run:
flow-runtime generate ./src > ./src/typedefs.jsthen, in your entry point (e.g. index.js) your first import should be:
import './typedefs';charlespick
charles@codemix.com
Estimated unpacked size across 25 packages.
22.1 MB
Includes dependencies.
8 direct · 3 outdated
^3.4.7
3.7.2
^1.2.0
1.2.8
^0.11.0
3.10.1
^0.38.0
0.340.0
^0.17.0
0.17.0
^2.1.0-0
2.1.0-0
^0.3.0
0.3.0
^0.17.0
0.19.0