A CLI tool for managing high-quality Flow type definitions for third-party JavaScript libraries
npx @tessl/cli install tessl/npm-flow-typed@4.1.0Flow-typed is a CLI tool for managing high-quality Flow type definitions for third-party JavaScript libraries. It provides a comprehensive repository system and automated tooling for discovering, installing, and managing type definitions, enabling developers to maintain strong type safety across their entire dependency graph.
npm install -g flow-typedimport {
runCLI,
install,
search,
createDef,
createStub,
outdated,
runTests,
update,
updateCache,
validateDefs
} from "flow-typed";For CommonJS:
const {
runCLI,
install,
search,
createDef,
createStub,
outdated,
runTests,
update,
updateCache,
validateDefs
} = require("flow-typed");import { runCLI, install } from "flow-typed";
// Run the CLI programmatically
runCLI();
// Install library definitions programmatically
const result = await install({
explicitLibDefs: ['lodash', 'express'],
flowVersion: 'v0.83.0',
verbose: true,
skip: false
});Flow-typed is built around several key components:
Primary command-line interface providing all flow-typed functionality through a yargs-based CLI system.
/**
* Main CLI entry point function
*/
function runCLI(): void;Core functionality for installing, updating, and managing Flow type definitions for third-party libraries.
/**
* Install library definitions
* @param args - Installation configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function install(args: InstallArgs): Promise<number>;
interface InstallArgs {
flowVersion?: string;
overwrite?: boolean;
skip?: boolean;
skipCache?: boolean;
skipFlowRestart?: boolean;
verbose?: boolean;
libdefDir?: string;
cacheDir?: string;
packageDir?: string;
ignoreDeps?: Array<string>;
rootDir?: string;
useCacheUntil?: number;
explicitLibDefs?: Array<string>;
}Search functionality for finding available type definitions in the flow-typed repository.
/**
* Search for available library definitions
* @param args - Search configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function search(args: SearchArgs): Promise<number>;
interface SearchArgs {
term: string;
flowVersion?: string;
}Tools for creating new type definitions and stubs for libraries without existing definitions.
/**
* Create template library definition
* @param args - Creation configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function createDef(args: CreateDefArgs): Promise<number>;
/**
* Create stub definition for missing libraries
* @param args - Stub creation configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function createStub(args: CreateStubArgs): Promise<number>;
interface CreateDefArgs {
libName: string;
ver: string;
}
interface CreateStubArgs {
libName: string;
libdefDir?: string;
overwrite?: boolean;
maxLines?: number;
}Comprehensive Flow version parsing, comparison, and compatibility checking system.
/**
* Parse Flow version directory string
* @param verStr - Version string to parse
* @returns Parsed Flow version object
*/
function parseDirString(verStr: string): FlowVersion;
/**
* Determine Flow version for a project
* @param packageDir - Directory containing package.json
* @param flowVersion - Optional explicit Flow version
* @returns Promise resolving to Flow version
*/
function determineFlowSpecificVersion(
packageDir: string,
flowVersion?: string
): Promise<FlowVersion>;
type FlowVersion =
| { kind: 'all' }
| { kind: 'specific', ver: FlowSpecificVer }
| { kind: 'ranged', upper: FlowSpecificVer | null, lower: FlowSpecificVer | null };
interface FlowSpecificVer {
major: number;
minor: number | 'x';
patch: number | 'x';
prerel: string | 'x' | null;
}System for managing, filtering, and working with Flow type definitions from the repository.
/**
* Get library definitions from directory
* @param defsDir - Directory containing definitions
* @returns Promise resolving to array of library definitions
*/
function getLibDefs(defsDir: string): Promise<Array<LibDef>>;
/**
* Filter library definitions based on criteria
* @param defs - Array of library definitions
* @param filter - Filter criteria
* @returns Filtered array of definitions
*/
function filterLibDefs(
defs: Array<LibDef>,
filter: FilterOptions
): Array<LibDef>;
interface LibDef {
pkgName: string;
pkgVersionStr: string;
configPath: string | null;
flowVersion: FlowVersion;
flowVersionStr: string;
path: string;
testFilePaths: Array<string>;
}
interface FilterOptions {
type: 'fuzzy' | 'exact';
term: string;
flowVersionStr?: string;
}