Skip to content

codemods: action-prop-to-on-action could auto-wrap bare function references #3060

Description

@mfal

The codemod (packages/codemods/src/migrations/action-prop-to-on-action/transform.ts) renames actiononAction but deliberately leaves a bare function reference (onAction={controller.close}) untouched, because — per the entry's own text — "whether the referenced function declares a parameter cannot be decided from the source... that needs type information."

True for deciding whether wrapping is necessary, not for performing the wrap. Wrapping a bare reference in an inline arrow (onAction={() => controller.close()}) is a no-op when the function takes no meaningful parameter, and turns a type error into working code when it does — there's no case where wrapping an already-bare reference breaks previously-correct code. A value that is already an arrow function or function expression doesn't need this and should stay untouched.

Proposal: extend the codemod to unconditionally wrap any bare identifier/member-expression passed to onAction (skip arrow functions and function expressions), removing the need for a manual pass over every call site.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions