Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export ReactFormApi for better typescript package support #868

Merged
merged 4 commits into from
Aug 5, 2024

Conversation

Makisuo
Copy link
Contributor

@Makisuo Makisuo commented Jul 18, 2024

This solves the following Typescript error when building a react typescript package exporting useForm.

has or is using name 'ReactFormApi' from external module @tanstack/react-form" but cannot be named.

Copy link

nx-cloud bot commented Jul 20, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 497fdac. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

Copy link

pkg-pr-new bot commented Jul 20, 2024

commit: 497fdac

pnpm add https://pkg.pr.new/@tanstack/angular-form@868
pnpm add https://pkg.pr.new/@tanstack/form-core@868
pnpm add https://pkg.pr.new/@tanstack/lit-form@868
pnpm add https://pkg.pr.new/@tanstack/react-form@868
pnpm add https://pkg.pr.new/@tanstack/solid-form@868
pnpm add https://pkg.pr.new/@tanstack/valibot-form-adapter@868
pnpm add https://pkg.pr.new/@tanstack/vue-form@868
pnpm add https://pkg.pr.new/@tanstack/yup-form-adapter@868
pnpm add https://pkg.pr.new/@tanstack/zod-form-adapter@868

Open in Stackblitz

More templates

@timon-kosmoy
Copy link

timon-kosmoy commented Jul 23, 2024

Please also export the ReactFieldApi and export them both also from the index.ts main module so that they can be consumed by users of the library.

EDIT: this issue is now breaking our builds

@mistyharsh
Copy link

@timon-kosmoy If you need a temporary workaround and do not wish to change the code, you can do the module augmentation as follows:

// <REPO>/src/augment.d.ts

// Important for module augmentation
import * as form from '@tanstack/react-form';

declare module '@tanstack/react-form' {
  import { FormApi, FieldComponent } from '@tanstack/react-form';

  export interface FormApi<TFormData, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined> {
    Field: FieldComponent<TFormData, TFormValidator>;
  };
}

Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.37%. Comparing base (5473bb8) to head (497fdac).
Report is 77 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #868       +/-   ##
===========================================
- Coverage   91.55%   43.37%   -48.19%     
===========================================
  Files          21       10       -11     
  Lines         900       83      -817     
  Branches      206       11      -195     
===========================================
- Hits          824       36      -788     
+ Misses         71       42       -29     
  Partials        5        5               

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Balastrong Balastrong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're probably going to export this anyway in #825 without breaking changes so let's get this merged :)

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.

5 participants