Skip to content

Commit 6c20277

Browse files
magic-akariDunqing
andauthored
fix(transformer): Always update jsx options from comments (#10966)
> [!NOTE] > The explanation in the comment is incorrect because the `h` function might be locally defined rather than imported. Removing the conditional check will fix the issue. - Closes: #10956 Co-authored-by: Dunqing <dengqing0821@gmail.com>
1 parent e31c361 commit 6c20277

5 files changed

Lines changed: 13 additions & 8 deletions

File tree

crates/oxc_transformer/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,7 @@ impl<'a> Transformer<'a> {
120120
self.ctx.source_type = program.source_type;
121121
self.ctx.source_text = program.source_text;
122122

123-
// Update options from comments when source type is JSX or TypeScript which has enabled `only_remove_type_imports`.
124-
// Because if `only_remove_type_imports` is enabled, no imports will be removed, so that we don't care about
125-
// TypeScript's `jsx_pragma` and `jsx_pragma_frag` options.
126-
if program.source_type.is_jsx()
127-
&& (!program.source_type.is_typescript() || !self.typescript.only_remove_type_imports)
128-
{
123+
if program.source_type.is_jsx() {
129124
jsx::update_options_with_comments(
130125
&program.comments,
131126
&mut self.typescript,

tasks/transform_conformance/snapshots/oxc.snap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
commit: 578ac4df
22

3-
Passed: 152/254
3+
Passed: 153/255
44

55
# All Passed:
66
* babel-plugin-transform-class-static-block
@@ -44,7 +44,7 @@ after transform: SymbolId(0): [ReferenceId(0), ReferenceId(2), ReferenceId(6), R
4444
rebuilt : SymbolId(0): [ReferenceId(0), ReferenceId(2), ReferenceId(6), ReferenceId(10)]
4545

4646

47-
# babel-plugin-transform-typescript (4/25)
47+
# babel-plugin-transform-typescript (5/26)
4848
* allow-declare-fields-false/input.ts
4949
Unresolved references mismatch:
5050
after transform: ["dce"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/** @jsx h */
2+
/** @jsxRuntime classic */
3+
export const foo = <div></div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": [
3+
["transform-typescript", { "onlyRemoveTypeImports": true }],
4+
"transform-react-jsx"
5+
]
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const foo = h("div", null);

0 commit comments

Comments
 (0)