@opentf/esrun-types
v0.16.0
Published
TypeScript type definitions for ES Runtime (esrun) — the runtime: standard modules (process, path, fs, db, net, http).
Maintainers
Readme
@opentf/esrun-types
TypeScript type definitions for ES Runtime
(esrun) — every runtime: standard module, so your editor gives completion
and type-checking for import … from "runtime:fs" and its siblings.
Install
bun add -d @opentf/esrun-types # or: npm i -D @opentf/esrun-typesUse
Add the package to your tsconfig.json:
{ "compilerOptions": { "types": ["@opentf/esrun-types"] } }…or reference it from one file:
/// <reference types="@opentf/esrun-types" />Then the runtime: imports are fully typed:
import { file, write } from "runtime:fs";
const cfg = await file("./config/app.json").json();
await write("./out/result.txt", "done", { append: true });esrun targets the WinterTC web-platform surface, so web globals (URL, Blob,
ReadableStream, Response, …) come from your lib (dom or webworker).
Covered
runtime:process—env,args,platform,arch,cwd(),exit(),stdout,stderrruntime:path—join,resolve,normalize,dirname,basename,extname,parse,relative,isAbsolute,sep,delimiter,fromFileURL,toFileURLruntime:fs—file(),write(),readDir,stat,exists,mkdir,remove,rename,Globruntime:db—connect,sql,queryAst,sqlite,Connection,Rows,Pool,Driver,DbError, and the driver-authoring surface (defineDriver,runBackendConformance)runtime:net—connect,listen,bind,Socket,Listener,DatagramSocketruntime:http—serve,Handler,Server,withTrailersruntime:websocket—serve,upgradeWebSocket,WebSocketConnection,broadcastruntime:serialization—XML,YAML,TOML,MessagePack,JSONL,Protobufruntime:hashing—hash,Hasher,hashStream,hmac,timingSafeEqual,passwordruntime:images—Imageruntime:system—Command,ChildProcessruntime:wasi—WASI
The last three are esdev's, not esrun's — a deployed binary has no bundler,
no watcher and no test runner:
runtime:build—build,Plugin,Hook,BuildOptions,BuildResultruntime:watch—watch,Watcher,Changeruntime:test—test,beforeAll,afterAll,beforeEach,afterEach,assert,assertEquals,assertThrows,assertRejects
…plus the few globals whose shape here differs from the standard libs.
