Skip to content

Commit

Permalink
fix(es/typescript): Enable Injector to process JSX (#9395)
Browse files Browse the repository at this point in the history
- Closes #9394
  • Loading branch information
magic-akari authored Aug 7, 2024
1 parent 8e49c90 commit e24e2ff
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-pets-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
swc_ecma_utils: patch
---

fix(es/typescript): Enable Injector to process JSX
9 changes: 9 additions & 0 deletions crates/swc/tests/fixture/issues-9xxx/9394/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"target": "es2022"
}
}
5 changes: 5 additions & 0 deletions crates/swc/tests/fixture/issues-9xxx/9394/input/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MyClass {
constructor(private readonly myNumber: number) {
const component = <MyComponent />;
}
}
7 changes: 7 additions & 0 deletions crates/swc/tests/fixture/issues-9xxx/9394/output/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MyClass {
myNumber;
constructor(myNumber){
this.myNumber = myNumber;
const component = /*#__PURE__*/ React.createElement(MyComponent, null);
}
}
6 changes: 2 additions & 4 deletions crates/swc_ecma_utils/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use std::iter;

use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_visit::{
noop_visit_mut_type, standard_only_fold, Fold, FoldWith, VisitMut, VisitMutWith,
};
use swc_ecma_visit::{noop_fold_type, noop_visit_mut_type, Fold, FoldWith, VisitMut, VisitMutWith};

use crate::{prepend_stmts, ExprFactory};

Expand Down Expand Up @@ -36,7 +34,7 @@ struct Injector<'a> {
}

impl<'a> Fold for Injector<'a> {
standard_only_fold!();
noop_fold_type!();

fn fold_class(&mut self, c: Class) -> Class {
c
Expand Down

0 comments on commit e24e2ff

Please sign in to comment.