Skip to content

Commit

Permalink
fix(transformer/typescript): generated assignment for constructor arg…
Browse files Browse the repository at this point in the history
…uments with access modifiers should be injected to the top of the constructor (#4808)

fix: #4789
  • Loading branch information
Dunqing committed Aug 10, 2024
1 parent 857bc73 commit 62f759c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/oxc_transformer/src/typescript/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ impl<'a> TypeScriptAnnotations<'a> {
)
})
.statements
.extend(
.splice(
0..0,
self.assignments
.drain(..)
.map(|assignment| assignment.create_this_property_assignment(ctx)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Foo {
boom: number;
constructor(public foo, private bar, protected zoo, readonly bang, too) {

console.log(this.foo, this.bar, this.zoo, this.bang);
}
}
class Bar extends Foo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Foo {
this.bar = bar;
this.zoo = zoo;
this.bang = bang;
console.log(this.foo, this.bar, this.zoo, this.bang);
}
}
class Bar extends Foo {
Expand Down

0 comments on commit 62f759c

Please sign in to comment.