Skip to content

Commit

Permalink
feature: add support of set/get in interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed May 27, 2024
1 parent 2fa2ad1 commit 27ba8a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,11 @@ function genericPrintNoParens(path: any, options: any, print: any) {
return concat(parts);

case "TSMethodSignature":
if (n.kind === 'get') {
parts.push('get ')
} else if (n.kind === 'set') {
parts.push('set ')
}
if (n.computed) {
parts.push("[", path.call(print, "key"), "]");
} else {
Expand Down
7 changes: 7 additions & 0 deletions test/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
" a(c: (this: void, e: E) => void): void;",
"}",
]);

check([
"interface LabelledContainer<T> {",
" get label(): string;",
" set label(a: string);",
"}",
]);

check([
"interface Square<T, U> extends Shape<T, U>, Visible<T, U> {",
Expand Down

0 comments on commit 27ba8a6

Please sign in to comment.