https://github.com/leona/ts2go
Experimental TypeScript to Go transpiler
https://github.com/leona/ts2go
Last synced: 5 months ago
JSON representation
Experimental TypeScript to Go transpiler
- Host: GitHub
- URL: https://github.com/leona/ts2go
- Owner: leona
- Created: 2024-02-05T10:24:22.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-12T14:18:29.000Z (almost 2 years ago)
- Last Synced: 2024-07-12T16:26:01.570Z (almost 2 years ago)
- Language: TypeScript
- Homepage: https://ts2go.pages.dev/
- Size: 2.44 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-typescript-compilers - ts2go
README
# ts2go
Experimental TypeScript to Go transpiler. Supports an extremely limited subset of TypeScript features.
Playground
https://ts2go.pages.dev/

Debugger (`docker-compose up`)

## Why?
This is just a crazy experiment to learn more about ASTs. Should you use this? Probably not. But I've found it a fun experiment.
My goal for this was not to reach Go performance with Typescript, or to have 1-1 support, but just to be able to write simple applications (CLI tools etc.) in TypeScript and output a small, portable and low footprint binary.
### Not yet supported
- disable any keyword and force strict typing
- enums
- classes
- impoved type inference
- support callbacks
- async await
- complete fetch, console, Date & process support
- float
- try/catch
- spread operators
- anonymous/named functions
- type params
- support constructors like new Date() but also static references like Date.now()
- support not capitalising variable names within a scoped function
- debug wrapper to print TS lines or comments
- error handling for unsupported features
- imports
- declaring multiple variables at once e.g. const test, test2 = "test"
- computed properties such as length
- pass by reference everywhere
- optimiser and debugger, crawl through and check for pushing string to int array etc.
- run tests in typescript & Go then compare
- seperate GoNode into multiple types
- casting
- utilise the reference IDs you can generate with asty
- optionals
Features this may never support
- enums
- interface properties
- inheritence
- same variable names different capitalisation
- partial imports, only import all
- mutating int to float
- var scoping