-
-
Notifications
You must be signed in to change notification settings - Fork 607
fix: prevent initialFormState from overriding client values during merge #2096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
|
|
||
| expect(clientState.values).toEqual({ name: 'client-name' }) | ||
| }) | ||
| }) | ||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add description to ESLint requires a description explaining why the type suppression is necessary. Consider using Proposed fix- // `@ts-ignore`
+ // `@ts-expect-error` - Testing with simplified mock state that doesn't match full ServerFormState type
mutateMergeDeep(clientState, initialFormState)📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 17-17: Include a description after the "@ts-ignore" directive to explain why the ( 🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| expect(clientState.values).toEqual({ name: 'client-name' }) | ||||||||||
| }) | ||||||||||
| }) | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add description to
@ts-ignoredirective.Same issue as in the Remix test file. ESLint requires a description for the type suppression.
Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 ESLint
[error] 17-17: Include a description after the "@ts-ignore" directive to explain why the
@ts-ignoreis necessary. The description must be 3 characters or longer.(
@typescript-eslint/ban-ts-comment)🤖 Prompt for AI Agents