Learn
Running TypeScript online with Node type stripping
Last updated: July 19, 2026
How Code Arena executes TypeScript with Node.js type stripping — what works, what does not, how it differs from tsc, and how to design playground-friendly typed snippets.
Why strip types instead of compiling?
A full TypeScript project usually runs tsc (or a bundler) to emit JavaScript. That needs a toolchain, often a tsconfig, and frequently packages from npm.
Code Arena’s sandbox has no network installs and aims for fast feedback. Node’s type-stripping path removes type syntax and runs the remaining JavaScript directly — enough for many playground snippets without shipping a compiler into every run.
What Code Arena runs
TypeScript files are written as main.ts and executed with Node 24 flags that strip types and suppress experimental warnings. You get console output just like JavaScript when the syntax is erasable.
Think of stripping as scissors for type annotations, not as a full TypeScript emitter. If a feature needs the compiler to generate helper code, stripping alone may not be enough.
- Good fit: type annotations, interfaces used only as types, type aliases, many generics
- Risky: enums that need emit, namespaces, decorators, path aliases, npm imports
- Also risky: TS features that rewrite runtime semantics rather than erase cleanly
Stripping is not typechecking
If you write a type error, Node may still run the program after types are removed — or fail for unrelated runtime reasons. The sandbox will not print a tidy list of TS2322 diagnostics the way tsc does.
Use a local tsc --noEmit or your IDE for real type safety. Use Code Arena for quick typed experiments, teaching demos, and validating runtime behavior of small sketches.
Designing snippets that survive stripping
Prefer interfaces and type aliases over enums. Prefer union types and discriminated unions expressed with plain objects. Keep imports to built-ins you truly need, or avoid imports entirely for the smallest demos.
When something fails, bisect: remove types until you have plain JS that runs, then re-add annotations gradually. That isolates “strip/runtime limitation” from “logic bug.”
How this compares to other online runners
Some online TypeScript sandboxes bundle a full compiler or use transpile-only modes with different defaults. Code Arena’s choice optimizes for sandboxed Node execution without package installs.
If you need JSX transforms, path mapping, or emit-heavy features, a Vite/Next local template (or a specialized TS playground) is the better tool. Match the tool to the job.
Try it
Open the TypeScript editor, keep the typed sum example, change a parameter type, and Run. Then try a small interface-based object example. If you experiment with enums or decorators, be ready to simplify when execution fails.