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

@isopodlabs/typescript

v6.0.1-0

Published

TypeScript is a language for application scale JavaScript development

Readme

Typescript extensions

This document describes the experimental operator overloading and function overload dispatch features added to this TypeScript fork.

Operator Overloading

Operator overloading in this TypeScript fork allows user-defined types to provide custom behavior for operators such as +, -, *, /, comparison, and bitwise operators. The implementation works by transforming operator expressions into method calls on the operand types, if those methods exist.

This feature is enabled with the compiler option operatorOverloading.

Operator-to-Method Mappings

The following mappings are used to resolve operator overloads:

Binary Operators:

| Operator | Left Method | Right Method | |----------|-------------|--------------| | + | add | add | | - | sub | rsub | | * | mul | mul | | / | div | rdiv | | % | mod | rmod | | ** | pow | rpow | | & | and | and | | \| | or | or | | ^ | xor | xor | | << | shl | | | >> | shr | | | >>> | asr | | | < | lt | gt | | <= | le | ge | | > | gt | lt | | >= | ge | le | | == | eq | eq | | != | ne | ne |

Unary Operators:

| Operator | Method | |----------|--------| | ++ | inc | | -- | dec | | + | pos | | - | neg | | ~ | inv | | ! | not |

For comparison, the method cmp may be used, with the result compared to zero (e.g., a.cmp(b) < 0).

How Operator Methods Are Found

When the compiler encounters an operator expression (like a + b), it:

  1. Uses the above mapping to determine the method name(s) to check.
  2. Checks if the left operand's type has a method with that name (using the type checker).
  3. If found, verifies the method signature matches the expected operand types.
  4. If valid, rewrites the operator expression as a method call (e.g., a.add(b)).
  5. For some operators, also checks the right operand for a corresponding method (e.g., rsub for right-side subtraction).
  6. For comparison operators, may also check for a cmp method and rewrite as a comparison against zero (e.g., a.cmp(b) < 0).
  7. If no suitable method is found, the operator behaves as usual.

Example

class Point {
    x: number;
    y: number;

    add(other: Point): Point {
        return new Point(this.x + other.x, this.y + other.y);
    }
}

const p1 = new Point(1, 2);
const p2 = new Point(3, 4);
const p3 = p1 + p2; // Transformed to p1.add(p2) if 'add' exists

Notes

  • Operator overloads are resolved at compile time by checking for matching methods on operand types.
  • Only supported operators (see implementation mapping) can be overloaded.
  • If no matching method is found, the operator behaves as in standard TypeScript.

Function Overload Dispatch

Function overload dispatch in this fork enables selection of function implementations based on argument types. It works by generating mangled function names for each overloaded implementation, and rewriting calls to use the correct implementation. Functions (or methods) with multiple signatures but only a single implementation work as before.

This feature is enabled with the compiler option functionOverloadDispatch.

How Name Mangling Works

For each overloaded function or method, a mangled name is generated using the base name and a suffix encoding the parameter types:

  • n for number
  • s for string
  • b for boolean
  • i for bigint
  • u for undefined
  • 0 for null
  • v for void
  • a for any
  • x for unknown
  • A... for array types
  • T... for tuple types
  • F... for function types
  • O... for object types (with class/interface name if available)
  • U... for union types
  • I... for intersection types

For example, foo(x: number) becomes foo$n, and foo(x: string, y: number[]) becomes foo$sAn.

At call sites, the compiler determines the argument types and rewrites the call to the correct mangled function name.

Example

function foo(x: number): number { /* ... */ }
function foo(x: string): string { /* ... */ }

foo(42);    // Transformed to foo$n(42)
foo("hi"); // Transformed to foo$s("hi")

Notes

  • Overload resolution is performed at compile time using type information.
  • Function and method implementations are renamed to unique mangled names.
  • See src/compiler/transformers/functionOverloadDispatch.ts for implementation details.

Using Both Features Together

When both operator overloading and function overload dispatch are enabled, operator methods themselves can be overloaded and mangled. For example, you can provide multiple overloads for an operator method such as add, and the correct overload will be selected and mangled based on the operand types.

Example:

class Point {
    x: number;
    y: number;

    add(other: Point): Point { /* ... */ }
    add(other: number): Point { /* ... */ }
}

const p = new Point(1, 2);
p + p;      // Transformed to p.add$OPoint(p)
p + 5;      // Transformed to p.add$n(5)

This allows for highly flexible operator overloading, with dispatch based on operand types.

Feedback

Please report issues or suggestions via the repository's issue tracker.


For general TypeScript documentation and usage, see the official README:

View the original TypeScript README on GitHub

TypeScript

CI npm version Downloads OpenSSF Scorecard

TypeScript is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the playground, and stay up to date via our blog and Twitter account.

Find others who are using TypeScript at our community page.

Installing

For the latest stable version:

npm install -D typescript

For our nightly builds:

npm install -D typescript@next

Contribute

There are many ways to contribute to TypeScript.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Documentation

Roadmap

For details on our planned features and future direction, please refer to our roadmap.