tsbindgen Documentation
tsbindgen generates TypeScript declaration files from .NET assemblies.
Table of Contents
Getting Started
- Getting Started - Installation and first generation
- CLI Reference - Commands and options
Type Generation
- Type Mappings - How CLR types map to TypeScript
- Naming Conventions - CLR vs JavaScript naming
- Library Mode - Generating for custom assemblies
Validation
- Testing - Validation and regression tests
- Troubleshooting - Common issues
Quick Links
- Architecture Documentation - For contributors
- GitHub Repository
Overview
What is tsbindgen?
tsbindgen generates TypeScript declaration files (.d.ts) from .NET assemblies:
.NET Assembly (DLL) -> Reflection -> TypeScript Declarations (.d.ts)
Why tsbindgen?
- Complete BCL Coverage: All 130 namespaces, 4,296 types, 50,675+ members
- Type Safety: Branded primitives, generic constraints preserved
- IDE Support: Full IntelliSense for .NET types in TypeScript
- Dual Naming: CLR PascalCase or JavaScript camelCase
Output Example
// System.Collections.Generic
export interface List_1<T> {
readonly count: int;
add(item: T): void;
remove(item: T): boolean;
clear(): void;
}
export declare const List_1: {
new <T>(): List_1<T>;
new <T>(capacity: int): List_1<T>;
};
Prerequisites
- .NET 10 SDK: For assembly reflection
- Node.js 18+: For validation scripts
Verify installation:
dotnet --version # 10.0.x
node --version # v18.0.0 or higher
Quick Start
# Clone and build
git clone https://github.com/tsoniclang/tsbindgen
cd tsbindgen
dotnet build src/tsbindgen/tsbindgen.csproj
# Generate BCL declarations
dotnet run --project src/tsbindgen/tsbindgen.csproj -- \
generate -d ~/.dotnet/shared/Microsoft.NETCore.App/10.0.0 \
-o ./output