From c8ab569146fb105b59d4ec4e39662a993459371a Mon Sep 17 00:00:00 2001 From: Manuel Date: Sun, 9 Mar 2025 08:01:04 +0100 Subject: [PATCH 1/3] fix: correct indentation of `TSModuleBlock` --- .changeset/rude-jeans-cough.md | 5 +++++ src/handlers.js | 2 +- test/samples/ts-module-declaration/expected.ts | 2 +- test/samples/ts-module-declaration/expected.ts.map | 4 ++-- test/samples/ts-module-declaration/input.ts | 4 +++- 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/rude-jeans-cough.md diff --git a/.changeset/rude-jeans-cough.md b/.changeset/rude-jeans-cough.md new file mode 100644 index 0000000..d91cf64 --- /dev/null +++ b/.changeset/rude-jeans-cough.md @@ -0,0 +1,5 @@ +--- +'esrap': patch +--- + +fix: correct indentation of `TSModuleBlock` diff --git a/src/handlers.js b/src/handlers.js index 31fc82e..58be967 100644 --- a/src/handlers.js +++ b/src/handlers.js @@ -1518,7 +1518,7 @@ const handlers = { TSModuleBlock(node, state) { state.commands.push(' {', indent, newline); - sequence(node.body, state, false, handle); + handle_body(node.body, state); state.commands.push(dedent, newline, '}'); }, diff --git a/test/samples/ts-module-declaration/expected.ts b/test/samples/ts-module-declaration/expected.ts index 106d6b3..7204c58 100644 --- a/test/samples/ts-module-declaration/expected.ts +++ b/test/samples/ts-module-declaration/expected.ts @@ -1,6 +1,6 @@ declare global { namespace App { - interface Error {} + interface Error { foo: string } } } diff --git a/test/samples/ts-module-declaration/expected.ts.map b/test/samples/ts-module-declaration/expected.ts.map index 2b334e8..a2a6bc7 100644 --- a/test/samples/ts-module-declaration/expected.ts.map +++ b/test/samples/ts-module-declaration/expected.ts.map @@ -5,7 +5,7 @@ "input.js" ], "sourcesContent": [ - "declare global {\n\tnamespace App {\n\t\tinterface Error {}\n\t}\n}\n\nexport {};\n" + "declare global {\n\tnamespace App {\n\t\tinterface Error {\n\t\t\tfoo: string;\n\t\t}\n\t}\n}\n\nexport {};\n" ], - "mappings": "QAAQ,MAAM;WACH,GAAG;YACF,KAAK;;;;" + "mappings": "QAAQ,MAAM;WACH,GAAG;YACF,KAAK,GACd,GAAG;;;;" } \ No newline at end of file diff --git a/test/samples/ts-module-declaration/input.ts b/test/samples/ts-module-declaration/input.ts index e05a84c..0e54d25 100644 --- a/test/samples/ts-module-declaration/input.ts +++ b/test/samples/ts-module-declaration/input.ts @@ -1,6 +1,8 @@ declare global { namespace App { - interface Error {} + interface Error { + foo: string; + } } } From 4e6caf61e4f24c1b8e9df02e25d5e631903566b1 Mon Sep 17 00:00:00 2001 From: Manuel Date: Sun, 9 Mar 2025 08:45:50 +0100 Subject: [PATCH 2/3] fix test --- test/samples/ts-module-declaration/expected.ts | 2 +- test/samples/ts-module-declaration/expected.ts.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/samples/ts-module-declaration/expected.ts b/test/samples/ts-module-declaration/expected.ts index 7204c58..25d8edb 100644 --- a/test/samples/ts-module-declaration/expected.ts +++ b/test/samples/ts-module-declaration/expected.ts @@ -1,6 +1,6 @@ declare global { namespace App { - interface Error { foo: string } + interface Error {foo: string} } } diff --git a/test/samples/ts-module-declaration/expected.ts.map b/test/samples/ts-module-declaration/expected.ts.map index a2a6bc7..544f615 100644 --- a/test/samples/ts-module-declaration/expected.ts.map +++ b/test/samples/ts-module-declaration/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "declare global {\n\tnamespace App {\n\t\tinterface Error {\n\t\t\tfoo: string;\n\t\t}\n\t}\n}\n\nexport {};\n" ], - "mappings": "QAAQ,MAAM;WACH,GAAG;YACF,KAAK,GACd,GAAG;;;;" + "mappings": "QAAQ,MAAM;WACH,GAAG;YACF,KAAK,EACd,GAAG;;;;" } \ No newline at end of file From efa10b3fa8253999e90fed156d933372b913841b Mon Sep 17 00:00:00 2001 From: Manuel Date: Sun, 9 Mar 2025 09:50:34 +0100 Subject: [PATCH 3/3] fix tests again --- test/samples/ts-module-declaration/expected.ts | 2 +- test/samples/ts-module-declaration/expected.ts.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/samples/ts-module-declaration/expected.ts b/test/samples/ts-module-declaration/expected.ts index 25d8edb..7204c58 100644 --- a/test/samples/ts-module-declaration/expected.ts +++ b/test/samples/ts-module-declaration/expected.ts @@ -1,6 +1,6 @@ declare global { namespace App { - interface Error {foo: string} + interface Error { foo: string } } } diff --git a/test/samples/ts-module-declaration/expected.ts.map b/test/samples/ts-module-declaration/expected.ts.map index 544f615..a2a6bc7 100644 --- a/test/samples/ts-module-declaration/expected.ts.map +++ b/test/samples/ts-module-declaration/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "declare global {\n\tnamespace App {\n\t\tinterface Error {\n\t\t\tfoo: string;\n\t\t}\n\t}\n}\n\nexport {};\n" ], - "mappings": "QAAQ,MAAM;WACH,GAAG;YACF,KAAK,EACd,GAAG;;;;" + "mappings": "QAAQ,MAAM;WACH,GAAG;YACF,KAAK,GACd,GAAG;;;;" } \ No newline at end of file