Proof-based JavaScript → TypeScript rewriter. Record behavior. Port anything. Prove parity. Keep a kill switch.
record → port → replay → diff → gate → swap in — with a byte-exact, one-command undo.
AI agents (and humans) port code confidently and incorrectly. Type checking catches type errors — it cannot catch behavior changes. The only honest way to rewrite logic is to make the original's runtime behavior the contract:
- record — capture real inputs → outputs of the original JS (lossless codecs:
NaN,-0,BigInt,Date,RegExp,Map/Set, typed arrays, cycles, lone surrogates, error chains). - port — generate a typed TS port (evidence-inferred types, JSDoc extraction, reversible
// >>> typescript-anything: … >>>markers). Let an agent or a human finish it. - replay — re-run every recorded case against the port.
- diff — compare outputs with explicit tolerances (float relative epsilon, NaN/-0 policy, unicode NFC/NFD, order-insensitive collections). Divergence? The port is wrong. Fix it, re-diff.
- gate — parity + marker integrity + size budget + export-surface parity + typecheck + tests + 40+ module checks (secret scan, trojan-source, supply-chain baseline, i18n probes…).
- revert — the kill switch: strip markers byte-exactly (CRLF-aware) and remove generated files. Originals are never modified.
Proof, not vibes:
ta diffexit code 0 means n/n recorded cases reproduced exactly — including thrown-error identity.
npm install -g typescript-anything # or: npx ta …
ta init # create ta.config.json
ta record --entry src/lib.js # 500 cases → .ta/cases.jsonl
ta port --entry src # typed skeletons + markers
# …finish the port by hand or with an agent
ta replay --entry src/lib.ts # re-run every case
ta diff # PROOF: 100% parity or divergence list
ta gate # definition of done
ta revert # kill switch — byte-exact undoA complete runnable demo: npm run demo.
425 modules / 1,725 machine-counted features across 24 categories — counted from the live registry at runtime (ta features count, asserted in CI), never hand-written:
| category | modules | what it gives you |
|---|---|---|
codecs |
25 | lossless value serialization (typed arrays, error cause chains, symbols, prototype tags, URL/Intl, AbortSignal, stream chunks, Temporal-lite…) |
record |
20 | evidence capture: harness API, seeded PRNG, determinism audit, merkle tamper chain, secret redaction, process metrics, fd snapshots, network shapes |
diff |
16 | tolerance rules (float/NaN/−0/unicode/set/map/key order), RFC 6902 JSON patch, edit scripts, known-diffs ledger with required reasons |
fuzz |
24 | 93 adversarial corpora: astral emoji, bidi trojans, BOM/NEL, Turkish İ, DST boundaries, float-print edges, regex traps, gzip bombs, calendar edges |
gate |
24 | 103 checks: strict typecheck, no-any budget, eval quarantine, secret scan, license, marker protocol, semver surface, budget asserts, exports policy |
bench |
20 | percentile statistics, bootstrap probability-of-faster, --cpu-prof/--heap-prof spawning, chrome trace export, throughput/tail-latency/startup/memory ceilings |
port |
24 | JS→TS transforms: evidence type inference, generics/tuples/recursive types, marker writer/restorer, decorator strip, class-field semantics, module shape |
runtime |
18 | node/bun/deno/electron/container/ssh adapters, worker threads, vm sandbox, cross-runtime matrix, crash classifier, exit-code parity |
adapters |
24 | react/vue/svelte/express/fastify/nest detection, package managers, tsconfig/eslint emit, GitHub/GitLab CI, pre-commit, devcontainer, Zed/Neovim/Cursor/Copilot/DevPod |
watch |
20 | poll/event watchers, content-addressed cache, LRU/TTL, import-graph invalidation, atomic writes, lockfiles, undo stack, snapshot restore |
security |
24 | prototype hardening, supply-chain baseline, SBOM, tar/zip-slip/symlink-escape guards, timing-safe compare, env allowlist, header injection, concurrency |
report |
22 | REPORT.md/html, SARIF 2.1.0, JUnit XML, badges, OTel dump, Prometheus text, SVG timeline, GitHub annotations, AI prompt packs, MCP server |
ai |
18 | agent harness & task envelopes, prompt library, unit-contract inference, sha-addressed evidence store, knowledge graph, Codex/Claude/Cursor adapters |
mcp |
12 | streamable HTTP transport (SSE), tool JSON-Schemas, resources/prompts registries, progress notifications, OAuth descriptor, conformance self-test |
kill |
14 | per-unit env kill switches, gradual rollout (hash cohorts), circuit breaker, canary compare, rollback store, shadow traffic, freeze button, flap guard |
swap |
12 | import rewriting with dry-run, byte-exact marker restore, package exports map, alias shims, conditional load, freeze bundles, version pins |
state |
12 | atomic typed store, cross-process lockfile, schema migrations, content-addressed cache, snapshots, remote sync, GC, checksums, jq-lite query |
observ |
14 | JSONL structured logs with redaction, counters/gauges/histograms, span tracer, OTLP shim, Prometheus exposition, alert rules, crash reporter |
interop |
16 | napi .d.ts decl gen, wasm loader + bindgen decode, fa_call-style C ABI, Deno FFI, struct layout calculator, safe DataView accessors, ABI versioning |
profile |
14 | .cpuprof parsing with self-time, hotspot ranking, fast-anything-style covered_by ≥90% rule, flame summaries, heap summaries, event-loop lag |
pm |
10 | npm/pnpm/yarn/bun/deno/uv(python)/cargo(rust)/go/maven(JVM) adapters + cross-PM lockfile drift checks — record/replay beyond JS |
fw |
16 | react/next/vue/svelte/astro/electron/remix/express/fastify/nest/turborepo/monorepo/vite analyzers, Storybook stories as replay corpus |
ci |
12 | GitHub Actions/GitLab CI/pre-commit/husky/Dockerfile generators, release flow with provenance, matrix strategy, cache policy, flake quarantine, publish guard |
docs |
14 | TSDoc API docs, verified tutorials/examples, ADR store, compat table, mermaid diagrams, static SVG badges, tiny SSG site, RSS/Atom feed, README score |
Full catalog with per-feature tables: docs/FEATURES.md (4,751 lines, generated from the running binary).
The 12 new advanced categories (220 new modules) turn the proof pipeline into a full porting platform:
| new category | one-liner |
|---|---|
ai |
drive porting agents with task envelopes, token budgets, evidence store, and a knowledge graph |
mcp |
streamable HTTP + SSE MCP server surface with conformance self-tests |
kill |
runtime kill switches: env flags, gradual rollout, circuit breaker, canary, rollback, freeze |
swap |
swap ports in: import rewriting, marker restore, alias shims, freeze bundles |
state |
persisted state: atomic store, locks, migrations, snapshots, GC |
observ |
structured logs, metrics, spans, OTLP shim, Prometheus exposition |
interop |
napi/wasm/C-ABI declaration generation, struct layouts, ABI versioning |
profile |
.cpuprof parsing, hotspot ranking, the covered_by ≥90% hot-path rule |
pm |
record/replay beyond JS: python/uv, rust/cargo, go, JVM/maven bridges |
fw |
framework-aware analysis: React/Next/Vue/Svelte/Astro/Electron/Nest and more |
ci |
generate CI: Actions, GitLab, pre-commit, husky, Dockerfile, release flow |
docs |
docs automation: API docs, tutorials, ADRs, SSG site, RSS |
- MCP server —
ta mcpspeaks JSON-RPC 2.0 over stdio (initialize,tools/list,tools/call,ping) so Claude/Cursor/Codex agents can read the evidence and the proof while porting. Prompt library:ta mcp-prompts. - Adversarial by default — recording round-robins all 93 corpora, so your evidence set contains
İstanbul,0.1+0.2, DST-gap timestamps, 300-deep nesting and lone surrogates before you trust the port. - Everything reversible — every source transform is wrapped in marker blocks;
ta revert/ta unmarkrestore byte-exact originals (CRLF-safe, sha-verifiable). - Zero runtime dependencies — Node ≥ 18.17 and nothing else.
ta doctorself-audits the whole engine (codec round-trips, tolerance sanity, registry integrity). - Trusted by CI —
ta ciemits GitHub annotations (::error …::) and hard exit codes; tests assert ≥ 200 modules and ≥ 600 features so the catalog can never silently shrink.
┌──────────── ORIGINAL (never modified) ─────────────┐
│ │
ta record─┤─▶ cases.jsonl (lossless, adversarial, merkle-chained)
│ │
ta port ──┼─▶ port.ts (evidence-inferred types + markers) │
│ │ │
ta replay─┼──▶ replay.jsonl ──▶ ta diff ──▶ diff.json (proof) │
│ │ │
ta gate ←─┴──────────────────────────────────────────┘ │
│ pass │
swap in the port ── ta revert = kill switch ─┘
- Extension contract — every module plugs into typed extension points (
registerCodec,registerCheck,registerCorpus,registerDiffRule,registerReporter,registerPortTransform,registerRuntime,registerCommand,registerAnalyzer, or the event bus). Read docs/module-contract.md and ship your own in ~100 lines. - Wire format — plugin codecs wrap values as
{ $codec, v }; cycles become$refpaths; truncation is explicit ($trunc); reserved keys are escaped — the format never lies about what it lost.
tsc --allowJs |
ts-migrate | TypeStat | typescript-anything | |
|---|---|---|---|---|
| Adds types without touching logic | ✅ | ✅ | ✅ | ✅ (evidence-inferred) |
| Proves behavioral parity | ❌ | ❌ | ❌ | ✅ record/replay/diff over adversarial corpora |
| Error-identity preserved (throw for throw) | ❌ | ❌ | ❌ | ✅ |
| Byte-exact undo of the whole port | ❌ | n/a | ❌ | ✅ ta revert |
| Bench original vs port | ❌ | ❌ | ❌ | ✅ percentiles + bootstrap |
| Kill switch for production | ❌ | ❌ | ❌ | ✅ revert + marker protocol |
| MCP server for AI agents | ❌ | ❌ | ❌ | ✅ |
Does it rewrite my files in place? No. ta port writes new .ts files and never modifies your .js originals; every generated block is marker-wrapped; ta revert deletes exactly what the manifest lists.
What about non-deterministic code (clock, randomness)? ta determinism re-runs evidence and flags flaky units; recording warns on nondeterminism; virtual-clock utilities and boundary-date corpora help you pin time-dependent logic.
Can it port a function written in another language? Yes — any process that can read cases.jsonl and emit replay.jsonl is provable. The runtime adapters even run the matrix across node/bun/deno.
Why 1,725 features and not 100? Because rewriting code honestly is a wide problem: codecs, tolerances, i18n, security, concurrency, CI, reporting, agent integration. Every feature is machine-counted from the running registry — and asserted in CI, so the number is real.
Is it a toy? It is a serious v4 with a serious caveat: it proves what you recorded. Thin evidence = weak proof — that's why ta fuzz --harvest, coverage proxies, and thin-evidence gates exist.
src/ engine: cli, pipeline commands, registry, codecs, diff, inference
src/modules/ 425 extension modules in 24 categories (generated index)
src/test/ 56 tests incl. registry integrity + full pipeline e2e
docs/ FEATURES.md (generated), QUICKSTART.md (generated), module contract
examples/ slugify + stringUtils: recorded, ported, gated end-to-end
scripts/ gen-module-index / gen-features-doc / demo runner
.github/ CI: build, test, doctor, count assertions on 4 node versions
npm install # typescript + @types/node (dev-only)
npm test # build + 56 tests
npm run doctor # full self-audit (registry issues must be 0)
npm run features # print live feature countContributions welcome — one module per file, real logic only, see CONTRIBUTING.md and the module contract.
MIT © 2026 typescript-anything contributors
Quickstart · Feature catalog · Module contract · Changelog
Star ⭐ the repo if proof-based porting sounds better than vibes-based porting.