From 5c660cf952a897596ebdbc38aa70b6c9e47dff7b Mon Sep 17 00:00:00 2001 From: hdineen Date: Fri, 29 Jul 2022 21:54:47 -0400 Subject: [PATCH] add would-be failing test for unwanted commas in TSTypeLiteral --- test/typescript.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/typescript.ts b/test/typescript.ts index 1480a24e..b638177c 100644 --- a/test/typescript.ts +++ b/test/typescript.ts @@ -365,6 +365,25 @@ const nodeMajorVersion = parseInt(process.versions.node, 10); ].join(eol), ); }); + + it("TypeLiteral: unwanted comma", function () { + const code = [ + "type A = {", + " x: boolean;", + " y: number;", + " z: string;", + "}", + ].join(eol); + + const ast = recast.parse(code, { parser }); + + ast.program.body[0].typeAnnotation.members.pop(); + + assert.strictEqual( + recast.print(ast).code, + ["type A = {", " x: boolean;", " y: number;", "}"].join(eol), + ); + }); }); testReprinting(