mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 13:33:11 +00:00
fix: resolve TypeScript type errors in autofix tests
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<string, unknown>`,
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 <noreply@anthropic.com>
This commit is contained in:
@@ -118,7 +118,8 @@ describe('Integration: handleAutofixWorkflow', () => {
|
|||||||
|
|
||||||
// Verify workflow not modified (fetch it back)
|
// Verify workflow not modified (fetch it back)
|
||||||
const fetched = await client.getWorkflow(created.id!);
|
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 {
|
} else {
|
||||||
// No fixes available - that's also a valid result
|
// No fixes available - that's also a valid result
|
||||||
expect(data.message).toContain('No automatic fixes available');
|
expect(data.message).toContain('No automatic fixes available');
|
||||||
@@ -240,7 +241,8 @@ describe('Integration: handleAutofixWorkflow', () => {
|
|||||||
|
|
||||||
// Verify workflow was actually modified
|
// Verify workflow was actually modified
|
||||||
const fetched = await client.getWorkflow(created.id!);
|
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)
|
// Expression format should be fixed (depends on what fixes were available)
|
||||||
expect(setValue).toBeDefined();
|
expect(setValue).toBeDefined();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user