@mittwald/flow-react-components 1.2.0-next.1 → 1.2.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/MIGRATION.md CHANGED
@@ -774,9 +774,41 @@ prop. At runtime the old prop still works: `Action` maps it to `onAction` and
774
774
  logs a deprecation warning, and an explicit `onAction` wins. The fallback will
775
775
  be removed in a future major version.
776
776
 
777
- A codemod renames the prop on `Action`.
777
+ #### The type changed too
778
778
 
779
- **Apply:** Rename the `action` prop on `Action` to `onAction`.
779
+ `onAction` is typed `ActionFn`, which is `(...args: unknown[]) => unknown`. A
780
+ function that declares a parameter of any narrower type is not assignable to it,
781
+ because the parameter would receive `unknown`:
782
+
783
+ ```
784
+ Type '(options?: CloseOptions | undefined) => void' is not assignable to type 'ActionFn'.
785
+ Types of parameters 'options' and 'args' are incompatible.
786
+ Type 'unknown' is not assignable to type 'CloseOptions | undefined'.
787
+ ```
788
+
789
+ Wrap the call instead of passing the reference:
790
+
791
+ ```diff
792
+ - <Action onAction={controller.close}>
793
+ + <Action onAction={() => controller.close()}>
794
+ ```
795
+
796
+ Only function **references** are affected. An inline arrow
797
+ (`onAction={() => …}`), a zero-parameter function, and anything already
798
+ accepting `unknown` are all fine.
799
+
800
+ A codemod renames the prop. It deliberately does not wrap: whether the
801
+ referenced function declares a parameter cannot be decided from the source —
802
+ that needs type information — and wrapping everything would silently drop the
803
+ arguments `Action` passes to handlers that do accept them.
804
+
805
+ **Apply:** Rename the `action` prop on `Action` to `onAction`. Not only a
806
+ rename: the new prop is typed `ActionFn` (`(...args: unknown[]) => unknown`), so
807
+ a function _reference_ that declares a parameter no longer type-checks and needs
808
+ wrapping — `onAction={() => controller.close()}` rather than
809
+ `onAction={controller.close}`. Check every site where you passed a reference
810
+ rather than an inline arrow; the codemod renames the prop but cannot decide this
811
+ one from the source.
780
812
 
781
813
  ```shell
782
814
  npx @mittwald/flow-codemods@latest action-prop-to-on-action src