npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tsonic/runtime

v0.1.0

Published

TypeScript type definitions for CLR/.NET runtime primitives

Readme

@tsonic/runtime

TypeScript type definitions for CLR/.NET runtime primitives.

Overview

@tsonic/runtime provides branded primitive types that match CLR/.NET types, enabling type-safe interop between TypeScript and .NET while remaining compatible with JavaScript primitives at runtime.

Installation

npm install @tsonic/runtime

Usage

Named Imports (Recommended)

import { int, decimal, bool, long } from "@tsonic/runtime";

const age: int = 42 as int;
const price: decimal = 99.99 as decimal;
const isActive: bool = true as bool;
const timestamp: long = Date.now() as long;

Global/Ambient Types

Add to your tsconfig.json:

{
  "compilerOptions": {
    "types": ["@tsonic/runtime/global"]
  }
}

Or use a triple-slash reference:

/// <reference types="@tsonic/runtime/global" />

const count: int = 10 as int;  // No import needed

Available Types

Integer Types

| Type | CLR Type | Range | Bytes | |------|----------|-------|-------| | sbyte | System.SByte | -128 to 127 | 1 | | byte | System.Byte | 0 to 255 | 1 | | short | System.Int16 | -32,768 to 32,767 | 2 | | ushort | System.UInt16 | 0 to 65,535 | 2 | | int | System.Int32 | -2,147,483,648 to 2,147,483,647 | 4 | | uint | System.UInt32 | 0 to 4,294,967,295 | 4 | | long | System.Int64 | ~-9.2e18 to ~9.2e18 | 8 | | ulong | System.UInt64 | 0 to ~1.8e19 | 8 | | nint | System.IntPtr | Platform-dependent | 4/8 | | nuint | System.UIntPtr | Platform-dependent | 4/8 | | int128 | System.Int128 | 128-bit signed | 16 | | uint128 | System.UInt128 | 128-bit unsigned | 16 |

Floating-Point Types

| Type | CLR Type | Precision | Bytes | |------|----------|-----------|-------| | half | System.Half | 16-bit float | 2 | | float | System.Single | 32-bit float | 4 | | double | System.Double | 64-bit float | 8 | | decimal | System.Decimal | 128-bit decimal | 16 |

Other Types

| Type | CLR Type | Description | |------|----------|-------------| | bool | System.Boolean | Boolean value | | char | System.Char | Single UTF-16 code unit |

How It Works

These types use TypeScript's branded types pattern:

export type int = number & { __brand: "int" };

This provides:

  • Type safety - int and long are not interchangeable
  • Runtime compatibility - Still JavaScript number at runtime
  • Zero overhead - No runtime wrappers or classes
  • IDE support - Full autocomplete and type checking

Examples

Type Safety

import { int, long } from "@tsonic/runtime";

const age: int = 42 as int;
const timestamp: long = Date.now() as long;

// ❌ Type error: Type 'long' is not assignable to type 'int'
const invalid: int = timestamp;

// ✅ Explicit cast required
const valid: int = timestamp as unknown as int;

Collections

import { int, decimal } from "@tsonic/runtime";

const scores: Array<int> = [95, 87, 92].map(x => x as int);
const prices: Array<decimal> = [9.99, 14.99].map(x => x as decimal);

Function Parameters

import { int, bool } from "@tsonic/runtime";

function setAge(age: int): void {
  console.log(`Age set to ${age}`);
}

function isValid(value: int): bool {
  return (value > 0) as bool;
}

setAge(25 as int);
const result: bool = isValid(10 as int);

TypeScript Configuration

For best results, configure TypeScript:

{
  "compilerOptions": {
    "strict": true,
    "types": ["@tsonic/runtime/global"]
  }
}

License

MIT

Related Projects

  • Tsonic - TypeScript to C# compiler
  • tsbindgen - TypeScript declaration generator for .NET assemblies