Skip to content

Commit

Permalink
fix(es/codegen): Emit question token for class methods (#9342)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jul 30, 2024
1 parent 1725858 commit 636585b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
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!("?");
}

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

0 comments on commit 636585b

Please sign in to comment.