-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Property 'getFieldset' does not exist on type 'FieldMetadata' #499
Comments
Can you please share your zod schema? |
I'm seeing the same issue upgrading from v1.0.0 to v1.0.2. Here's a short repro: TypeScript playground import { useField } from "@conform-to/react";
interface Schema {
foo: string;
}
() => {
const [{ getFieldset }] = useField<Schema>("name");
// ^ Property 'getFieldset' does not exist on type 'FieldMetadata<Schema, Record<string, unknown>, string[]>'.
const { foo } = getFieldset();
};
// Workaround
() => {
const [{ getFieldset }] = useField<{ foo: string }>("name");
const { foo } = getFieldset();
}; The problem is that an (Edit: I see this change alone wouldn't solve OP's problem, since that schema is nullable. I don't understand why an entire schema would ever be |
I have never thought about this 🤔 Interesting.
Feel free to submit a PR if you have any ideas. I did some changes to improve the type inference on #459 recently but I am also uncertain if I covered all possible cases.
I think part of the issue is the same as #478 in which TS infers the schema based on the default value instead. But your solution looks good to me. |
@edmundhung, I've filed #508 with the solution I described, plus updated tests. |
Thank you @aaronadamsCA! I am busy with something else right now but I wish to come back to it later this week and will likely cut a release with a few other fixes. :) |
Apologies for the delayed response. I've observed that the issue arises when a default value is supplied in an incorrect format. However, it's unclear why this impacts |
Yes I can confirm the type infer is from the default value type. if we properly type the field in question as an object, |
Describe the bug and the expected behavior
I have a simple form:
The LSP and
lint
does not report an error. However,typecheck
is:Conform version
1.0.2
Steps to Reproduce the Bug or Issue
Run
typecheck
while usinggetFieldset
What browsers are you seeing the problem on?
No response
Screenshots or Videos
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: