fix(isolated-declarations): do not infer type for private parameters (#4105)

close: #4033
This commit is contained in:
Dunqing 2024-07-08 06:51:28 +00:00
parent 0f026089d1
commit e67c7d1b01
2 changed files with 7 additions and 3 deletions

View file

@ -241,8 +241,12 @@ impl<'a> IsolatedDeclarations<'a> {
let mut elements = self.ast.new_vec();
for (index, param) in function.params.items.iter().enumerate() {
if param.accessibility.is_some() || param.readonly {
// transformed params will definitely have type annotation
let type_annotation = self.ast.copy(&params.items[index].pattern.type_annotation);
let type_annotation = if param.accessibility.is_some_and(|a| a.is_private()) {
None
} else {
// transformed params will definitely have type annotation
self.ast.copy(&params.items[index].pattern.type_annotation)
};
if let Some(new_element) =
self.transform_formal_parameter_to_class_property(param, type_annotation)
{

View file

@ -29,7 +29,7 @@ export declare class Baz {
}
export declare class Boo {
readonly prop: number;
private readonly prop2: number;
private readonly prop2;
readonly prop3: number;
constructor(prop?: number, prop2?: number, prop3?: number);
}