or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli-commands.mdcreation.mdflow-versions.mdindex.mdinstallation.mdlibdefs.mdsearch.md
tile.json

flow-versions.mddocs/

Flow Version Management

Comprehensive Flow version parsing, comparison, and compatibility checking system. This module handles the complex semantics of Flow version ranges and provides utilities for version resolution and compatibility checking.

Capabilities

Flow Version Types

Core type definitions for representing Flow versions in different formats.

/**
 * Represents a specific Flow version with major, minor, patch components
 */
interface FlowSpecificVer {
  /** Major version number */
  major: number;
  /** Minor version number or 'x' for wildcard */
  minor: number | 'x';
  /** Patch version number or 'x' for wildcard */
  patch: number | 'x';
  /** Pre-release identifier or 'x' for wildcard, null if none */
  prerel: string | 'x' | null;
}

/**
 * Union type representing different Flow version specifications
 */
type FlowVersion =
  | { kind: 'all' }
  | { kind: 'specific', ver: FlowSpecificVer }
  | { 
      kind: 'ranged', 
      upper: FlowSpecificVer | null, 
      lower: FlowSpecificVer | null 
    };

Version Parsing

Parse Flow version strings into structured version objects.

/**
 * Parse Flow version directory string into FlowVersion object
 * @param verStr - Version string to parse (e.g., "v0.83.x", "v0.80.0-v0.85.x")
 * @returns Parsed FlowVersion object
 */
function parseDirString(verStr: string): FlowVersion;

/**
 * Parse a specific Flow version string
 * @param verStr - Specific version string (e.g., "v0.83.0")
 * @returns Parsed FlowSpecificVer object
 */
function parseFlowSpecificVer(verStr: string): FlowSpecificVer;

Usage Examples:

import { parseDirString, parseFlowSpecificVer } from "flow-typed";

// Parse single version
const singleVersion = parseDirString("v0.83.x");
// Result: { kind: 'specific', ver: { major: 0, minor: 83, patch: 'x', prerel: null } }

// Parse version range
const rangeVersion = parseDirString("v0.80.0-v0.85.x");
// Result: { kind: 'ranged', lower: {...}, upper: {...} }

// Parse specific version
const specificVer = parseFlowSpecificVer("v0.83.0");
// Result: { major: 0, minor: 83, patch: 0, prerel: null }

Version Resolution

Determine appropriate Flow versions for projects and packages.

/**
 * Determine the Flow version for a project directory
 * Checks .flowconfig, package.json, and other sources
 * @param cwd - Current working directory containing the project
 * @param flowVersionArg - Optional explicit Flow version override
 * @returns Promise resolving to specific FlowVersion object
 */
function determineFlowSpecificVersion(
  cwd: string,
  flowVersionArg?: string
): Promise<{kind: 'specific', ver: FlowSpecificVer}>;

/**
 * Find specific Flow version from package configuration
 * @param startingPath - Starting path to search for Flow version
 * @returns Promise resolving to FlowSpecificVer
 */
function findFlowSpecificVer(startingPath: string): Promise<FlowSpecificVer>;

Usage Examples:

import { determineFlowSpecificVersion } from "flow-typed";
// Note: findFlowSpecificVer is available from flow-typed/lib/npm/npmProjectUtils

// Determine Flow version for current project
const version = await determineFlowSpecificVersion(process.cwd());

// Determine with explicit version override
const version = await determineFlowSpecificVersion(
  "/path/to/project", 
  "v0.83.0"
);

Version Comparison and Compatibility

Functions for comparing Flow versions and checking compatibility.

/**
 * Compare two Flow versions in ascending order
 * @param a - First FlowVersion to compare
 * @param b - Second FlowVersion to compare
 * @returns Number: negative if a < b, 0 if equal, positive if a > b
 */
function compareFlowVersionAsc(a: FlowVersion, b: FlowVersion): number;

/**
 * Check if all provided versions are disjoint (non-overlapping)
 * @param vers - Array of FlowVersions to check
 * @returns Boolean indicating if all versions are disjoint
 */
function disjointVersionsAll(vers: Array<FlowVersion>): boolean;

Usage Examples:

import { compareFlowVersionAsc, disjointVersionsAll } from "flow-typed";

const v1 = parseDirString("v0.83.0");
const v2 = parseDirString("v0.85.0");

// Compare versions
const comparison = compareFlowVersionAsc(v1, v2); // -1 (v1 < v2)

// Check if versions overlap
const versions = [
  parseDirString("v0.80.x"),
  parseDirString("v0.85.x")
];
const areDisjoint = disjointVersionsAll(versions); // true

Version String Conversion

Convert Flow version objects back to string representations.

/**
 * Convert FlowVersion to directory string format
 * @param ver - FlowVersion object to convert
 * @returns Directory string representation (e.g., "v0.83.x")
 */
function toDirString(ver: FlowVersion): string;

/**
 * Convert FlowVersion to semver-compatible string
 * @param ver - FlowVersion object to convert
 * @returns Semver string representation (e.g., "0.83.0")
 */
function toSemverString(ver: FlowVersion): string;

Usage Examples:

import { toDirString, toSemverString, parseDirString } from "flow-typed";

const version = parseDirString("v0.83.x");

// Convert to directory string
const dirStr = toDirString(version); // "v0.83.x"

// Convert to semver string
const semverStr = toSemverString(version); // "0.83.0"

Version Format Specifications

Directory String Format

  • Single version: v0.83.x, v0.83.0
  • Version range: v0.80.0-v0.85.x
  • All versions: all (rarely used)

Supported Version Patterns

  • Exact versions: v0.83.0 - matches exactly version 0.83.0
  • Minor wildcards: v0.83.x - matches any patch version in 0.83.x
  • Major wildcards: v0.x.x - matches any version in 0.x.x
  • Pre-release versions: v0.83.0-beta.1 - includes pre-release identifier
  • Version ranges: v0.80.0-v0.85.x - matches versions between bounds

Compatibility Rules

Flow version compatibility follows these rules:

  1. Exact Match: Exact versions only match themselves
  2. Wildcard Match: x in any position matches any value for that component
  3. Range Match: Version must fall within specified range bounds
  4. Pre-release Handling: Pre-release versions have special precedence rules

Common Use Cases

Project Setup

// Determine project Flow version
const flowVersion = await determineFlowSpecificVersion('./');
const versionStr = toSemverString(flowVersion);
console.log(`Using Flow version: ${versionStr}`);

Library Definition Filtering

// Filter definitions by Flow version compatibility
const compatibleDefs = libdefs.filter(def => {
  return compareFlowVersionAsc(def.flowVersion, targetVersion) <= 0;
});

Version Range Validation

// Check if definition versions overlap
const hasOverlap = !disjointVersionsAll([
  parseDirString("v0.80.x"),
  parseDirString("v0.83.x")
]);

Error Handling

  • Invalid version strings throw ValidationError with descriptive messages
  • Malformed version ranges are detected during parsing
  • Version comparison functions handle all version type combinations
  • File system errors during version detection are propagated appropriately