# StaticScript

> A TypeScript compiler that uses TypeScript as a frontend and LLVM as a backend to compile TypeScript code into native binaries.

StaticScript is an open-source compiler project created by Dmitry Patsura that takes TypeScript as its frontend language and uses LLVM as its backend for native code generation. The project, also referred to as RSTS (Real Static Typed Script), enables TypeScript code to be compiled directly to binary executables rather than running through a JavaScript runtime. It is hosted on GitHub under the MIT License and has accumulated over 650 stars since its creation in 2018.

## What It Is

StaticScript sits at the intersection of TypeScript tooling and systems programming. Rather than transpiling TypeScript to JavaScript for execution in Node.js or a browser, StaticScript parses TypeScript source files using the TypeScript compiler frontend and then feeds the resulting AST into LLVM's code generation pipeline to produce native machine code. The result is a compiled binary that runs without a JavaScript engine, offering the potential for significantly lower startup times and reduced runtime overhead compared to interpreted or JIT-compiled execution.

## How It Works

The compilation pipeline has two main stages:

- **Frontend**: The TypeScript compiler API parses and type-checks `.ts` source files, producing a typed AST.
- **Backend**: LLVM receives the AST and generates optimized native machine code, outputting a binary executable.

The project's README includes a worked example — a Monte Carlo π calculation — that compiles and runs in approximately 0.013 seconds on the author's machine, illustrating the performance characteristics of native output.

## Architecture and Language Support

StaticScript is written in TypeScript itself and is installable as a global npm package (`npm install -g static-script`). The compiler binary is invoked via `ssc`, which takes a `.ts` file and produces a compiled output in an `./output/main` binary. The project targets a statically typed subset of TypeScript, leveraging LLVM's mature optimization passes for code quality. GitHub topics for the repository are `llvm` and `typescript`, reflecting the two core technologies.

## Current Status

The repository was last pushed to in December 2021, indicating that active development has been dormant for several years. The project has 8 open issues and 30 forks as of the latest GitHub metadata. The author presented the project at PiterJS meetups in two parts, with slides available on SpeakerDeck and a recorded talk on YouTube explaining the high-level architecture, V8/JIT comparisons, and implementation details. Despite the inactivity, the repository remains publicly available and the codebase is accessible for study or forking.

## Features
- TypeScript frontend with LLVM backend
- Compiles TypeScript to native binary executables
- No JavaScript runtime required at execution
- CLI compiler invoked via `ssc` command
- Installable as a global npm package
- MIT licensed and open source
- Supports static typing via TypeScript's type system

## Integrations
TypeScript, LLVM, npm

## Platforms
API, CLI

## Pricing
Open Source

## Links
- Website: https://github.com/ovr/StaticScript
- Repository: https://github.com/ovr/StaticScript
- EveryDev.ai: https://www.everydev.ai/tools/staticscript
