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.

curl -fsSL https://sharpts.dev/setup.sh | sh
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.

Broad TypeScript support

Use familiar TypeScript — generics, classes, decorators, async, modules, and more — with types checked before your code runs. See the practical compatibility overview 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

SourceLexerParserTypeCheckerInterpreterIL 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

A practical overview of the TypeScript and runtime surface you can use today. For measured detail, explore Conformance.

Everyday TypeScript

Classes, generics, unions, decorators, modules, async/await, and modern type-system features are supported across SharpTS workflows.

Standard runtime

Common Array, String, collection, Promise, Date, RegExp, JSON, Symbol, and typed-array APIs are available.

Packages & Node.js

Bare imports and package exports/imports can resolve, but packages still depend on SharpTS-compatible syntax and runtime APIs. TypeScript-source packages are the strongest fit.

Known limitations

Proxy and WeakRef are not implemented. Interpreter and AOT results can also differ on specification edge cases.

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 setup script uses the .NET SDK when available or installs a self-contained build when it is not.

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, and supported module-resolution modes can apply package exports/imports and conditional targets. Packages can still fail when they rely on unsupported syntax, native add-ons, browser globals, or missing runtime APIs. Packages that ship TypeScript source are the strongest fit.

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 compatibility overview above summarizes common capabilities, measured Conformance publishes the detailed evidence, and STATUS.md tracks implementation gaps.

Follow progress in STATUS.md →

Get Started

Up and running in three steps

1

Install

Run the setup script to install the best SharpTS build for this machine

curl -fsSL https://sharpts.dev/setup.sh | sh
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