@tsonic/nodejs
v10.0.6
Published
TypeScript type definitions for Node.js CLR library
Maintainers
Readme
@tsonic/nodejs
TypeScript type definitions for the Node.js CLR library.
Versioning
This repo is versioned by .NET major:
- .NET 10 →
versions/10/→ npm:@tsonic/[email protected]
When publishing, run: npm publish versions/10 --access public
Features
- Node.js-like APIs for .NET - fs, path, events, http, and more
- camelCase members - TypeScript-friendly naming conventions
- Primitive aliases -
int,long,decimal, etc. via@tsonic/core - Full type safety - Complete TypeScript declarations
Installation
npm install @tsonic/nodejs @tsonic/dotnet @tsonic/coreUsage
File System
import { fs } from "@tsonic/nodejs/index.js";
// Read file
const content = fs.readFileSync("./package.json", "utf-8");
// Write file
fs.writeFileSync("./output.txt", "Hello from Tsonic!");Path Operations
import { path } from "@tsonic/nodejs/index.js";
const fullPath = path.join("config", "settings.json");
const ext = path.extname(fullPath); // ".json"
const dir = path.dirname(fullPath);Events
import { EventEmitter } from "@tsonic/nodejs/index.js";
class MyEmitter extends EventEmitter {}
const emitter = new MyEmitter();
emitter.on("data", (chunk) => console.log(chunk));HTTP
import { http } from "@tsonic/nodejs/nodejs.Http.js";Documentation
docs/README.md- https://tsonic.org/nodejs/
Naming Conventions
- Types: PascalCase (matches .NET)
- Members: camelCase (TypeScript convention)
To generate CLR/PascalCase member names, regenerate with --naming clr (or omit --naming js).
Development
Regenerating Types
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)
License
MIT
