Skip to content

Commit

Permalink
fix(es/codegen): Emit computed getter and setter signatures (#8656)
Browse files Browse the repository at this point in the history
**Description:**

Emits computed getter/setter signatures.
  • Loading branch information
dsherret authored Feb 23, 2024
1 parent 4fa09eb commit 66bf8e9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
16 changes: 14 additions & 2 deletions crates/swc_ecma_codegen/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,13 @@ where
keyword!("get");
space!();

emit!(n.key);
if n.computed {
punct!("[");
emit!(n.key);
punct!("]");
} else {
emit!(n.key)
}

punct!("(");
punct!(")");
Expand All @@ -953,7 +959,13 @@ where
keyword!("set");
space!();

emit!(n.key);
if n.computed {
punct!("[");
emit!(n.key);
punct!("]");
} else {
emit!(n.key)
}

punct!("(");
emit!(n.param);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const symbol1 = Symbol();
const symbol2 = Symbol();
const symbol3 = Symbol();

export interface Test {
[symbol1]: string;
[symbol2](): string;
get [symbol3](): string;
set [symbol3](value: string);
prop1: string;
method1(value: string, param2: number): string;
get method2(): string;
set method2(value: string);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const symbol1 = Symbol();
const symbol2 = Symbol();
const symbol3 = Symbol();
export interface Test {
[symbol1]: string;
[symbol2](): string;
get [symbol3](): string;
set [symbol3](value: string);
prop1: string;
method1(value: string, param2: number): string;
get method2(): string;
set method2(value: string);
}

0 comments on commit 66bf8e9

Please sign in to comment.