From fe77b4e3a87b7096f4a3de37f086eeb821b0a9cf Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 14:52:58 +0000 Subject: [PATCH] fix: add optional chaining to ls_files tests for TypeScript strict null checks - Follow patterns from read-files and edit-files tests - Use optional chaining (?.) for array access to handle 'Object is possibly undefined' errors - Fixes CI TypeScript compilation errors on lines 54, 55, 56, 65, 141, 142, 143 Co-Authored-By: Dallin Bentley --- .../file-tools/ls-files-tool/ls-files-impl.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/ai/src/tools/file-tools/ls-files-tool/ls-files-impl.test.ts b/packages/ai/src/tools/file-tools/ls-files-tool/ls-files-impl.test.ts index ed946d145..a4e2266ad 100644 --- a/packages/ai/src/tools/file-tools/ls-files-tool/ls-files-impl.test.ts +++ b/packages/ai/src/tools/file-tools/ls-files-tool/ls-files-impl.test.ts @@ -51,9 +51,9 @@ drwxr-xr-x 2 user group 4096 Jan 15 10:31 directory1`; const result = await lsFilesSafely(['/test/path'], options); expect(result).toHaveLength(1); - expect(result[0].success).toBe(true); - expect(result[0].entries).toHaveLength(2); - expect(result[0].entries?.[0]).toEqual({ + expect(result[0]?.success).toBe(true); + expect(result[0]?.entries).toHaveLength(2); + expect(result[0]?.entries?.[0]).toEqual({ name: 'file1.txt', type: 'file', size: '1024', @@ -62,7 +62,7 @@ drwxr-xr-x 2 user group 4096 Jan 15 10:31 directory1`; owner: 'user', group: 'group', }); - expect(result[0].entries?.[1]).toEqual({ + expect(result[0]?.entries?.[1]).toEqual({ name: 'directory1', type: 'directory', size: '4096', @@ -138,9 +138,9 @@ drwxr-xr-x 2 user group 4096 Jan 15 10:31 directory1`; const result = await lsFilesSafely(['/good/path', '/bad/path']); expect(result).toHaveLength(2); - expect(result[0].success).toBe(true); - expect(result[1].success).toBe(false); - expect(result[1].error).toBe('Path not found'); + expect(result[0]?.success).toBe(true); + expect(result[1]?.success).toBe(false); + expect(result[1]?.error).toBe('Path not found'); }); });