Skip to content

Inline task actions #7560

@alcuadrado

Description

@alcuadrado

Describe the issue

Context

One of the last-minute breaking changes that @ChristopherDedominici and I decided to implement before the beta, was simplifying setAction in task builders, and remove the possibility of adding an inline action.

The reason behind that was that it having an union type there was extremely error prone and hard to debug.

Then cons of having done that is that users defining their own tasks have to split the task action to a different file, which is annoying and extra boilerplate. Note that extra boilerplate is ok for plugins, as plugin authors are more invested already.

To be clear, when I refer to user tasks I refer to the ones defined in HardhatUserConfig#tasks. Not the ones coming from plugins.

Proposed change

Add a setInlineAction function that can only be used in user tasks.

Potential designs

  1. We add it to the task builders and add config validation logic to forbid plugins to use it.
  2. We create different builders for users and plugins.

In both cases we should validate that the user doesn't use both setAction and setInlineAction.

(1) is simpler to implement. (2) is more involved, but also harder to enforce, as plugin authors may accidentally still use the user-level builders.

Metadata

Metadata

Labels

type:KREnd-to-end implementation of a KR

Projects

Status

Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions