TypeScript language runtime primitives for the Tsonic compiler - provides Union types, structural typing, and other TypeScript language features in C#.
Tsonic.Runtime contains mode-independent TypeScript language primitives that are used in all Tsonic compilation modes. This library provides:
- Union Types -
Union<T1, T2, ...>for TypeScript unions likestring | number - Structural Typing -
Structural.Clone<T>()andDictionaryAdapter<T>for duck typing - Dynamic Objects -
DynamicObjectfor TypeScript'skeyofand indexed access patterns - Operators -
typeofandinstanceofoperator support
This library is referenced by all Tsonic projects.
- CLR/default-surface projects use
Tsonic.Runtime - First-party source surfaces such as
@tsonic/js,@tsonic/nodejs, and@tsonic/expressalso useTsonic.Runtime
JavaScript and Node surface behavior is authored in first-party TypeScript source packages, not in separate CLR runtime packages:
- Array methods (push, pop, map, filter, etc.)
- String methods (toUpperCase, slice, includes, etc.)
- Math, console, JSON, global functions
dotnet builddotnet testThis library is fully compatible with .NET NativeAOT, enabling TypeScript code to be compiled to native executables.
Published as Tsonic.Runtime on NuGet.
MIT License - see LICENSE file for details.