Run TypeScript
run_typescriptExecute TypeScript code in a fresh isolated V8 sandbox and return printed output, return values, or errors under enforced memory and time limits.
Instructions
Execute TypeScript inside a hardened V8 isolate (isolated-vm) and return everything it printed.
Each call gets a brand new isolate, so no state, memory or globals are shared between runs. The isolate is a separate heap with no access to the host process: there is no require, process, timer or file-system API available.
Limits, per call:
512 MB of V8 heap.
30 seconds of wall time; the isolate is disposed when the limit is hit.
fetch is available: the isolate has no network stack of its own, so each request is performed by the host process and the response is copied back in. Per request:
10 seconds of wall time; a slower request rejects with a
TimeoutError.Bodies in either direction are capped at 8388608 bytes.
http:andhttps:URLs only; the host sends no cookies and follows redirects unlessredirectsays otherwise.
Language notes:
The first line of the response reports how long the run took.
The snippet is compiled with esbuild (types stripped) and then executed exactly like
run_javascript: same isolate, same limits, same output capture.import/exportmodule syntax is not supported: the isolate has no module resolver, so the snippet has to be self-contained.Constructs that emit new code (
enum,namespace, constructor parameter properties) make esbuild produce extra lines, so a runtime stack trace can point past the line you wrote. Plain type annotations keep line numbers exact.The snippet runs as the body of an async function, so top-level
awaitand top-levelreturnare both allowed.console.log/console.info/console.debugare captured as stdout;console.warn,console.errorandconsole.traceare captured as stderr.fetch,Headers,Response,AbortController,TextEncoderandTextDecoderare minimal shims:response.text(),response.json(),response.arrayBuffer()andresponse.clone()work, butresponse.bodyisnull(no streams, noblob()),URL/Request/FormData/Blobdo not exist, and the isolate has no timers, sosetTimeoutandAbortSignal.timeoutare unavailable.A top-level
returnvalue is reported back underresult:. - Uncaught exceptions, syntax errors and their stack traces are reported back undererror:, and the tool is flagged as an error.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | TypeScript code to run |