Tsonic.JSRuntime 0.0.9

dotnet add package Tsonic.JSRuntime --version 0.0.9
                    
NuGet\Install-Package Tsonic.JSRuntime -Version 0.0.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tsonic.JSRuntime" Version="0.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tsonic.JSRuntime" Version="0.0.9" />
                    
Directory.Packages.props
<PackageReference Include="Tsonic.JSRuntime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tsonic.JSRuntime --version 0.0.9
                    
#r "nuget: Tsonic.JSRuntime, 0.0.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tsonic.JSRuntime@0.0.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tsonic.JSRuntime&version=0.0.9
                    
Install as a Cake Addin
#tool nuget:?package=Tsonic.JSRuntime&version=0.0.9
                    
Install as a Cake Tool

Tsonic.JSRuntime

JavaScript/TypeScript runtime implementation for the Tsonic compiler - provides exact JavaScript semantics in C#.

Overview

Tsonic.JSRuntime is a C# library that implements JavaScript semantics, enabling TypeScript code compiled by Tsonic to behave exactly like it would in a JavaScript runtime. This includes:

  • JavaScript Arrays - Sparse arrays with JS semantics (length, holes, etc.)
  • String manipulation - JS string methods and behavior
  • Type coercion - Automatic type conversions matching JS rules
  • Structural typing - Duck typing and object shape compatibility
  • Console API - console.log, console.error, etc.
  • JSON support - JSON.stringify, JSON.parse
  • Math - JavaScript Math object (abs, floor, ceil, round, random, etc.)
  • Global functions - parseInt, parseFloat, encodeURIComponent, etc.
  • Map/Set - ES6 Map and Set collections
  • WeakMap/WeakSet - Weak reference collections
  • ArrayBuffer - Fixed-length binary data buffer
  • Typed Arrays - Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array
  • Date - Date object with timezone support
  • RegExp - Regular expression support with JavaScript flags

For Tsonic Users

Install and enable the bindings package:

# new project
npx --yes tsonic@latest init --surface @tsonic/js

# existing project
npx --yes tsonic@latest add npm @tsonic/js

Then write natural JS (no explicit @tsonic/js imports required when the workspace surface is @tsonic/js):

export function main(): void {
  const value = JSON.parse<{ x: number }>('{"x": 1}');
  console.log(JSON.stringify(value));
}

Direct imports from @tsonic/js/index.js remain supported when you want explicit symbols like JSArray or Timers.

Documentation:

Building

dotnet build

Testing

dotnet test

All 500+ tests verify that the runtime matches JavaScript behavior exactly.

NativeAOT Compatibility

This library is fully compatible with .NET NativeAOT, enabling TypeScript code to be compiled to native executables with zero runtime dependencies and fast startup times.

Package

Published as Tsonic.JSRuntime on NuGet.

License

MIT License - see LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Tsonic.JSRuntime:

Package Downloads
Tsonic.Express

Express.js style API surface for .NET and Tsonic.

Tsonic.Nodejs

Node.js API implementation for .NET, enabling TypeScript compiled to C# to use Node.js modules.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.9 208 3/13/2026
0.0.8 114 3/10/2026
0.0.7 100 3/9/2026
0.0.6 115 3/9/2026
0.0.5 112 3/8/2026
0.0.4 109 3/6/2026
0.0.3 108 2/15/2026
0.0.2 115 2/13/2026