8000 fix(ts/isolated-dts): Emit properties in overloaded constructor params by magic-akari · Pull Request #10623 · swc-project/swc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(ts/isolated-dts): Emit properties in overloaded constructor params #10623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions crates/swc_typescript/src/fast_dts/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,20 @@ impl FastDts {
if self.has_internal_annotation(constructor.span_lo()) {
continue;
}
if !(constructor.is_optional) && constructor.body.is_none() {
is_function_overloads = true;
} else if is_function_overloads {
is_function_overloads = false;
continue;
}

if self.report_property_key(&constructor.key) {
continue;
}

// Transform parameters
class.body.splice(
0..0,
self.transform_constructor_params(&mut constructor.params),
);

if !(constructor.is_optional) && constructor.body.is_none() {
is_function_overloads = true;
} else if is_function_overloads {
is_function_overloads = false;
continue;
}

if constructor
.accessibility
.is_some_and(|accessibility| accessibility == Accessibility::Private)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
```==================== .D.TS ====================
// @isolatedDeclarations: true
export declare class C1 {
private prop;
constructor(prop: string);
}
export declare class C2 {
private prop;
constructor(prop: string);
}
export declare class C3 {
readonly prop: any;
constructor(prop: string);
}
export declare class C4 {
readonly prop: any;
constructor(prop: string);
}
export declare class C5 {
private readonly prop;
constructor(prop: string);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @isolatedDeclarations: true
export class C1 {
constructor(private prop: string) {}
}

export class C2 {
constructor(prop: string);
constructor(private prop: any) {}
}

export class C3 {
constructor(prop: string);
constructor(readonly prop: any) {}
}

export class C4 {
constructor(prop: string);
constructor(public readonly prop: any) {}
}

export class C5 {
constructor(prop: string);
constructor(private readonly prop: any) {}
}
Loading
0