TSZIG: An experimental TypeScript-to-Zig compiler

orielhaim1 pts0 comments

GitHub - orielhaim/tszig: An experimental compiler that translates TypeScript into Zig · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

orielhaim

tszig

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>13 Commits<br>13 Commits

src

src

test

test

.gitignore

.gitignore

LICENSE

LICENSE

README.md

README.md

biome.json

biome.json

build.ts

build.ts

bun.lock

bun.lock

package.json

package.json

tsconfig.json

tsconfig.json

View all files

Repository files navigation

TSZIG

TSZIG is an experimental compiler project that aims to transform TypeScript code into readable Zig code. The goal is to explore what a TypeScript-to-Zig workflow could look like while keeping the generated output simple and understandable.

Why?

TypeScript offers a productive developer experience, while Zig focuses on simplicity, performance, and control. (Or in simpler terms - zig is faster 🙂)

Usage

You can use the CLI to check your code compatibility or build the final Zig files.

Installation

git clone https://github.com/orielhaim/tszig.git<br>cd tszig

bun install # or npm install (for the losers)

Commands

Build: Compile a directory of TypeScript files to Zig.

bun dev build ./test -o ./output

Check: Validate TypeScript files for Zig compatibility without generating output.

bun dev check ./test

Example

Input (fibonacci.ts):

function fibonacci(n: number): number {<br>if (n 1) return n;

let a = 0;<br>let b = 1;

for (let i = 2; i n; i++) {<br>const temp = a + b;<br>a = b;<br>b = temp;

return b;

Output (fibonacci.zig):

pub fn fibonacci(n: f64) f64 {<br>if (n 1.0) return n;

var a: f64 = 0.0;<br>var b: f64 = 1.0;

var i: f64 = 2.0;<br>while (i n) : (i += 1.0) {<br>const temp = a + b;<br>a = b;<br>b = temp;

return b;

Try it yourself

The repo includes a Test Suite directory that covers most of the supported TypeScript features.

bun dev build ./test -o ./output

Status

TSZIG is currently under active development and is considered experimental .

✅ Built and tested with TypeScript 6

✅ Compatible with Zig 0.16.0

⚠️ Not all TypeScript features are supported (e.g., complex Generics, JS built-ins)

⚠️ APIs and output format may change frequently

Goals

Primitive types, functions, and control flow

Classes with inheritance, abstract classes, and virtual dispatch

Generics (functions and classes)

Cross-module imports and multi-file compilation

Comprehensive diagnostics for unsupported TypeScript patterns

Standard library coverage (Math, string methods, Array utilities)

Discriminated unions and advanced type narrowing

Contributing

Issues, ideas, feedback, and pull requests are welcome. (Obviously)

License

Apache License 2.0

About

An experimental compiler that translates TypeScript into Zig

Resources

Readme

License

Apache-2.0 license

Uh oh!

There was an error while loading. Please reload this page.

Activity

Stars

star

Watchers

watching

Forks

forks

Report repository

Releases

No releases published

Uh oh!

There was an error while loading. Please reload this page.

Contributors

Uh oh!

There was an error while loading. Please reload this page.

Languages

TypeScript<br>100.0%

You can’t perform that action at this time.

typescript tszig reload files test license

Related Articles