type-registry-effect
v0.2.2
Published
Fetch, cache, and resolve TypeScript type definitions from npm packages for use with Twoslash and documentation tooling. Built on Effect.
Readme
type-registry-effect
Fetch, cache, and resolve TypeScript type definitions from npm packages for use with Twoslash and other documentation tooling that needs type-aware code samples.
Features
- Composable Effect programs with typed errors and explicit service requirements
- Disk-based caching with XDG Base Directory compliance and TTL support
- Virtual file system generation compatible with @typescript/vfs and Twoslash
- Module resolution via package.json exports, typesVersions, and legacy fields
- Concurrent package loading with graceful degradation on partial failures
- Built-in Effect Metrics (counters and timers) for cache hits, load durations, and batch operations
Installation
npm install type-registry-effect effect @effect/platformSee docs/guides/getting-started.md for peer dependency details.
Quick Start
import { TypeRegistry, PackageSpec } from "type-registry-effect";
import { NodeLayer } from "type-registry-effect/node";
import { Effect } from "effect";
const program = TypeRegistry.getVFS([
new PackageSpec({ name: "zod", version: "3.23.8" }),
new PackageSpec({ name: "@effect/schema", version: "0.79.0" }),
]);
const vfs = await Effect.runPromise(Effect.provide(program, NodeLayer));Documentation
For detailed guides, architecture, and API reference, see docs/.
