From a696af8cfa8a33402af436a1aee84c0d1fd4bc93 Mon Sep 17 00:00:00 2001 From: czlonkowski <56956555+czlonkowski@users.noreply.github.com> Date: Sun, 5 Oct 2025 09:49:24 +0200 Subject: [PATCH] fix: resolve TypeScript type errors in autofix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes TypeScript compilation errors identified by typecheck: - Error TS2571: Object is of type 'unknown' (lines 121, 243) ## Problem The `parameters` field in WorkflowNode is typed as `Record`, causing TypeScript to see deeply nested property accesses as `unknown` type. ## Solution Added explicit type assertions when accessing Set node parameters: ```typescript // Before (fails typecheck): const value = fetched.nodes[1].parameters.assignments.assignments[0].value; // After (passes typecheck): const params = fetched.nodes[1].parameters as { assignments: { assignments: Array<{ value: unknown }> } }; const value = params.assignments.assignments[0].value; ``` ## Verification - ✅ `npm run typecheck` passes with no errors - ✅ `npm run lint` passes with no errors - ✅ All 28 tests passing (12 validation + 16 autofix) - ✅ No regressions introduced This maintains type safety while properly handling the dynamic nature of n8n node parameters. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../integration/n8n-api/workflows/autofix-workflow.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/n8n-api/workflows/autofix-workflow.test.ts b/tests/integration/n8n-api/workflows/autofix-workflow.test.ts index cc015c0..192b3b6 100644 --- a/tests/integration/n8n-api/workflows/autofix-workflow.test.ts +++ b/tests/integration/n8n-api/workflows/autofix-workflow.test.ts @@ -118,7 +118,8 @@ describe('Integration: handleAutofixWorkflow', () => { // Verify workflow not modified (fetch it back) const fetched = await client.getWorkflow(created.id!); - expect(fetched.nodes[1].parameters.assignments.assignments[0].value).toBe('$json.data'); + const params = fetched.nodes[1].parameters as { assignments: { assignments: Array<{ value: string }> } }; + expect(params.assignments.assignments[0].value).toBe('$json.data'); } else { // No fixes available - that's also a valid result expect(data.message).toContain('No automatic fixes available'); @@ -240,7 +241,8 @@ describe('Integration: handleAutofixWorkflow', () => { // Verify workflow was actually modified const fetched = await client.getWorkflow(created.id!); - const setValue = fetched.nodes[1].parameters.assignments.assignments[0].value; + const params = fetched.nodes[1].parameters as { assignments: { assignments: Array<{ value: unknown }> } }; + const setValue = params.assignments.assignments[0].value; // Expression format should be fixed (depends on what fixes were available) expect(setValue).toBeDefined(); } else {