Skip to content

[@mantine/form] Fix missing TS suggestions for path in clearFieldError, resetField, clearFieldDirty#8810

Merged
rtivital merged 2 commits into
mantinedev:masterfrom
semimikoh:fix/form-field-path-types
Apr 6, 2026
Merged

[@mantine/form] Fix missing TS suggestions for path in clearFieldError, resetField, clearFieldDirty#8810
rtivital merged 2 commits into
mantinedev:masterfrom
semimikoh:fix/form-field-path-types

Conversation

@semimikoh

Copy link
Copy Markdown
Contributor

Fixes #8808

Problem

clearFieldError and resetField have path parameters typed as unknown and PropertyKey, which disables TypeScript autocomplete for form values. This is inconsistent with setFieldValue, setFieldError, and validateField, which use LooseKeys<Values> and provide proper suggestions.

Fix

Aligned the path parameter type across the form API by using the LooseKeys<Values> generic:

Function Before After
clearFieldError (path: unknown) => void <Field extends LooseKeys<Values>>(path: Field) => void
resetField (path: PropertyKey) => void <Field extends LooseKeys<Values>>(path: Field) => void
clearFieldDirty (path: unknown) => void <Field extends LooseKeys<Values>>(path: Field) => void

clearFieldDirty wasn't mentioned in the original issue but had the same problem, so I included it for consistency with the rest of the form API. Its runtime implementation (getPath-based, same as setFieldValue) already supports nested paths, so the type change reflects actual behavior.

Testing

  • Type check passes (tsc --noEmit)
  • All 389 @mantine/form tests pass
  • Lint/format clean
  • Verified the bug reproduces in the Stackblitz from the issue (no autocomplete on clearFieldError / resetField)
  • Fix verified via local type check against the same usage pattern

…ield, clearFieldDirty

Align path parameter types with setFieldValue/setFieldError/validateField
by using LooseKeys<Values> generic instead of unknown/PropertyKey.

clearFieldDirty had the same issue and was included for consistency.

Fixes mantinedev#8808
@semimikoh semimikoh changed the title fix(form): provide TS suggestions for path in clearFieldError, resetField, clearFieldDirty [@mantine/form] Fix missing TS suggestions for path in clearFieldError, resetField, clearFieldDirty Apr 6, 2026
@rtivital rtivital merged commit 88d07ad into mantinedev:master Apr 6, 2026
1 check passed
@rtivital

rtivital commented Apr 6, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mantine/form some field functions don't provide TS suggestions for path parameter

2 participants