Skip to content

fix(form-core): export FormListenerFieldProps to fix TS4023 declaration emit#2219

Open
mixelburg wants to merge 1 commit into
TanStack:mainfrom
mixelburg:fix/export-form-listener-props-type
Open

fix(form-core): export FormListenerFieldProps to fix TS4023 declaration emit#2219
mixelburg wants to merge 1 commit into
TanStack:mainfrom
mixelburg:fix/export-form-listener-props-type

Conversation

@mixelburg

@mixelburg mixelburg commented Jun 20, 2026

Copy link
Copy Markdown

Fixes #2210

Extract the inline {formApi, fieldApi} callback props type from FormListeners into a named exported FormListenerFieldProps interface.

Previously, exporting a formOptions() result that included listeners failed with TS4023 because TypeScript could not serialize the anonymous inline type into a .d.ts file. By giving the type an explicit name and exporting it, declaration emit can now reference it directly.

All 438 tests pass across TS 5.4–5.8.

Summary by CodeRabbit

  • Refactor
    • Form listener callback types have been updated to use a unified type structure, ensuring consistent generic type parameters across onChange, onBlur, and onFieldUnmount callbacks. This improves overall type safety and consistency for developers working with form event handlers.

…on emit

Extract the inline {formApi, fieldApi} callback props type from
FormListeners into a named exported FormListenerFieldProps interface.
Previously, exporting a formOptions() result that included listeners
failed with TS4023 because TypeScript could not serialize the anonymous
type into a .d.ts file.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e22ef611-df21-45dc-ac18-efd71beff5b0

📥 Commits

Reviewing files that changed from the base of the PR and between 6a73479 and 4f6556d.

📒 Files selected for processing (1)
  • packages/form-core/src/FormApi.ts

📝 Walkthrough

Walkthrough

Adds a new exported generic interface FormListenerFieldProps to FormApi.ts that bundles formApi and fieldApi into a single named type. Updates FormListeners' three field-level callback props (onChange, onBlur, onFieldUnmount) to use this interface instead of inline anonymous object types.

Changes

FormListenerFieldProps export and FormListeners refactor

Layer / File(s) Summary
FormListenerFieldProps interface and FormListeners callback updates
packages/form-core/src/FormApi.ts
Introduces the exported FormListenerFieldProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta> interface with formApi and fieldApi fields, then replaces the previously-inline { formApi; fieldApi } prop types in FormListeners.onChange, FormListeners.onBlur, and FormListeners.onFieldUnmount with references to FormListenerFieldProps<...>.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 A type hid inside, unnamed and unseen,
TS4023 made declarations scream.
I hopped to the source, carved an interface neat,
FormListenerFieldProps — now export complete!
No more hidden names to trip up the emit,
Declarations flow free, and the types finally fit. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: exporting FormListenerFieldProps to fix the TS4023 declaration emit error.
Description check ✅ Passed The PR description adequately explains the problem, solution, and validation. It references the linked issue, describes the extraction of the type, and mentions test coverage across TypeScript versions.
Linked Issues check ✅ Passed The code changes directly address issue #2210 by extracting and exporting FormListenerFieldProps, allowing TypeScript declaration emit to properly serialize the listener callback types.
Out of Scope Changes check ✅ Passed All changes in FormApi.ts are directly related to resolving the TS4023 declaration emit issue by introducing the FormListenerFieldProps export and updating FormListeners accordingly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/export-form-listener-props-type

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Successfully merging this pull request may close these issues.

Exported formOptions with listeners fails declaration emit: FormListenersPropsField cannot be named

1 participant