Skip to content

Fix references to this in default arguments of class/object methods #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 18, 2025

Conversation

SarahIsWeird
Copy link
Contributor

What the title says.

function(context, args) {
  class Foo extends Object {
    constructor() {
      let _14t6uzrkvpl_THIS_ = super()
      _14t6uzrkvpl_THIS_.bar = 1
    }
    baz(a = super.valueOf().bar) {
      return a
    }
  }
  return new Foo().baz()
}

I did check this in-game as well, and it works :)

@SarahIsWeird
Copy link
Contributor Author

Oopsie, the script output above is generated from this:

export default (context: Context, args?: unknown) => {
    class Foo {
        declare bar: number;

        constructor() {
            this.bar = 1;
        }

        baz(a = this.bar): number {
            return a;
        }
    }

    return (new Foo()).baz();
}

@samualtnorman samualtnorman merged commit 70f29fa into samualtnorman:main Feb 18, 2025
1 check passed
@samualtnorman
Copy link
Owner

ty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants