Something went wrong. Try again.
A native-speed rewrite of the roblox-ts compiler in golang
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128// classes: declarations, expressions, inheritance, statics, abstract,// parameter properties, computed names, hoisting, toString/__tostringexport class Animal { name: string; legs = 4; constructor(name: string) { this.name = name; } walk(dist: number) { print(this.name, dist); } describe(this: void) { print("callback-style method"); } ["with space"]() { return 1; } static create() { return new Animal("a"); } static VERSION = 1;}
class Point { constructor( public x: number, public readonly y = 10, ) {} toString() { return `(${this.x}, ${this.y})`; } lengthSquared() { return this.x * this.x + this.y * this.y; }}
class Point3 extends Point { constructor( x: number, public z: number, ) { print("pre-super"); super(x); print("post-super", this.z); } lengthSquared() { return super.lengthSquared() + this.z * this.z; } manhattan() { return super["lengthSquared"](); }}
class Inherited extends Point {}
abstract class Shape { abstract area(): number; describe() { return "shape area: " + tostring(this.area()); }}
abstract class NamedShape extends Point { abstract label(): string;}
class Square extends Shape { constructor(private side: number) { super(); } area() { return this.side * this.side; }}
const Runtime = class Inner { tag = "inner"; self() { return Inner; }};
const Anon = class { value() { return 42; }};
class Registry { static entries = 0; static { Registry.entries = 1; print(this.entries); }}
const KEY = "dynamic";
class Computed { [KEY]() { return "computed"; }}
function early() { return new Hoisted();}
class Hoisted { when = "later";}
export default class { run() { return "default"; }}
const animal = Animal.create();animal.walk(Animal.VERSION);animal.describe();print(animal["with space"]());const p3 = new Point3(1, 2);print(tostring(p3), p3.lengthSquared(), p3.manhattan(), new Inherited(5));print(new Square(3).describe(), NamedShape);print(new Runtime().self(), new Anon().value(), Registry.entries);print(new Computed()[KEY](), early().when);