You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use this schema to build a form in Qwik, but I'm having difficulties taming the Typescript compiler because it's always inferring that features is an undefined field or never.
Here's a minimal example to illustrate this issue:
src/components/map/places/add-place-modal.tsx:218:23 - error TS2322: Type 'string' is not assignable to type 'undefined'.
218 type="string[]"
~~~~
../../node_modules/@modular-forms/qwik/dist/types/components/Field.d.ts:20:5
20 type: FieldType<FieldPathValue<TFieldValues, TFieldName>>;
~~~~
The expected type comes from property 'type' which is declared here on type 'IntrinsicAttributes & Pick<Partial<Omit<FieldProps<{ name: string; coordinates: { latitude: number; longitude: number; }; features: ("workspace" | "skiing" | "snowshoeing" | "nordic-skiing" | ... 8 more ... | "bathroom")[]; placeType: "activity"; link?: string | undefined; th...'
src/components/map/places/add-place-modal.tsx:225:49 - error TS2339: Property 'includes' does not exist on type 'never'.
225 checked={field.value?.includes(feature)}
Do you have an (elegant) recommendation on how to satisfy the compiler and let it know that we want a specific variant of the form in that case?
The text was updated successfully, but these errors were encountered:
Yes, this is a problem with the current implementation of Modular Forms, which I will fix when I rewrite the library. To satisfy the compiler, you could add features: v.undefined() wherever features is not needed. The initial object structure for .loader is needed to initialize the form store.
Let's say I have the following schema with multiple variants requiring different fields based on the
placeType
field.Here's the simplified version so I can better refer to it below:
I want to use this schema to build a form in Qwik, but I'm having difficulties taming the Typescript compiler because it's always inferring that
features
is anundefined
field ornever
.Here's a minimal example to illustrate this issue:
Which will yield the following errors:
Do you have an (elegant) recommendation on how to satisfy the compiler and let it know that we want a specific variant of the form in that case?
The text was updated successfully, but these errors were encountered: