← All recipes
Moderne licensed

Migrate constructor injection to inject()

Recipe IDorg.openrewrite.angular.migration.migrate-constructor-to-injectArtifact@openrewrite/recipes-angular

Converts constructor parameter properties in Angular classes to field declarations using the inject() function. For example, constructor(private svc: MyService) {} becomes private svc = inject(MyService);.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.angular.migration.migrate-constructor-to-inject

If the recipe isn’t available locally, install it with:

mod config recipes npm install @openrewrite/recipes-angular