tsover

Getting Started

How to get setup with tsover

After completing this guide, overloaded operators will be available within 'use tsover' marked scopes.

'use tsover'; // a directive that allows use of overloaded operators

import {  } from './vec2f.ts';

const  = new (1, 2);
const  = new (3, 4);

const c =  + ;
const c: Vec2f
function () { 'use tsover'; // you can also be more granular, and mark functions return + ; }

Installation

The tsover package is a drop-in replacement for TypeScript, and to install it, first change what typescript points to in your package.json file.

package.json
{
  "devDependencies": {
    "typescript": "^5.9.3"
    "typescript": "npm:tsover@latest"
  }
}

Instead of @latest, consider pinning a version where major.minor matches between tsover and typescript, for example:

  • typescript@5.9.3 => tsover@5.9.x

There could be other packages that depend on typescript, so it is best to override them as well.

package.json
{
  "overrides": {
    "typescript": "npm:tsover@latest"
  }
}

In a monorepo setup, overrides/resolutions should be defined in the root package.json file.

tsconfig.json

All additional tsover functionality is enabled only when "tsover" is included as a lib in your tsconfig.json file.

tsconfig.json
{
  "compilerOptions": {
    "lib": ["tsover" /*...*/]
  }
}

Editor setup

IDE support was one of the main driving forces behind the creation of tsover, and to enable it, you need to configure your editor to use tsover instead of typescript.

VS Code / Cursor / Windsurf / Antigravity

For VS Code and its forks, just make sure you're using the Workspace version of TypeScript. You can do so by opening up the command palette (Ctrl+Shift+P) and searching for TypeScript: Select TypeScript Version. Then, select Use Workspace Version.

In case that doesn't work, ensure that the typescript.tsdk setting is set to the correct path in .vscode/settings.json:

{
  "typescript.tsdk": "node_modules/typescript/lib"
}

Zed

To configure vtsls, change settings in your Zed settings file:

// .zed/settings.json
{
  "lsp": {
    "vtsls": {
      "settings": {
        "typescript": {
          "tsdk": "node_modules/typescript/lib",
        },
      },
    },
  },
  // ...
}

If instead you're using typescript-language-server, change your settings file to the following

// .zed/settings.json
{
  "lsp": {
    "typescript-language-server": {
      "settings": {
        "typescript": {
          "tsdk": "node_modules/typescript/lib",
        },
      },
    },
  },
  // ...
}

Code Transform

If you're using TypeGPU, its bundler plugin unplugin-typegpu already handles operator overloads that are placed inside 'use gpu' marked functions.

Unless you want overloaded operators to work outside of 'use gpu' marked functions, you can skip this step.

While tsover enables TypeScript to understand operator overloads, the target runtime must support them as well. A bundler plugin is shipped as part of the tsover package, which can be used to transform your code into a format that supports operator overloads.

Vite

import { defineConfig } from 'vite';
import tsover from 'tsover/plugin/vite';

export default defineConfig({
  plugins: [tsover()],
});

Rollup

import { defineConfig } from 'rollup';
import tsover from 'tsover/plugin/rollup';

export default defineConfig({
  plugins: [tsover()],
});

Rolldown

import { defineConfig } from 'rolldown';
import tsover from 'tsover/plugin/rolldown';

export default defineConfig({
  plugins: [tsover()],
});

On this page