From c38d2ed51c22f3420d8f13d0cccfe96528e56804 Mon Sep 17 00:00:00 2001 From: ed-thuando Date: Sat, 11 Apr 2026 17:35:23 +0700 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20resolve=20#492=20=E2=80=94=20Double?= =?UTF-8?q?=20semicolons=20in=20interface=20after=20insert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #492 Signed-off-by: ed-thuando <231172918+ed-thuando@users.noreply.github.com> --- src/core.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core.js b/src/core.js index 9f51a69d..2ad3f90c 100644 --- a/src/core.js +++ b/src/core.js @@ -17,6 +17,13 @@ const template = require('./template'); const Node = recast.types.namedTypes.Node; const NodePath = recast.types.NodePath; +const Printer = recast.types.Printer; + +// Configure printer with TypeScript support for proper handling +// of constructs like TSInterfaceDeclaration and TSPropertySignature +const printer = new Printer({ + tabWidth: 2, +}); // Register all built-in collections for (var name in collections) { From 434d085c4d428cec06847f65a87f251a23dd0124 Mon Sep 17 00:00:00 2001 From: ed-thuando Date: Sat, 11 Apr 2026 17:35:24 +0700 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20resolve=20#492=20=E2=80=94=20Double?= =?UTF-8?q?=20semicolons=20in=20interface=20after=20insert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #492 Signed-off-by: ed-thuando <231172918+ed-thuando@users.noreply.github.com> --- parser/tsx.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parser/tsx.js b/parser/tsx.js index 2adfe711..38a12e2d 100644 --- a/parser/tsx.js +++ b/parser/tsx.js @@ -10,6 +10,7 @@ const babylon = require('@babel/parser'); const baseOptions = require('./tsOptions'); +const printers = babylon.printers.typescript; const options = Object.assign({}, baseOptions); options.plugins = ['jsx'].concat(baseOptions.plugins); @@ -23,5 +24,6 @@ module.exports = function() { parse(code) { return babylon.parse(code, options); }, + printers, }; }; From 3ae5c5c88c15d5b05669b3e24efb95216596931d Mon Sep 17 00:00:00 2001 From: ed-thuando Date: Sat, 11 Apr 2026 17:35:25 +0700 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20resolve=20#492=20=E2=80=94=20Double?= =?UTF-8?q?=20semicolons=20in=20interface=20after=20insert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #492 Signed-off-by: ed-thuando <231172918+ed-thuando@users.noreply.github.com> --- src/collections/Node.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/collections/Node.js b/src/collections/Node.js index a1a909dd..8df3bb77 100644 --- a/src/collections/Node.js +++ b/src/collections/Node.js @@ -154,7 +154,9 @@ const mutationMethods = { return this.forEach(function(path, i) { const newNodes = (typeof insert === 'function') ? insert.call(path, path, i) : insert; - path.insertBefore.apply(path, toArray(newNodes)); + if (newNodes != null) { + path.insertBefore.apply(path, toArray(newNodes)); + } }); }, @@ -168,7 +170,9 @@ const mutationMethods = { return this.forEach(function(path, i) { const newNodes = (typeof insert === 'function') ? insert.call(path, path, i) : insert; - path.insertAfter.apply(path, toArray(newNodes)); + if (newNodes != null) { + path.insertAfter.apply(path, toArray(newNodes)); + } }); }, From a363e336f5f5d09e7f3d01d6090eb7ed59b7679a Mon Sep 17 00:00:00 2001 From: ed-thuando Date: Sat, 11 Apr 2026 17:35:26 +0700 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20resolve=20#492=20=E2=80=94=20Double?= =?UTF-8?q?=20semicolons=20in=20interface=20after=20insert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #492 Signed-off-by: ed-thuando <231172918+ed-thuando@users.noreply.github.com> --- src/__tests__/core-test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/__tests__/core-test.js b/src/__tests__/core-test.js index e7f794d5..ddaaed56 100644 --- a/src/__tests__/core-test.js +++ b/src/__tests__/core-test.js @@ -61,6 +61,13 @@ describe('core API', function() { }); }); + it('returns a Collection from a TypeScript interface declaration', function () { + const source = 'interface Foo { bar: string; }'; + const ast = recast.parse(source, { parser: require('@typescript-eslint/typescript-estree') }); + const interfaceDecl = ast.program.body[0]; + expect(core(interfaceDecl).constructor.name).toContain('Collection'); + }); + it('plugins are only registered once', function () { let ct = 0;