Skip to content

Commit 27ba8a6

Browse files
committed
feature: add support of set/get in interfaces
1 parent 2fa2ad1 commit 27ba8a6

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/printer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,11 @@ function genericPrintNoParens(path: any, options: any, print: any) {
23372337
return concat(parts);
23382338

23392339
case "TSMethodSignature":
2340+
if (n.kind === 'get') {
2341+
parts.push('get ')
2342+
} else if (n.kind === 'set') {
2343+
parts.push('set ')
2344+
}
23402345
if (n.computed) {
23412346
parts.push("[", path.call(print, "key"), "]");
23422347
} else {

test/typescript.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ const nodeMajorVersion = parseInt(process.versions.node, 10);
249249
" a(c: (this: void, e: E) => void): void;",
250250
"}",
251251
]);
252+
253+
check([
254+
"interface LabelledContainer<T> {",
255+
" get label(): string;",
256+
" set label(a: string);",
257+
"}",
258+
]);
252259

253260
check([
254261
"interface Square<T, U> extends Shape<T, U>, Visible<T, U> {",

0 commit comments

Comments
 (0)