Skip to content

Static methods have no self parameter #320

@hazzard993

Description

@hazzard993

Found a bug, looks like transpiled static methods no longer have a self parameter.

class Player {
    static initialize() {
        this.x = 0;     // this = Player
    }
}

Player.initialize();
console.log(Player.x);

When transpiled to Lua initialize turns into

function Player.initialize()
    self.x = 0;
end

So that function won't work, self will always be nil.

Transpile and run this code with tsc and node and you'll get an output of 0.

tsc main.ts && node main.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions