Open Source — MIT License

SharpTS

A TypeScript interpreter and AOT compiler for .NET

Run it as a script for instant feedback, or compile it to a native .NET assembly — with full access to the .NET ecosystem.

$ dotnet tool install -g SharpTS
Star on GitHub
example.ts
// Run TypeScript directly on .NET
interface Greeter {
    greet(name: string): string;
}

class WelcomeBot implements Greeter {
    constructor(private prefix: string) {}

    greet(name: string): string {
        return `${this.prefix}, ${name}! Welcome to SharpTS.`;
    }
}

const bot = new WelcomeBot("Hello");
console.log(bot.greet("Developer"));
// → Hello, Developer! Welcome to SharpTS.

What SharpTS Does

Write TypeScript that runs on the .NET runtime — interpreted for quick iteration, or compiled to native .NET assemblies.

Run it instantly

Point SharpTS at a .ts file and it runs — no build step, no config. Ideal for scripts, automation, and trying ideas in the REPL.

Compile to .NET

Ahead-of-time compile to a real .NET assembly — a DLL, a self-contained executable, or a NuGet package — running at native CLR speed.

Interop both ways

Call .NET libraries from TypeScript with @DotNetType, and use your compiled TypeScript from C#. Reuse the BCL, NuGet packages, and code you already have.

Real TypeScript

Not a subset — the real language: generics, classes, decorators, async, modules, and more, all type-checked before your code runs. See the full support matrix below.

Fits your .NET build

Drop the SharpTS.Sdk into a .NET project and dotnet build compiles your TypeScript alongside your C# — same toolchain, same output.

Editor support

A language server brings autocomplete, type checking, and go-to-definition to VS Code and Visual Studio.

See It In Action

Real TypeScript running on the .NET runtime

const greeting: string = "Hello from SharpTS!";
const version: number = 1.0;
console.log(`${greeting} v${version}`);

const languages = ["TypeScript", "C#", ".NET"];
languages.forEach(lang => console.log(`  ✓ ${lang}`));
Output
Hello from SharpTS! v1
  ✓ TypeScript
  ✓ C#
  ✓ .NET

Want to run your own? Open the Playground ↓

When SharpTS Fits

Concrete situations where TypeScript on .NET beats reaching for Node — or for C#.

Scripts and automation for .NET teams

Write build scripts, dev tools, and one-off automation in TypeScript with the whole BCL available — on machines that already have the .NET SDK and no Node toolchain. No package.json, no build step: point sharpts at the file.

Terminal
sharpts rotate-logs.ts

Ship TypeScript logic as a .NET library

Compile a TypeScript module to a real assembly and publish it as a versioned NuGet package. With a reference assembly, C# callers instantiate your classes and call your methods fully typed.

Terminal
sharpts --compile pricing.ts --ref-asm
sharpts --compile pricing.ts --pack

TypeScript developers in a .NET codebase

Let TypeScript-first teammates contribute in the language they know best. With SharpTS.Sdk, their .ts files build inside the same dotnet build as the C# projects around them — one toolchain, one CI pipeline.

app.csproj
<Project Sdk="SharpTS.Sdk/1.0.0">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <SharpTSEntryPoint>src/main.ts</SharpTSEntryPoint>
  </PropertyGroup>
</Project>

Self-contained command-line tools

Compile to a single self-contained executable that runs without a separate runtime install — no Node on the target machine, no node_modules folder shipped next to your tool.

Terminal
sharpts --compile tool.ts -t exe
./tool

How It Works

A multi-stage pipeline from source to execution

Source Lexer Parser TypeChecker Interpreter IL Compiler
Learn how it works

Interactive Playground

Write TypeScript and run it on .NET — right in your browser

Output
Click Run or press Ctrl+Enter to execute

What's Supported

The TypeScript you already write — feature by feature.

Type System

Feature Status Notes
Primitive types Implemented
Generics Implemented Full support with constraints
Union & Intersection types Implemented
Literal types Implemented
Tuple types Implemented Optional, rest, and named elements
Conditional types Implemented infer keyword, distribution
Mapped types Implemented keyof, indexed access
Template literal types Implemented
Utility types Implemented Partial, Required, Pick, Omit, etc.

Classes & OOP

Feature Status Notes
Classes & inheritance Implemented
Access modifiers Implemented
Abstract classes Implemented
Getters/Setters Implemented
Private fields (#field) Implemented
Static blocks Implemented
Decorators Implemented Legacy & TC39 Stage 3
Method overloading Implemented

Functions & Async

Feature Status Notes
Arrow functions Implemented
Rest/spread Implemented
Closures Implemented
async/await Implemented
Promise.all/race/any Implemented
Generators (function*) Implemented
Async generators Implemented
for await...of Implemented

Modules

Feature Status Notes
import/export Implemented
Default exports Implemented
Namespace imports Implemented
Dynamic imports Implemented
TypeScript namespaces Implemented
import type Implemented
Module augmentation Implemented

Built-in APIs

Feature Status Notes
console.log Implemented Printf-style format specifiers
Math object Implemented
String methods Implemented 40+ methods
Array methods Implemented 50+ methods
Map/Set Implemented ES2025 Set operations
RegExp Implemented
Date Implemented
JSON Implemented
Promise Implemented
Symbol Implemented
Proxy Missing
WeakRef Missing

Advanced

Feature Status Notes
using/await using Implemented TS 5.2+ resource management
satisfies operator Implemented
Const type parameters Implemented
bigint type Implemented
TypedArrays Implemented
SharedArrayBuffer/Atomics Implemented

Frequently Asked Questions

The questions that come up first — answered straight.

How is SharpTS different from tsc?

tsc type-checks your code and emits JavaScript for an engine like Node to run. SharpTS never produces JavaScript: it type-checks the same TypeScript, then either executes it directly or compiles it to a .NET assembly. There is no Node anywhere in the chain — the only prerequisite is the .NET SDK.

Why not embed a JavaScript engine like Jint or ClearScript?

Those projects run plain, untyped JavaScript inside a .NET host — a great fit for small embedded scripts. SharpTS runs TypeScript itself, type-checked before execution, and adds what an embedded JS engine can't: ahead-of-time compilation to IL, NuGet packaging, and typed interop in both directions between TypeScript and C#.

Can I use npm packages?

Partially. Bare imports resolve through node_modules, so packages that ship TypeScript source can work, and a growing set of Node built-ins — fs, path, process, buffer, events, streams — is implemented natively on .NET. Packages that ship plain JavaScript or rely on package.json exports maps aren't supported yet.

See the Node.js compatibility tracker →
Is it fast?

Each mode answers differently. The interpreter is a tree-walker tuned for instant startup — right for scripts and the REPL, not for number crunching. Compiled mode emits IL that the CLR JIT-compiles like any C# assembly, so it runs as native .NET code. In both modes, types are checked up front and then erased — they cost nothing at runtime.

How mature is SharpTS?

It's a young, MIT-licensed project under active development. The support matrix above is the honest picture: most of the modern language works, and the gaps — like Proxy and WeakRef — are listed rather than hidden.

Follow progress in STATUS.md →

Get Started

Up and running in three steps

1

Install

Install SharpTS as a .NET global tool

Terminal
dotnet tool install -g SharpTS
2

Write

Create a TypeScript file

hello.ts
interface Config {
    name: string;
    debug: boolean;
}

const config: Config = { name: "MyApp", debug: true };
console.log(`Starting ${config.name}...`);
3

Run

Interpret directly or compile to a .NET assembly

Terminal
# Interpret (instant startup)
sharpts hello.ts

# Compile to .NET assembly
sharpts --compile hello.ts -o hello