Skip to content

Commit ec8381a

Browse files
authored
Fix mapping for if/ifnot bindings (#138)
1 parent 7a84ddf commit ec8381a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.changeset/three-kids-pull.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@knuckles/typescript": patch
3+
---
4+
5+
Fix mapping for if/ifnot bindings.

packages/typescript/src/transpiler/transpiler.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,17 @@ class Renderer {
367367
const negate = binding.name.value === "ifnot";
368368

369369
descendants = new Chunk()
370-
.append("if (")
371-
.append(negate ? "!(" : "")
372-
.append(binding.param.value, { blame: binding.param })
373-
.append(negate ? ")" : "")
374-
.append(") {")
370+
.while(
371+
(chunk) =>
372+
chunk
373+
.append("if (")
374+
.append(negate ? "!(" : "")
375+
.append(binding.param.value, { mirror: binding.param })
376+
.append(negate ? ")" : "")
377+
.append(")"),
378+
{ blame: binding },
379+
)
380+
.append("{")
375381
.newline()
376382
.append(descendants)
377383
.newline()

0 commit comments

Comments
 (0)