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.
package main
type Counter struct {
value int
}
func (c *Counter) Increment() {
c.value++
}
func main() {
c := &Counter{}
c.Increment()
println("Count:", c.value)
}
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, control flow, reflection, encoding/json, and most of the standard library.
Tests
Verified by a compliance suite that compiles Go code and executes the generated TypeScript.
In progress
Reflection edge cases, full standard library coverage.
Limitations
Uses JS number (64-bit float). No
unsafe, uintptr, or complex numbers.