Skip to content

Commit 4018cdc

Browse files
committed
feat(transformer/typescript): support for backward compatibility
1 parent c7f3c06 commit 4018cdc

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

crates/oxc_transformer/src/typescript/annotations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ impl<'a, 'ctx> TypeScriptAnnotations<'a, 'ctx> {
5353
has_jsx_fragment: false,
5454
jsx_element_import_name,
5555
jsx_fragment_import_name,
56-
remove_class_fields_without_initializer: options
57-
.remove_class_fields_without_initializer,
56+
remove_class_fields_without_initializer: !options.allow_declare_fields
57+
|| options.remove_class_fields_without_initializer,
5858
}
5959
}
6060
}

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: 153/249
3+
Passed: 154/250
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 (6/22)
47+
# babel-plugin-transform-typescript (7/23)
4848
* class-property-definition/input.ts
4949
Unresolved references mismatch:
5050
after transform: ["const"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Cls {
2+
x: number;
3+
y = 1;
4+
@dce
5+
z: string;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"plugins": [
3+
[
4+
"transform-typescript",
5+
{
6+
"allowDeclareFields": false
7+
}
8+
]
9+
]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Cls {
2+
y = 1;
3+
@dce
4+
z;
5+
}

0 commit comments

Comments
 (0)