@tsonic/dotnet
v10.0.41
Published
TypeScript type definitions for .NET 10 BCL (Base Class Library)
Maintainers
Readme
@tsonic/dotnet
TypeScript declarations and CLR binding metadata for the .NET 10 base class library.
@tsonic/dotnet is a generated binding package. It gives Tsonic projects an
importable TypeScript surface for Microsoft.NETCore.App assemblies while the
compiled program still targets the real .NET runtime assemblies.
Install
npm install @tsonic/dotnet @tsonic/coreUse with Tsonic
Default CLR workspaces include the BCL binding package in the normal compiler setup. Import CLR namespaces explicitly:
import { Console } from "@tsonic/dotnet/System.js";
import { List } from "@tsonic/dotnet/System.Collections.Generic.js";
import type { int } from "@tsonic/core/types.js";
export function main(): void {
const values = new List<int>();
values.Add(42);
Console.WriteLine(values.Count.ToString());
}Package shape
The package exposes one ESM facade per CLR namespace plus compiler metadata:
@tsonic/dotnet/
System.d.ts
System.js
System/
bindings.json
internal/index.d.ts
System.Collections.Generic.d.ts
System.Collections.Generic.js
System.Collections.Generic/
bindings.json
internal/index.d.ts
__internal/extensions/index.d.ts
families.json<Namespace>.d.tsis the public import facade.<Namespace>.jsis an ESM stub for package resolution.<Namespace>/internal/index.d.tscontains the full generated declaration surface.<Namespace>/bindings.jsoncarries CLR identity, overload, receiver, extension, nullable, and generic metadata for the Tsonic compiler.__internal/extensions/index.d.tscontains generated extension-method wrapper types used for C#-styleusingsemantics.families.jsonrecords multi-arity type families such asFunc,Action, andValueTuple.
Type model
- CLR type and member names are emitted with CLR-faithful casing.
- CLR primitives use
@tsonic/core/types.jsaliases such asint,long,double,bool, andchar. - Generic CLR names keep their arity-safe declarations, with facade aliases for common families.
- Delegates emit callable TypeScript types.
TaskandValueTaskare thenable in TypeScript positions.- Extension methods are available through generated
ExtensionMethodshelpers.
Example extension-method wrapper:
import type { ExtensionMethods as Linq } from "@tsonic/dotnet/System.Linq.js";
import type { IEnumerable } from "@tsonic/dotnet/System.Collections.Generic.js";
import type { int } from "@tsonic/core/types.js";
type LinqEnumerable<T> = Linq<IEnumerable<T>>;
declare const values: LinqEnumerable<int>;
const positive = values.Where((value) => value > 0);Versioning
This repo is versioned by .NET major:
- .NET 10 declarations live under
versions/10/. - The npm package is published as
@tsonic/[email protected].
Development
Regenerate the .NET 10 package from a sibling tsbindgen checkout:
npm install
npm run generate:10The generation script requires:
- .NET 10 SDK/runtime
../tsbindgen- a
Microsoft.NETCore.Appruntime directory selected byDOTNET_HOMEandDOTNET_VERSION
Example for a system install:
DOTNET_HOME=/usr/lib/dotnet DOTNET_VERSION=10.0.5 npm run generate:10License
MIT
