ui icon indicating copy to clipboard operation
ui copied to clipboard

[bug]: Typescript error in form component

Open kadeau-devteam opened this issue 1 year ago • 1 comments
trafficstars

Describe the bug

There is typescript errors within form component.

Property formState does not exist in useFormContext.

Than for part

const fieldState = getFieldState(fieldContext.name, formState)

getFieldState expect no arguments.

Than later we have error with usage of: const { error, formItemId } = useFormField().

TS2339: Property error does not exist on type { id: string; name: string; formItemId: string; formDescriptionId: string; formMessageId: string; }

Error in typescript brake process build for Nextjs.

Affected component/components

Form

How to reproduce

Test form component within nextjs application.

Codesandbox/StackBlitz link

No response

Logs

next build

  ▲ Next.js 14.2.4
  - Environments: .env.local

   Creating an optimized production build ...
 ⚠ For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended. Run 'npm i sharp', and Next.js will use it automatically for Image Optimization.
Read more: https://nextjs.org/docs/messages/sharp-missing-in-production
 ⚠ For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended. Run 'npm i sharp', and Next.js will use it automatically for Image Optimization.
Read more: https://nextjs.org/docs/messages/sharp-missing-in-production
 ✓ Compiled successfully
   Linting and checking validity of types  .Failed to compile.

./src/components/ui/form.tsx:45:26
Type error: Property 'formState' does not exist on type '{ getFieldState: () => {}; getValues: () => {}; watch: () => {}; setValue: () => {}; register: () => {}; }'.

  43 |   const fieldContext = React.useContext(FormFieldContext)
  44 |   const itemContext = React.useContext(FormItemContext)
> 45 |   const { getFieldState, formState } = useFormContext()
     |                          ^
  46 |
  47 |   const fieldState = getFieldState(fieldContext.name, formState)
  48 |
 ELIFECYCLE  Command failed with exit code 1.

System Info

Linux Mint, nodejs v22.11.0, nextjs 14.2.4

Before submitting

  • [X] I've made research efforts and searched the documentation
  • [X] I've searched for existing issues

kadeau-devteam avatar Nov 14 '24 12:11 kadeau-devteam

This issue has been automatically marked as stale due to one year of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you. (This is an automated message)

shadcn avatar Nov 14 '25 23:11 shadcn