Skip to content
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

fix(es/codegen): Emit question token for class methods #9342

Merged
merged 3 commits into from
Jul 30, 2024
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
6 changes: 6 additions & 0 deletions .changeset/tall-cooks-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_ecma_codegen: patch
swc_ecma_transforms_typescript: patch
---

fix(es/codegen): Emit question token for class methods
4 changes: 4 additions & 0 deletions crates/swc_ecma_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,10 @@ where
}
}

if n.is_optional {
punct!("?");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this regressed because previously it happened to emit from the binding ident being optional.


if let Some(type_params) = &n.function.type_params {
emit!(type_params);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class MyClass extends Base {
public override method(param: number): string {
}
public abstract override log(msg: string): void;
public abstract override log?<TValue>(msg: string): TValue;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class MyClass extends Base {
public override method(param: number): string {}
public abstract override log(msg: string): void;
public abstract override log?<TValue>(msg: string): TValue;
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
class MyClass extends Base{public override method(param:number):string{}public abstract override log(msg:string):void}
class MyClass extends Base{public override method(param:number):string{}public abstract override log?<TValue>(msg:string):TValue}
1 change: 1 addition & 0 deletions crates/swc_ecma_transforms_typescript/src/strip_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl VisitMut for StripType {
n.accessibility = None;
n.is_override = false;
n.is_abstract = false;
n.is_optional = false;
n.visit_mut_children_with(self);
}

Expand Down
Loading