Skip to content

Latest commit

 

History

4,433 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharpTS

SharpTS is a TypeScript interpreter and ahead-of-time compiler written in C# for .NET 10. It parses and type-checks TypeScript directly, then either executes the syntax tree or emits .NET IL; there is no JavaScript transpilation step.

NuGet License: MIT .NET

Install

Install the command-line tool from NuGet:

dotnet tool install --global SharpTS

Self-contained managed and Native AOT binaries are also published on GitHub Releases. See the Native AOT guide before choosing the native build because it deliberately has a smaller interop and tooling surface.

Interpret TypeScript

Create hello.ts:

interface Greeting {
  name: string;
}

const greeting: Greeting = { name: "SharpTS" };
console.log(`Hello, ${greeting.name}!`);

Run it directly:

sharpts hello.ts

Running sharpts without a file starts the interactive REPL.

Compile to .NET

Compile the same program to a runnable .NET assembly:

sharpts --compile hello.ts -o hello.dll
dotnet hello.dll

Use --target exe for an executable target, or the SharpTS.Sdk MSBuild SDK for repeatable .NET project builds. Compiled output embeds the runtime it needs and only copies SharpTS.dll when an emitted soft-dependent feature requires it.

Major feature areas

  • TypeScript syntax, type checking, modules, projects, declarations, JSX/TSX, async functions, decorators, and JavaScript built-ins
  • Interpreter and compiled-IL execution with a documented parity contract
  • Node-compatible built-in modules and real npm package loading
  • .NET imports, external assemblies and NuGet references, C# consumption, and embedding APIs
  • MSBuild SDK integration, interpreted and compiled TypeScript-source debugging, and a standalone language server
  • Retained Avalonia desktop applications written in TypeScript/TSX
  • Managed self-contained and Native AOT distribution options

The current capability matrix and known gaps are in STATUS.md.

Documentation

Start with the documentation hub for task-oriented guides. Runnable examples are collected in the samples cookbook. Contributors should read CONTRIBUTING.md and ARCHITECTURE.md.

SharpTS is licensed under the MIT License.

About

Compile TypeScript to .NET IL; Use .NET classes in Typescript

Topics

Resources

Contributing

Stars

152 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages