fix(transformer/typescript): generated assignment for constructor arguments with access modifiers should be injected to the top of the constructor (#4808)

fix: #4789
This commit is contained in:
Dunqing 2024-08-10 11:21:45 +00:00
parent 857bc73302
commit 62f759c1f2
3 changed files with 4 additions and 2 deletions

View file

@ -298,7 +298,8 @@ impl<'a> TypeScriptAnnotations<'a> {
) )
}) })
.statements .statements
.extend( .splice(
0..0,
self.assignments self.assignments
.drain(..) .drain(..)
.map(|assignment| assignment.create_this_property_assignment(ctx)), .map(|assignment| assignment.create_this_property_assignment(ctx)),

View file

@ -1,7 +1,7 @@
class Foo { class Foo {
boom: number; boom: number;
constructor(public foo, private bar, protected zoo, readonly bang, too) { constructor(public foo, private bar, protected zoo, readonly bang, too) {
console.log(this.foo, this.bar, this.zoo, this.bang);
} }
} }
class Bar extends Foo { class Bar extends Foo {

View file

@ -5,6 +5,7 @@ class Foo {
this.bar = bar; this.bar = bar;
this.zoo = zoo; this.zoo = zoo;
this.bang = bang; this.bang = bang;
console.log(this.foo, this.bar, this.zoo, this.bang);
} }
} }
class Bar extends Foo { class Bar extends Foo {