fix(transformer/typescript): missing initializer for class constructor arguments with private and protected modifier (#3996)

close: #3992
This commit is contained in:
Dunqing 2024-07-01 15:10:31 +00:00
parent 23038ad8f8
commit a50ce3d299
5 changed files with 16 additions and 2 deletions

View file

@ -8,11 +8,13 @@ on:
paths:
- '**/*.md'
- '**/*.html'
- '!**/fixtures/**'
pull_request:
types: [opened, synchronize]
paths:
- '**/*.md'
- '**/*.html'
- '!**/fixtures/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}

View file

@ -239,7 +239,7 @@ impl<'a> TypeScriptAnnotations<'a> {
// for each of them in the constructor body.
if def.kind == MethodDefinitionKind::Constructor {
for param in def.value.params.items.as_mut_slice() {
if param.is_public() {
if param.accessibility.is_some() {
if let Some(id) = param.pattern.get_binding_identifier() {
self.assignments.push(Assignment {
span: id.span,

View file

@ -1,6 +1,6 @@
commit: 12619ffe
Passed: 4/4
Passed: 5/5
# All Passed:
* babel-plugin-transform-typescript

View file

@ -0,0 +1,5 @@
class Foo {
constructor(public foo, private bar, protected zoo, too) {
}
}

View file

@ -0,0 +1,7 @@
class Foo {
constructor(foo, bar, zoo, too) {
this.foo = foo;
this.bar = bar;
this.zoo = zoo;
}
}