Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/cool-jars-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@tanstack/svelte-form': patch
'@tanstack/react-form': patch
'@tanstack/solid-form': patch
'@tanstack/vue-form': patch
---

add AnyFormApi types for convenience in generic contexts
36 changes: 36 additions & 0 deletions packages/react-form/src/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ export interface ReactFormApi<
}) => ReactNode
}

/**
* {@link ReactFormApi} with all generics set to `any` for convenience use in generic contexts.
*/
export type AnyReactFormApi = ReactFormApi<
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any
>

/**
* An extended version of the `FormApi` class that includes React-specific functionalities from `ReactFormApi`
*/
Expand Down Expand Up @@ -135,6 +153,24 @@ export type ReactFormExtendedApi<
TSubmitMeta
>

/**
* {@link ReactFormExtendedApi} with all generics set to `any` for convenience use in generic contexts.
*/
export type AnyReactFormExtendedApi = ReactFormExtendedApi<
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any
>

function LocalSubscribe({
form,
selector,
Expand Down
39 changes: 38 additions & 1 deletion packages/solid-form/src/createForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,25 @@ export interface SolidFormApi<
}

/**
* An extended version of the `FormApi` class that includes React-specific functionalities from `ReactFormApi`
* {@link SolidFormApi} with all generics set to `any` for convenience use in generic contexts.
*/
export type AnySolidFormApi = SolidFormApi<
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any
>

/**
* An extended version of the `FormApi` class that includes Solid-specific functionalities from `SolidFormApi`
*/
export type SolidFormExtendedApi<
TFormData,
Expand Down Expand Up @@ -170,6 +188,25 @@ export type SolidFormExtendedApi<
TOnServer,
TSubmitMeta
>

/**
* {@link SolidFormExtendedApi} with all generics set to `any` for convenience use in generic contexts.
*/
export type AnySolidFormExtendedApi = SolidFormExtendedApi<
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any
>

export function createForm<
TParentData,
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
Expand Down
18 changes: 18 additions & 0 deletions packages/svelte-form/src/createForm.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ export interface SvelteFormApi<
WithoutFunction<Component>
}

/**
* {@link SvelteFormApi} with all generics set to `any` for convenience use in generic contexts.
*/
export type AnySvelteFormApi = SvelteFormApi<
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any
>

export function createForm<
TParentData,
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
Expand Down
6 changes: 5 additions & 1 deletion packages/svelte-form/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ export * from '@tanstack/form-core'

export { useStore } from '@tanstack/svelte-store'

export { createForm, type SvelteFormApi } from './createForm.svelte.js'
export {
createForm,
type SvelteFormApi,
type AnySvelteFormApi,
} from './createForm.svelte.js'

export { default as Field, createField } from './Field.svelte'

Expand Down
18 changes: 18 additions & 0 deletions packages/vue-form/src/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,24 @@ export interface VueFormApi<
>
}

/**
* {@link VueFormApi} with all generics set to `any` for convenience use in generic contexts.
*/
export type AnyVueFormApi = VueFormApi<
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any,
any
>

export function useForm<
TParentData,
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
Expand Down