TL;DR
Tsonic is a compiler that translates TypeScript into C# and uses the .NET NativeAOT pipeline to build single-file native executables. It provides direct access to the .NET Base Class Library and can generate CLR bindings from assemblies with an included toolchain.
What happened
A new toolchain called Tsonic converts TypeScript projects into C# code and leverages the standard .NET NativeAOT build flow to produce self-contained native executables. The project maps common TypeScript constructs — classes, interfaces, generics, async/await, iterators and callbacks — onto equivalent CLR concepts so the output integrates with the .NET runtime and BCL. Developers keep TypeScript type-checking, while Tsonic adds CLR-style numeric types and exposes .NET APIs through generated binding packages. A bindings generator, tsbindgen, produces ESM facade files and type declarations from .dlls or NuGet packages so imports like @tsonic/dotnet/System.js resolve to CLR types. The tool runs as an npm package with CLI commands to init projects, generate C#, build native binaries, and add packages or framework references. Installation requires Node.js 22+ and the .NET 10 SDK; macOS users also need Xcode command line tools per the docs.
Why it matters
- Lets TypeScript developers target native, single-file .NET executables without shipping a JavaScript runtime.
- Direct access to the .NET BCL opens file I/O, networking, crypto and concurrency APIs to TypeScript code.
- Uses the standard .NET NativeAOT pipeline, which produces self-contained binaries suitable for deployment.
- Bindings generation enables reuse of existing .NET libraries from TypeScript with typed facades.
Key facts
- Tsonic compiles TypeScript to C# and then uses dotnet publish / NativeAOT to build native executables.
- The tool maps TypeScript language features (classes, generics, async/await, iterators) to CLR equivalents.
- tsbindgen generates ESM facade (*.js) files, TypeScript declaration (*.d.ts) files, and metadata for CLR resolution.
- Tsonic targets the .NET Base Class Library (BCL); Node built-ins are not the default but optional compatibility packages exist.
- Installation is via npm (npm install -g tsonic); prerequisites include Node.js 22+ and .NET 10 SDK.
- CLI commands include project init, generate (C#), build (native executable), run, and helpers to add NuGet or DLL packages.
- NativeAOT produces single-file, self-contained binaries according to the project's documentation.
- Package ecosystem: @tsonic/globals, @tsonic/core, @tsonic/dotnet and optional compatibility packages such as @tsonic/nodejs are listed.
- License for the project is MIT.
What to watch next
- Wider adoption and production readiness of Tsonic across projects — not confirmed in the source
- Compatibility and coverage of Node-style APIs via @tsonic/nodejs for real-world Node modules — not confirmed in the source
- Benchmarks comparing Tsonic-produced binaries to native C# or Node.js performance — not confirmed in the source
Quick glossary
- NativeAOT: A .NET compilation mode that produces ahead-of-time compiled, self-contained native executables without requiring a separate runtime at launch.
- CLR (Common Language Runtime): The execution environment for .NET code that provides services like memory management, type safety, and interoperability for .NET languages.
- BCL (Base Class Library): The standard library shipped with .NET that provides core APIs for I/O, collections, networking, security and more.
- tsbindgen: A bindings generator that creates ESM facade files and TypeScript declarations from .NET assemblies to enable imports from TypeScript.
- ESM (ECMAScript Modules): The standardized JavaScript module format using import/export syntax and file-based module specifiers like .js.
Reader FAQ
What does Tsonic compile from and to?
Tsonic translates TypeScript into C# source and then uses the .NET NativeAOT build pipeline to produce native executables.
Do I still write TypeScript code and get type checking?
Yes. The source indicates your code still typechecks with tsc while Tsonic adds CLR-style numeric types via its core packages.
Can Tsonic use existing .NET libraries?
Yes. The tool relies on tsbindgen to generate bindings from .dlls or NuGet packages so .NET libraries can be imported and used.
Do I need a JavaScript runtime to run the output?
No. Tsonic uses NativeAOT to produce self-contained native binaries that do not require a separate JS runtime.
Is the project production-ready or widely adopted?
not confirmed in the source
Tsonic Tsonic is a TypeScript to C# compiler that produces native executables via .NET NativeAOT. Write TypeScript, get fast native binaries. Why Tsonic? Tsonic lets TypeScript/JavaScript developers build fast native…
Sources
- Show HN: The Tsonic Programming Language
- tsoniclang/tsonic: Compile TS to native code via NativeAOT
- TypeScript to C++
- TypeScript to C Converter
Related posts
- Rethinking natural language interfaces: use LLM-driven structured GUIs instead
- Gleam: A Typed Functional Language on the Erlang (BEAM) Runtime
- Axis: a minimalist systems programming language with Python syntax