Skip to content
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

value binding from Form.Field is not properly narrowed from generic type #990

Open
fnimick opened this issue Apr 4, 2024 · 0 comments
Open

Comments

@fnimick
Copy link
Contributor

fnimick commented Apr 4, 2024

Describe the bug

For some reason, using the same form object directly with FormPrimitive.Field from formsnap correctly narrows the type for the value prop, but using it with Form.Field from shadcn does not.

This works:

<FormPrimitive.Field {form} name="username" let:value>

(value is now the correct type of of the field from the form definition)

This does not:

<Form.Field {form} name="username" let:value>

(value is unknown)

Reproduction

https://stackblitz.com/edit/github-dsnve4?file=src%2Froutes%2F%2Bpage.svelte,src%2Froutes%2F%2Bpage.server.ts

It doesn't show inline, but run npm run check and the error will appear for the <Form.Field> case.

Logs

No response

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 29.20 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.0 - ~/.asdf/installs/nodejs/18.19.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 10.2.3 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 123.0.6312.105
    Safari: 17.4.1
  npmPackages:
    @sveltejs/kit: ^2.5.0 => 2.5.0 
    bits-ui: ^0.21.2 => 0.21.2 
    formsnap: ^1.0.0 => 1.0.0 
    lucide-svelte: ^0.364.0 => 0.364.0 
    svelte: ^4.2.11 => 4.2.11 
    sveltekit-superforms: ^2.12.2 => 2.12.2

Severity

annoyance

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

No branches or pull requests

1 participant