form icon indicating copy to clipboard operation
form copied to clipboard

Cannot refer to FiledInfo of tanstack form with ReturnType

Open k70suK3-k06a7ash1 opened this issue 1 year ago • 0 comments

Describe the bug

const useCustomForm = () => {
  // Custom form logic
  const form = useFrom();
  // Return form object
  return { form }
}

const useSomething = () => {
  type FormProperties = ReturnType<typeof useCustomForm>['form']['fieldInfo'];

  const handleSomething = (from: FieldApi<FormProperties, 'photo', undefined, undefined, string>) => {
    // Handle something logic
  }

  // Return handleSomething function
  return { handleSomething }
}

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/inspiring-dew-c7y3rl

Steps to reproduce

Image

Expected behavior

Expect tsc --noEmit to pass

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

  • OS [masOS]

TanStack Form adapter

None

TanStack Form version

0.33.0

TypeScript version

5.5.3

Additional context

No response

k70suK3-k06a7ash1 avatar Oct 13 '24 20:10 k70suK3-k06a7ash1