TypeScript type definitions for the Node.js CLR library.
- Node.js-like APIs for .NET - fs, path, events, http, and more
- camelCase members - TypeScript-friendly naming conventions
- Branded primitive types - Typed numbers via
@tsonic/types - Full type safety - Complete TypeScript declarations
npm install @tsonic/nodejs @tsonic/typesimport type { fs } from "@tsonic/nodejs/nodejs";
// Read file
const content = fs.readFileSync("./package.json", "utf-8");
// Write file
fs.writeFileSync("./output.txt", "Hello from Tsonic!");import type { path } from "@tsonic/nodejs/nodejs";
const fullPath = path.join(__dirname, "config", "settings.json");
const ext = path.extname(fullPath); // ".json"
const dir = path.dirname(fullPath);import type { EventEmitter } from "@tsonic/nodejs/nodejs";
class MyEmitter extends EventEmitter {}
const emitter = new MyEmitter();
emitter.on("data", (chunk) => console.log(chunk));import type { HttpServer, HttpRequest, HttpResponse } from "@tsonic/nodejs/nodejs.Http";- Types: PascalCase (matches .NET)
- Members: camelCase (TypeScript convention)
For CLR/PascalCase naming, use @tsonic/nodejs-pure instead.
To regenerate TypeScript declarations:
./__build/scripts/generate.shPrerequisites:
- .NET 10 SDK installed
tsbindgenrepository at../tsbindgennodejs-clrrepository at../nodejs-clr(built withdotnet build -c Release)
Environment variables:
DOTNET_VERSION- .NET runtime version (default:10.0.0)DOTNET_HOME- .NET installation directory (default:$HOME/.dotnet)
MIT