From 0ce9dd558a0323b034a83a07d8fc67c12fca224e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 27 May 2024 22:05:02 +0300 Subject: [PATCH] feature: add support of set/get in interfaces --- lib/printer.ts | 5 +++++ test/typescript.ts | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/printer.ts b/lib/printer.ts index df020115..b27fabd7 100644 --- a/lib/printer.ts +++ b/lib/printer.ts @@ -2333,6 +2333,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 { diff --git a/test/typescript.ts b/test/typescript.ts index ddbce81a..410fa9ac 100644 --- a/test/typescript.ts +++ b/test/typescript.ts @@ -244,6 +244,13 @@ const nodeMajorVersion = parseInt(process.versions.node, 10); " a(c: (this: void, e: E) => void): void;", "}", ]); + + check([ + "interface LabelledContainer {", + " get label(): string;", + " set label(a: string);", + "}", + ]); check([ "interface Square extends Shape, Visible {",