Go to TypeScript compiler

GoScript compiles Go to TypeScript at the AST level. Share algorithms and business logic between your Go backend and TypeScript frontend.

goscript-demo
Input main.go
package main

type Counter struct {
    value int
}

func (c *Counter) Increment() {
    c.value++
}

func main() {
    c := &Counter{}
    c.Increment()
    println("Count:", c.value)
}
Output main.ts
import * as $ from "@goscript/builtin"

export class Counter {
  public value: number = 0

  public Increment(): void {
    this.value++
  }
}

const c = new Counter()
c.Increment()
$.println("Count:", c.value)

Status

๐ŸŽฏ

Goal

Share algorithms and business logic between Go and TypeScript without maintaining separate implementations.

โœ…

What works

Structs, interfaces, methods, generics, channels, goroutines, pointers, slices, maps, closures, and control flow.

๐Ÿงช

Tests

Verified by a compliance suite that compiles Go code and executes the generated TypeScript.

๐Ÿšง

In progress

Reflection, standard library coverage.

โš ๏ธ

Limitations

Uses JS number (64-bit float). No unsafe, uintptr, or complex numbers.

Install

compile
run