johnfn / ts2gd

💥 Compile TypeScript to GDScript for Godot
210 stars 14 forks source link

Add static method support #70

Closed adamuso closed 2 years ago

adamuso commented 2 years ago

Add support for static methods in classes. Simple as that.

class Test extends Area2D {
  constructor() {
    super()
    Test.test()
  }

  static test() {
    print("static")
  }
}
import { Test } from "./src/Test"

class Foo extends Node { 
  constructor() {
    super()
    Test.test()
  }
}
extends Area2D
class_name Test

func _ready():
  self.test()

static func test():
  print("static")
extends Node
class_name Foo

var Test = load("res://compiled/Test.gd")

func _ready():
  Test.test()

closes #69

johnfn commented 2 years ago

Awesome, thanks!