Runtime type checks
@di-framework/tsc is a ttsc transform that injects runtime parameter checks from your TypeScript types.
Source stays plain TypeScript — no assert(), schemas, or decorators. On emit, function bodies get typeof/ shape guards synthesized from parameter types.
di-framework init wires this by default (@di-framework/tsc and plugins in tsconfig; ttsc and TypeScript 7+ come with @di-framework/tsc). Use the steps below for an existing app.
Installation
Pulls in ttsc and TypeScript 7+ transitively.
The first build compiles a Go sidecar (cached afterward). Needs a Go toolchain (go 1.26+ recommended; ttsc can pin via TTSC_GO_BINARY).
Setup
tsconfig.json:
The package also declares ttsc.plugin for auto-discovery when listed in devDependencies. Explicit plugins[] is recommended so wiring is obvious.
Build with ttsc, not stock tsc:
Example
Emitted JavaScript (simplified):
How it works
ttscloads the program (parse + typecheck).The plugin walks
FunctionDeclarationnodes.For each required parameter, it reads the type (syntax keywords, else checker).
It synthesizes
if/throwAST nodes and prepends them to the body.Emit prints JavaScript from the mutated AST.
Limitations
Skipped today:
methods, arrow functions, function expressions
optional / default / rest / destructured parameters
unions, arrays, tuples, classes, branded types, typia-style tags
Monorepo note
@di-framework/tsc is isolated from the monorepo’s TypeScript 5.x tsc graph (package build is a no-op). ttsc and TypeScript 7+ are dependencies of @di-framework/tsc (kept out of root / other @di-framework/* packages).
Next Steps
CLI - App
init/check/buildand maintainermxInstallation - Core package setup
Best Practices - Recommended patterns