Repository: alloy-framework/alloy
Pull request #60 (2025-03-08 22:31:30)

Fix member chain without call

github-actions[bot]: <!--chronus-github-change-commenter-->
All changed packages have been documented.
 - :white_check_mark: `@alloy-js/typescript`

<details>
<summary>Show changes</summary>

### `@alloy-js/typescript` - _fix_ [✏️](https://github.com/bterlson/alloy/edit/fix-member-chain-without-call/.chronus/changes/fix-member-chain-without-call-2025-2-8-14-30-57.md?pr=/alloy-framework/alloy/pull/60)
> Fix member chains that don't have a call expression in them
</details>

pkg-pr-new[bot]: 
[Open in Stackblitz](https://pkg.pr.new/template/a4c007a5-b11e-4bdc-94db-44c827074d32)


<details><summary><b>@alloy-js/babel-plugin</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-plugin@60
```

</p></details>
      
    

<details><summary><b>@alloy-js/babel-plugin-jsx-dom-expressions</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-plugin-jsx-dom-expressions@60
```

</p></details>
      
    

<details><summary><b>@alloy-js/core</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/core@60
```

</p></details>
      
    

<details><summary><b>@alloy-js/babel-preset</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-preset@60
```

</p></details>
      
    

<details><summary><b>@alloy-js/csharp</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/csharp@60
```

</p></details>
      
    

<details><summary><b>@alloy-js/java</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/java@60
```

</p></details>
      
    

<details><summary><b>@alloy-js/json</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/json@60
```

</p></details>
      
    

<details><summary><b>@alloy-js/prettier-plugin-alloy</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/prettier-plugin-alloy@60
```

</p></details>
      
    

<details><summary><b>@alloy-js/typescript</b></summary><p>

```
npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/typescript@60
```

</p></details>
      
    

_commit: <a href="https://github.com/alloy-framework/alloy/runs/38432525407"><code>3e7efb7</code></a>_


Patch:
diff --git a/.chronus/changes/fix-member-chain-without-call-2025-2-8-14-30-57.md b/.chronus/changes/fix-member-chain-without-call-2025-2-8-14-30-57.md
new file mode 100644
index 0000000..bde860b
--- /dev/null
+++ b/.chronus/changes/fix-member-chain-without-call-2025-2-8-14-30-57.md
@@ -0,0 +1,7 @@
+---
+changeKind: fix
+packages:
+  - "@alloy-js/typescript"
+---
+
+Fix member chains that don't have a call expression in them
\ No newline at end of file
diff --git a/packages/typescript/src/components/MemberChainExpression.tsx b/packages/typescript/src/components/MemberChainExpression.tsx
index 20d09a2..51eabd9 100644
--- a/packages/typescript/src/components/MemberChainExpression.tsx
+++ b/packages/typescript/src/components/MemberChainExpression.tsx
@@ -37,6 +37,10 @@ export function MemberChainExpression(props: MemberChainExpressionProps) {
       }
     }
 
+    if (currentChunk.length > 0) {
+      chunks.push(currentChunk);
+    }
+
     return [chunks[0], chunks.slice(1)];
   });
 


Test patch:
diff --git a/packages/typescript/test/member-chain.test.tsx b/packages/typescript/test/member-chain.test.tsx
index a4fcc20..11982d8 100644
--- a/packages/typescript/test/member-chain.test.tsx
+++ b/packages/typescript/test/member-chain.test.tsx
@@ -69,3 +69,18 @@ it("works with nested call member chains", () => {
       .array()
   `);
 });
+
+it("works without function call expressions", () => {
+  expect(
+    toSourceText(
+      <MemberChainExpression>
+        <>z</>
+        <>string</>
+        <>min</>
+      </MemberChainExpression>,
+      { printWidth: 5 },
+    ),
+  ).toBe(d`
+    z.string.min
+  `);
+});