Skip to content

Commit e67c7d1

Browse files
committed
fix(isolated-declarations): do not infer type for private parameters (#4105)
close: #4033
1 parent 0f02608 commit e67c7d1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

crates/oxc_isolated_declarations/src/class.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,12 @@ impl<'a> IsolatedDeclarations<'a> {
241241
let mut elements = self.ast.new_vec();
242242
for (index, param) in function.params.items.iter().enumerate() {
243243
if param.accessibility.is_some() || param.readonly {
244-
// transformed params will definitely have type annotation
245-
let type_annotation = self.ast.copy(&params.items[index].pattern.type_annotation);
244+
let type_annotation = if param.accessibility.is_some_and(|a| a.is_private()) {
245+
None
246+
} else {
247+
// transformed params will definitely have type annotation
248+
self.ast.copy(&params.items[index].pattern.type_annotation)
249+
};
246250
if let Some(new_element) =
247251
self.transform_formal_parameter_to_class_property(param, type_annotation)
248252
{

crates/oxc_isolated_declarations/tests/snapshots/class.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export declare class Baz {
2929
}
3030
export declare class Boo {
3131
readonly prop: number;
32-
private readonly prop2: number;
32+
private readonly prop2;
3333
readonly prop3: number;
3434
constructor(prop?: number, prop2?: number, prop3?: number);
3535
}

0 commit comments

Comments
 (0)