Releases: nickna/SharpTS
v1.0.7
SharpTS v1.0.7 Release Notes
Highlights
This release brings significant performance improvements, enhanced TypeScript language support, and expanded Node.js module compatibility.
Performance Improvements
RuntimeValue Boxing Elimination
- Introduced
RuntimeValuestruct (24-byte discriminated union) to store primitives inline, eliminating boxing overhead for common operations - Added
ISharpTSCallableV2interface supporting RuntimeValue throughout the call stack - Updated
BuiltInMethodto leverage RuntimeValue for reduced allocations
Method Reference Caching
- Cached
MethodInfoand constructor references throughout the runtime emitter - Optimized closure variable capture with static member access caching
- Enhanced method/getter/setter lookup caching in
SharpTSClass
Interpreter Optimizations
- Variable assignment now uses reference retrieval for improved performance
- Pooled argument lists reduce allocations during function calls
- Timer management refactored to use
PriorityQueuefor efficient scheduling - Type compatibility checks now use identity-based caching
Compiler Optimizations
- Constant folding for binary, unary, and logical expressions
- String concatenation optimized with
String.Concat ForLoopAnalyzerenables unboxed counter optimization in for loops- Typed return type resolution for arrow functions reduces boxing
Event Loop Performance
Contributed by @jeremylcarter
- Refactored event loop to use blocking callback queue with
SynchronizationContextdispatch - Benchmarks show ~10x improvement in HTTP server throughput
Language Enhancements
Control Flow Type Narrowing
- Path-based type narrowing with control flow graph construction
- Loop narrowing analysis with escape analysis
- Property null checks and type guards
- Aliasing awareness for accurate narrowing
New Language Features
usingdeclaration support with proper disposal handling- Generator methods with full parser validation
- Async generator methods with state machine emission
- Symbol support with global registry and description property
- Strict mode enforcement (variable deletion errors, duplicate parameters, octal literals)
- Private class fields/methods accessible in async contexts
- Static block support in classes
- Optional and rest parameters in function type annotations
ES2023 Array Methods
Array.prototype.findLast()andfindLastIndex()Array.prototype.toReversed()andwith()Array.prototype.at()with negative index support
Node.js Module Improvements
New Modules
| Module | Description |
|---|---|
buffer |
Full Buffer implementation with multi-byte read/write operations |
zlib |
Compression support (gzip, deflate, brotli, zstd) |
dns |
DNS lookup and service resolution |
stream |
Writable and Transform stream classes |
readline |
Interface and exports |
Enhanced Modules
| Module | Additions |
|---|---|
crypto |
HKDF, PBKDF2, scrypt, RSA, HMAC, signing/verification, timing-safe comparison |
util |
promisify, TextEncoder/TextDecoder, type helpers, ANSI stripping |
events |
Full EventEmitter implementation |
fs |
File descriptor APIs, directory utilities, hard links, Unix-specific operations |
os |
loadavg and networkInterfaces |
path |
Platform-specific POSIX and Win32 methods |
console |
printf-style format specifiers, indentation support |
Other Runtime Improvements
- HTTP server implementation with EventEmitter support
- Promise executor function support with improved rejection stack traces
import.metanow includesfilenameanddirnameproperties
Bug Fixes
- Method chaining on new expressions - Patterns like
new Date().toISOString()now parse correctly (contributed by @jeremylcarter) - Fixed exception handling with dedicated
CompileExceptionandInterpreterExceptiontypes - Normalized line endings in test output assertions
- Fixed inherited constructor handling for generic types in IL compiler
- Corrected frozen/sealed array mutation checks to throw TypeError
v1.0.6
Release Notes - v1.0.6
Highlights
This release introduces a comprehensive timer system (setTimeout, setInterval), ES2022 private class elements, CommonJS module support, resource management (using/await using), type predicates, and many type system enhancements.
Timer System
Full implementation of JavaScript timer APIs with proper main-thread execution:
setTimeout/clearTimeout- Delayed callback executionsetInterval/clearInterval- Repeating callback executionglobalThis- ES2020 global object support with property access and method calls- Virtual timer system - Main thread execution to avoid scheduling issues across platforms
- Automatic cleanup - Timer registration for proper disposal on interpreter shutdown
- Thread synchronization - Callback execution synchronized with interpreter's main thread
ES2022 Private Class Elements
Full support for private class members in both interpreter and IL compiler:
- Private fields -
#fieldsyntax with proper encapsulation - Private methods -
#method()with access checks - IL compiler support - Complete implementation including initialization and access validation
Class Enhancements
- Auto-accessor fields - TypeScript 4.9+
accessorkeyword support declarefield modifier - For ambient class field declarations- Static blocks - Class-level static initialization blocks
- Constructor signatures in interfaces - Enhanced type checking support
- Function type members - Support for function-typed class members
- Bound function constructor restriction - Enforced as per spec
Module System
- CommonJS support -
require()andmodule.exportssyntax with module dependency management - Triple-slash references -
/// <reference path="..." />for script-style file concatenation - Module/global augmentations - Declaration merging support
- Enhanced export handling - Improved static member resolution for imported classes
Resource Management
usingdeclarations - Explicit resource management for synchronous disposablesawait usingdeclarations - Async resource management with proper cleanup
Type System Enhancements
- Type predicates -
x is Typereturn type annotations with multi-parameter narrowing satisfiesoperator - TypeScript 4.9 expression-level type validation- Unique symbol types -
unique symbolsupport with predefined well-known symbols objecttype - Proper TypeScriptobjecttype with enhanced compatibility checks- Recursive type aliases - Self-referential type definitions
- Variance annotations -
in/outmodifiers for generic type parameters - Const type parameters -
constmodifier for generic parameters - Variadic tuples - Enhanced tuple type compatibility with spread support
Language Features
- Tagged template literals - Custom string processing with tag functions
String.raw- Raw string access for tagged templates- Named function expressions - Proper recursion and scoping for
const f = function name() {}
Array Methods
splice()/toSpliced()- Mutable and immutable array element replacementsort()/toSorted()- Mutable and immutable sorting with JS-compliant undefined handling
Testing & Quality
- CLI integration tests - Comprehensive tests for compilation, error handling, and script execution
- Negative compiler tests - Resilience testing against malformed input
- Parity tests - Built-in module compatibility verification
- End-to-end packaging tests - Full
--packworkflow validation
Infrastructure Improvements
- ClassRegistry - Refactored class member management
- OperatorDescriptor - Centralized operator semantics with enhanced type checking
- CommandLineParser - Proper command-line argument parsing with help messages
- TypeScript declaration generation - Enhanced support for nested types and obsolete attributes
$Hashclass - Standalone crypto method wrappers
Bug Fixes & Refactoring
- Removed redundant runtime DLL copy in compiled execution
- Improved variable type handling for self-referential callbacks
- Normalized path separators for cross-platform compatibility
- Simplified async evaluation methods
- Enhanced error reporting in Lexer
- Fixed simple class name null checks in type-checker
Full Changelog: v1.0.5...v1.0.6
v1.0.5
Release Notes - v1.0.5
Highlights
This release brings major advancements, including Node.js built-in module support, async generators, class expressions, full iterator protocol, and significant compiler improvements.
Node.js Built-in Modules
Full or partial implementations of Node.js core modules:
- fs - File system operations with named imports
- path - Path manipulation utilities
- process - Process info, stdin/stdout/stderr streams, argv
- crypto - Cryptographic functions and hash support
- util - Utility functions
- readline - Interactive input
- child_process - Spawn child processes
- querystring - Query string parsing
- url - URL parsing and manipulation
- assert - Assertion testing
Async/Await & Generators
- Async generators - Full IL compiler support for
async function* - Iterator protocol - Custom iterators with
$IteratorWrapperclass - Generator improvements - Hoisted enumerator support, outer variable capture
- Promise enhancements -
Promise.anysupport, proper nested Promise flattening
Class & Type System
- Class expressions - Full support in both interpreter and IL compiler
- Conditional types -
T extends U ? X : Ysyntax - Template literal types - Intrinsic string manipulations (
Uppercase,Lowercase, etc.) - Generic type aliases - Enhanced generic handling with array suffixes
- TypeScript utility types -
Partial,Required,Readonly,Record,Pick,Omit,ReturnType,Parameters,ConstructorParameters,InstanceType,ThisType,Awaited,NonNullable,Extract,Exclude - Union types - Improved handling with implicit conversions and
IUnionTypeinterface - Interface inheritance - Proper propagation during type-checking
- Control flow type narrowing - Termination analysis in TypeChecker
Language Features
- Strict mode -
"use strict"directive support - Dynamic imports -
import()with module registry import.meta- Access to module metadataas const- Const assertions- Import aliases -
import { x as y }declarations - Non-null assertion -
!operator support - Decorators - .NET attributes via TypeScript decorators (
@attribute) - Logical assignment operators -
&&=,||=,??= - Numeric separators -
1_000_000syntax - Optional catch binding -
catch { }without parameter typeofandkeyof- Operators in type expressions
Object & Array Methods
Object.freeze(),Object.seal(),Object.isFrozen(),Object.isSealed()Object.assign(),Object.fromEntries(),Object.hasOwn()Array.of(),Array.from()- Variadic
push(), enhancedsplit()with limit parameter
Runtime Improvements
- WeakMap and WeakSet - Validation and runtime emitter support
- Error class - Full implementation with subtypes (
TypeError,RangeError, etc.) $TSDateclass - Date handling support$Undefinedsingleton - Proper undefined handling- BigInt - Centralized handling with compound operators
Compiler (IL) Improvements
- ValidatedILBuilder - Refactored into multiple files with validation
- StateMachineEmitHelpers - Centralized state machine emission logic
- ExpressionEmitterBase / StatementEmitterBase - Unified emission patterns
- LocalVariableResolver - Improved variable access handling
- Type provider pattern - Better type resolution in RuntimeEmitter
- Performance - Memoization for type compatibility checks, cached union/intersection types
CLI & Developer Experience
--helpand--version- CLI commands- Output targets - Support for both DLL and EXE compilation
- Improved error handling - Better compile command errors and usage instructions
Performance Optimizations
- String concatenation using
string.Concat - Cached flattened types in Union/Intersection records
- Memoization for type compatibility checks
- Centralized primitive type mappings
Bug Fixes
startsWithandendsWithin IL compilation- Binding logic for
SharpTSFunctionin iterator handling - Parser error handling and recovery improvements
- Namespace merging for nested namespaces
- Null safety in argument handling
Full Changelog: v1.0.4...v1.0.5
v1.0.4
SharpTS v1.0.4 Release Notes
Release Date: January 11, 2026
This release introduces full .NET interoperability, thread-safety primitives, improved error reporting, and significant internal refactoring for maintainability.
New Features
.NET Interoperability
SharpTS can now directly consume .NET types from TypeScript code:
@DotNetTypedecorator - Map TypeScript classes to .NET types for seamless interopdeclare classsyntax - Declare .NET types in TypeScript with full type safety--gen-declCLI option - Auto-generate TypeScript declarations from .NET assemblies-r/--referenceoption - Reference external .NET assemblies at compile time- Overload resolution - Automatic .NET method overload selection based on argument types
- Type conversion - Seamless conversion between TypeScript and .NET types
@DotNetType("System.Text.StringBuilder")
declare class StringBuilder {
constructor();
Append(value: string): StringBuilder;
ToString(): string;
}
const sb = new StringBuilder();
sb.Append("Hello, ").Append(".NET!");
console.log(sb.ToString());Thread-Safety with @lock
New @lock decorator for thread-safe method execution:
- Works with both instance and static methods
- Reentrancy-safe using Monitor and AsyncLocal
- Prevents race conditions in concurrent scenarios
class Counter {
private count = 0;
@lock
increment(): void {
this.count++;
}
}Improved Error Reporting
Structured exception hierarchy with precise error locations:
TypeMismatchException- Type incompatibility errorsInvalidCallException- Invalid function/method callsTypeOperationException- Invalid type operationsUndefinedMemberException- Missing property/method access
All exceptions now include line and column information for better debugging.
TypeScript-Style Excess Property Checking
Object literals are now validated against their expected types:
interface Point { x: number; y: number; }
const p: Point = { x: 1, y: 2, z: 3 }; // Error: 'z' does not exist on type 'Point'Improvements
Performance Optimizations
- Property lookup caching in class instances
- FrozenDictionary/FrozenSet for immutable type collections
- Optimized reflection with caching strategies
- Improved BigInteger emission and locals management
Compiler Enhancements
- Type-first dispatch for built-in TypeScript types
- Refactored class type handling with MutableClass builder
- Improved value type handling in IL emission
- Better argument conversion for .NET interop
Infrastructure
MSBuild SDK
New SharpTS.Sdk package for MSBuild integration:
- Custom
ReadTsConfigTaskfor tsconfig.json parsing - Seamless integration with .NET build pipelines
- Automatic TypeScript compilation during build
Benchmarks Project
Added SharpTS.Benchmarks for performance testing and regression tracking.
Internal Refactoring
Major code organization improvements for maintainability:
- Split large classes into partial files for better navigation
- Converted exception-based control flow to
ExecutionResultpattern - Refactored analyzers to use visitor pattern
- Reorganized IL emitters by domain (Arrays, Objects, Promises, JSON, etc.)
Upgrading from v1.0.3
This release is backwards compatible with existing TypeScript code. Note these changes:
- Exception types - If you catch SharpTS exceptions programmatically, update to use the new structured exception types
- Excess property checking - Object literals with extra properties will now produce type errors
Documentation
Full Changelog: v1.0.3...v1.0.4
v1.0.3
SharpTS v1.0.3
Announcing SharpTS v1.0.3! This release brings major new language features, significant performance improvements, and important bug fixes.
What's New
Async/Await & Promises
Full async/await support is here! Write asynchronous TypeScript code that compiles to native .NET async state machines:
async/awaitkeywordsPromise<T>with.then(),.catch(),.finally()Promise.all(),Promise.race(),Promise.any(),Promise.allSettled()
Module System
Build multi-file TypeScript projects with ES6-style modules:
import/exportwith named, default, and namespace imports- Dynamic
import()expressions - Multi-module compilation support
Generators & Iterators
Create custom iterables with generator functions:
function*generator syntaxyieldexpressions- Iterator protocol support
New Built-in Types
- RegExp - Regular expression support
- Date - Full Date object implementation
- Map/Set - Collection types
- BigInt - Arbitrary precision integers
- Symbol - Unique identifiers as object keys
Advanced Type Features
- Decorators - Legacy and TC39 Stage 3 decorator support
- Namespace declarations - Organize code into namespaces
- Mapped types - Transform types programmatically
- Abstract classes - Define class contracts
- Intersection types - Combine multiple types
- Method overloading - Multiple signatures for methods
- Const enums - Compile-time enum inlining
- Computed property names - Dynamic property keys
C# Interop
Generate reference assemblies for seamless C# consumption:
sharpts --compile mylib.ts --ref-asmYour TypeScript classes become strongly-typed C# classes!
Performance Improvements
- Numeric boxing optimization - Numeric values stay unboxed through arithmetic chains
- Type-aware method dispatch - Direct calls for known types skip dynamic lookup
- Dead code elimination - Unused code is automatically removed from output
- Stack type tracking - Improved IL generation reduces unnecessary operations
Bug Fixes
- Fixed
Math.round()to match JavaScript behavior - Fixed
thisbinding in object methods during IL compilation - Fixed Promise callback handling in compiled code
- Fixed increment/decrement on properties and array indices
- Fixed cross-platform assembly reference resolution
- Fixed various IL stack type tracking issues
Getting Started
Install via NuGet (recommended)
dotnet tool install -g SharpTSUpgrade existing installation
dotnet tool update -g SharpTSRun your first script
sharpts script.ts # Interpret
sharpts --compile script.ts # Compile to .NETResources
Full Changelog: v1.0.2...v1.0.3
v1.0.2
🎉 Initial Release
SharpTS v1.0.2 is the first release of a TypeScript interpreter and ahead-of-time compiler written in C#.
Highlights
- Dual Execution Modes: Tree-walking interpreter for rapid development and AOT compilation to native .NET assemblies
- TypeScript Language Support: Types, arrays, objects, classes, interfaces, functions, control flow, and error handling
- Static Type Checking: Comprehensive type validation with nominal typing for classes and structural typing for interfaces
- Built-in Features:
console.log,Mathobject, string/array methods, and more - CI/CD: GitHub Actions workflow for automated NuGet package publishing
Getting Started
# Install from NuGet
dotnet tool install --global SharpTS
# Run TypeScript file
dotnet run -- script.ts
# Compile to .NET assembly
dotnet run -- --compile script.tsSee the README for full documentation.
Full Changelog: https://github.com/nickna/SharpTS/commits/v1.0.2