fix(isolated_declarations): Class properties should still be lifted from private constructors (#4934)

Before, this
```ts
export class Bux {
  private constructor(
    public readonly prop: number = 0,
    private readonly prop2: number = 1,
    readonly prop3: number = 1,
  ) {}
}
```
would be emitted as 
```ts
export declare class Bux {
	private constructor();
}
```

Now it will be emitted as
```ts
export declare class Bux {
	readonly prop: number;
	private readonly prop2;
	readonly prop3: number;
	private constructor();
}
```

Co-authored-by: MichaelMitchell-at <=>
This commit is contained in:
michaelm 2024-08-16 09:43:44 -04:00 committed by GitHub
parent 7ecf0efd40
commit 8e80f593fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 4 deletions

View file

@ -375,10 +375,6 @@ impl<'a> IsolatedDeclarations<'a> {
if self.report_property_key(&method.key, method.computed) {
continue;
}
if method.accessibility.is_some_and(TSAccessibility::is_private) {
elements.push(self.transform_private_modifier_method(method));
continue;
}
let inferred_accessor_types = self.collect_inferred_accessor_types(decl);
let function = &method.value;
@ -407,6 +403,11 @@ impl<'a> IsolatedDeclarations<'a> {
);
}
if method.accessibility.is_some_and(TSAccessibility::is_private) {
elements.push(self.transform_private_modifier_method(method));
continue;
}
let return_type = match method.kind {
MethodDefinitionKind::Method => {
let rt = self.infer_function_return_type(function);

View file

@ -35,3 +35,11 @@ export class Boo {
readonly prop3: number = 1,
) {}
}
export class Bux {
private constructor(
public readonly prop: number = 0,
private readonly prop2: number = 1,
readonly prop3: number = 1,
) {}
}

View file

@ -33,3 +33,9 @@ export declare class Boo {
readonly prop3: number;
constructor(prop?: number, prop2?: number, prop3?: number);
}
export declare class Bux {
readonly prop: number;
private readonly prop2;
readonly prop3: number;
private constructor();
}