GoScript is an experimental Go-to-TypeScript transpiler that converts Go source code at the AST level into TypeScript, enabling sharing algorithms and business logic between Go backends and TypeScript frontends. Current stable version is 0.0.84 with frequent releases (weekly). Unlike GopherJS (full Go runtime in browser), GoScript aims for readable TypeScript output focused on self-contained algorithms. It supports structs, interfaces, generics, goroutines (mapped to async/await), channels, and limited stdlib. Uses JavaScript number type (64-bit float), no unsafe or complex numbers. Mature enough for sharing logic but not full Go apps.
npm install goscriptNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use the compile function to transpile a simple Go program to TypeScript programmatically.
Manually cast to BigInt in generated TypeScript if exact integer math is required.
Ensure your bundler or tsconfig resolves .ts imports correctly (e.g., moduleResolution: 'bundler').
Avoid using uintptr or unsafe.Pointer; refactor code to use slices or references instead.
Wrap async calls in an async IIFE or use top-level await if your target supports it.
Pin to a specific version and expect to update imports when upgrading.
Check the list of supported packages in the documentation before compiling.
Avoid relying on advanced reflection in code meant for compilation.
npm install goscript@latest
Use named import: import { compile } from 'goscript';Change to ES module import or use dynamic import: import('goscript')Remove or replace the unsupported package with a compatible alternative.