Skip to content

fix: export WrapperProps to fix TS2883 with declaration emit#760

Open
ThibautMarechal wants to merge 1 commit into
formsy:masterfrom
ThibautMarechal:fix/export-wrapper-props
Open

fix: export WrapperProps to fix TS2883 with declaration emit#760
ThibautMarechal wants to merge 1 commit into
formsy:masterfrom
ThibautMarechal:fix/export-wrapper-props

Conversation

@ThibautMarechal

@ThibautMarechal ThibautMarechal commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #759

What

Export WrapperProps from the main formsy-react entry point.

- export type { PassDownProps as FormsyInjectedProps, InjectedProps };
+ export type { PassDownProps as FormsyInjectedProps, InjectedProps, WrapperProps };

Why

The return type of withFormsy<T, V> is:

React.ComponentType<Omit<T & WrapperProps<V>, keyof InjectedProps<V>>>

When a project has declaration: true (or composite: true) in tsconfig, TypeScript must write this type into the generated .d.ts file. Because WrapperProps is only reachable via the internal dist/withFormsy path and not the main entry, TypeScript raises TS2883 on every exported component:

error TS2883: The inferred type of 'MyInput' cannot be named without a reference to
'WrapperProps' from '../../node_modules/formsy-react/dist/withFormsy'.
This is likely not portable. A type annotation is necessary.

Exporting WrapperProps from the main entry gives TypeScript a portable name to reference, eliminating the error without any changes required in consumer code.

Impact

  • Non-breaking: purely additive type export.
  • No runtime change: type-only export, zero JS output diff.
  • WrapperProps is already part of the implicit public API (it describes exactly what every consumer must pass to a withFormsy-wrapped component); making it explicit is an improvement.

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.

Export WrapperProps from main entry to fix TS2883 in projects with declaration emit

1 participant