diff --git a/game-scripts-tests/this_in_default_argument.ts b/game-scripts-tests/this_in_default_argument.ts index 61e18b4..f903b3e 100644 --- a/game-scripts-tests/this_in_default_argument.ts +++ b/game-scripts-tests/this_in_default_argument.ts @@ -1,34 +1,35 @@ export default ({ expect }: typeof import('vitest')) => { - class Foo { - declare foo: number + class Foo { + declare foo: number - constructor() { - this.foo = 1 - } + constructor() { + this.foo = 1 + } - bar() { - return 2 - } + bar() { + return 2 + } - baz(a = this.foo, b = this.bar()) { - return a + b - } - } + baz(a = this.foo, b = this.bar()) { + return a + b + } + } - const obj = { - foo: 1, - bar() { - return 2 - }, - baz(a = this.foo, b = this.bar()) { - return a + b - } - } + const obj = { + foo: 1, + bar() { + return 2 + }, + baz(a = this.foo, b = this.bar()) { + return a + b + } + } - const foo = new Foo() - expect(foo.baz(3, 4)).toBe(7) // Is this the real life? - expect(foo.baz()).toBe(3) // Is this just fantasy? + const foo = (new Foo) - expect(obj.baz(3, 4)).toBe(7) // Caught in a landslide - expect(obj.baz()).toBe(3) // No escape from reality + expect(foo.baz(3, 4)).toBe(7) // Is this the real life? + expect(foo.baz()).toBe(3) // Is this just fantasy? + + expect(obj.baz(3, 4)).toBe(7) // Caught in a landslide + expect(obj.baz()).toBe(3) // No escape from reality } diff --git a/src/processScript/transform.ts b/src/processScript/transform.ts index 99eed3e..609f020 100644 --- a/src/processScript/transform.ts +++ b/src/processScript/transform.ts @@ -830,7 +830,7 @@ export function transform( path.replaceWith(t.callExpression( t.memberExpression(t.super(), t.identifier(`valueOf`)), [] )) - }, + } }, scope) }