Skip to content

feat: export ReactFormApi for better typescript package support #868

Merged
Balastrong merged 4 commits into
TanStack:mainfrom
Makisuo:patch-1
Aug 5, 2024
Merged

feat: export ReactFormApi for better typescript package support #868
Balastrong merged 4 commits into
TanStack:mainfrom
Makisuo:patch-1

Conversation

@Makisuo

@Makisuo Makisuo commented Jul 18, 2024

Copy link
Copy Markdown
Contributor

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.

@nx-cloud

nx-cloud Bot commented Jul 20, 2024

Copy link
Copy Markdown

☁️ 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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2024

Copy link
Copy Markdown

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

timon-kosmoy commented Jul 23, 2024

Copy link
Copy Markdown

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
Copy Markdown

@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>;
  };
}

@codecov

codecov Bot commented Aug 5, 2024

Copy link
Copy Markdown

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.

@Balastrong Balastrong left a comment

Copy link
Copy Markdown
Member

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