diff --git a/.changeset/shaky-bobcats-dig.md b/.changeset/shaky-bobcats-dig.md new file mode 100644 index 000000000000..09007d960285 --- /dev/null +++ b/.changeset/shaky-bobcats-dig.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: improves fields type for generic components diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index ce45549aa6b3..8a49431b50a5 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -15,7 +15,8 @@ import { PrerenderUnseenRoutesHandlerValue, PrerenderOption, RequestOptions, - RouteSegment + RouteSegment, + IsAny } from '../types/private.js'; import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from 'types'; import { SvelteConfig } from '@sveltejs/vite-plugin-svelte'; @@ -1949,6 +1950,18 @@ type UnknownField = RemoteFormFieldMethods & { [key: string | number]: UnknownField; }; +type RemoteFormFieldsRoot = + IsAny extends true + ? RecursiveFormFields + : Input extends void + ? { + /** Validation issues, if any */ + issues(): RemoteFormIssue[] | undefined; + /** Validation issues belonging to this or any of the fields that belong to it, if any */ + allIssues(): RemoteFormIssue[] | undefined; + } + : RemoteFormFields; + /** * Recursive type to build form fields structure with proxy access */ @@ -2073,7 +2086,7 @@ export type RemoteForm = { /** The number of pending submissions */ get pending(): number; /** Access form fields using object notation */ - fields: RemoteFormFields; + fields: RemoteFormFieldsRoot; /** Spread this onto a `