Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/react-form-nextjs/src/createServerValidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,5 @@ export const initialFormState: ServerFormState<any, undefined> = {
errorMap: {
onServer: undefined,
},
values: undefined,
errors: [],
}
} as unknown as ServerFormState<any, undefined>
22 changes: 22 additions & 0 deletions packages/react-form-nextjs/tests/createServerValidate.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, expect, it } from 'vitest'
import { mutateMergeDeep } from '@tanstack/react-form'
import { initialFormState } from '../src/createServerValidate'

describe('initialFormState', () => {
it('should not contain values property', () => {
expect(initialFormState).not.toHaveProperty('values')
})

it('should not override client values when merged', () => {
const clientState = {
values: { name: 'client-name' },
errors: [],
errorMap: {}
}

// @ts-ignore
mutateMergeDeep(clientState, initialFormState)
Comment on lines +17 to +18
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add description to @ts-ignore directive.

Same issue as in the Remix test file. ESLint requires a description for the type suppression.

Proposed fix
-    // `@ts-ignore`
+    // `@ts-expect-error` - Testing with simplified mock state that doesn't match full ServerFormState type
     mutateMergeDeep(clientState, initialFormState)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// @ts-ignore
mutateMergeDeep(clientState, initialFormState)
// `@ts-expect-error` - Testing with simplified mock state that doesn't match full ServerFormState type
mutateMergeDeep(clientState, initialFormState)
🧰 Tools
🪛 ESLint

[error] 17-17: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-form-nextjs/tests/createServerValidate.spec.tsx` around lines
17 - 18, Add a descriptive reason to the existing TypeScript suppression above
the mutateMergeDeep(clientState, initialFormState) call: replace the bare "//
`@ts-ignore`" with a comment that includes the TS error code and a short
justification (e.g., indicating this is intentional test-only mismatch of
types), or alternatively use "// eslint-disable-next-line
`@typescript-eslint/ban-ts-comment` -- <reason>" style; ensure the comment
directly precedes the mutateMergeDeep invocation so ESLint recognizes the
description.


expect(clientState.values).toEqual({ name: 'client-name' })
})
})
3 changes: 1 addition & 2 deletions packages/react-form-remix/src/createServerValidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,5 @@ export const initialFormState: ServerFormState<any, undefined> = {
errorMap: {
onServer: undefined,
},
values: undefined,
errors: [],
}
} as unknown as ServerFormState<any, undefined>
22 changes: 22 additions & 0 deletions packages/react-form-remix/tests/createServerValidate.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, expect, it } from 'vitest'
import { mutateMergeDeep } from '@tanstack/react-form'
import { initialFormState } from '../src/createServerValidate'

describe('initialFormState', () => {
it('should not contain values property', () => {
expect(initialFormState).not.toHaveProperty('values')
})

it('should not override client values when merged', () => {
const clientState = {
values: { name: 'client-name' },
errors: [],
errorMap: {}
}

// @ts-ignore
mutateMergeDeep(clientState, initialFormState)
Comment on lines +17 to +18
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add description to @ts-ignore directive.

ESLint requires a description explaining why the type suppression is necessary. Consider using @ts-expect-error which is preferred as it will error if the suppression becomes unnecessary.

Proposed fix
-    // `@ts-ignore`
+    // `@ts-expect-error` - Testing with simplified mock state that doesn't match full ServerFormState type
     mutateMergeDeep(clientState, initialFormState)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// @ts-ignore
mutateMergeDeep(clientState, initialFormState)
// `@ts-expect-error` - Testing with simplified mock state that doesn't match full ServerFormState type
mutateMergeDeep(clientState, initialFormState)
🧰 Tools
🪛 ESLint

[error] 17-17: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.

(@typescript-eslint/ban-ts-comment)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-form-remix/tests/createServerValidate.spec.tsx` around lines
17 - 18, Replace the bare "// `@ts-ignore`" above the call to
mutateMergeDeep(clientState, initialFormState) with a documented suppression or
preferred directive: either use "// `@ts-expect-error` -- <reason why types are
incompatible at runtime>" to ensure the suppression fails if types become
compatible, or keep "// `@ts-ignore` -- <explicit reason>" explaining why the type
error is acceptable here; make sure the comment references the mutateMergeDeep
call and why clientState/initialFormState type mismatch is intentionally
ignored.


expect(clientState.values).toEqual({ name: 'client-name' })
})
})