TypeScript setup
esrun does not execute TypeScript, nor does it inject ambient globals like Bun or process. esdev runs TypeScript directly — types erased, never checked — and the definitions below are what your editor and tsc --noEmit use.
One-command setup
esdev --install-types
It adds @opentf/esrun-types as a dev dependency, using the package manager your lockfile names (bun, pnpm, yarn, npm), and adds it to compilerOptions.types — creating a tsconfig.json if you don't have one, or merging into an existing one without touching your other settings.
What it configures
{ "compilerOptions": { "target": "ESNext", "module": "ESNext", "moduleResolution": "bundler", "strict": true, "types": ["@opentf/esrun-types"] }, "include": ["**/*.ts"] }
types is what editors and language servers load globally, so the runtime:* modules resolve everywhere, not just per-file.
With no lib, TypeScript uses the default for your target — lib.esnext.full for ESNext — which already includes the web APIs this runtime provides: fetch, URL, crypto, the streams, TextEncoder, and Temporal from TypeScript 7. Setting lib explicitly replaces that default, so a config naming only ["ESNext"] loses all of them.
npm install --save-dev @opentf/esrun-types
Then add "types": ["@opentf/esrun-types"] to compilerOptions, or put /// <reference types="@opentf/esrun-types" /> in one file.
Use it
Your editor now provides intellisense, inline docs, and type checking for every built-in module:
import { file } from "runtime:fs"; // Your IDE knows `text()` returns a Promise<string> const data = await file("./config.json").text();