Skip to content

fix(@schematics/angular): use service decorator in ng generate - #33105

Merged
clydin merged 1 commit into
angular:mainfrom
crisbeto:service-schematic
May 4, 2026
Merged

fix(@schematics/angular): use service decorator in ng generate#33105
clydin merged 1 commit into
angular:mainfrom
crisbeto:service-schematic

Conversation

@crisbeto

@crisbeto crisbeto commented Apr 30, 2026

Copy link
Copy Markdown
Member

Updates the service schematic in ng generate to use the @Service decorator instead of @Injectable. There's also a new --injectable flag to get back the old behavior.

Comment thread packages/schematics/angular/injectable/schema.json Outdated
Comment thread packages/schematics/angular/service/schema.json Outdated
@alan-agius4

alan-agius4 commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

Were there any discussions regarding the creation of a new schematic versus simply adding an option to the existing service schematic to support both @Injectable and @Service?

@crisbeto
crisbeto force-pushed the service-schematic branch from 3136903 to c2e241e Compare April 30, 2026 09:00
@crisbeto
crisbeto marked this pull request as ready for review April 30, 2026 09:05
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release labels Apr 30, 2026
@crisbeto

Copy link
Copy Markdown
Member Author

I mentioned in the design doc for @Service that I'm planning to change ng generate. I added the injectable schematic for symmetry, but I don't feel strongly about it.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new injectable schematic for generating Angular injectable classes and updates the existing service schematic to use a @Service decorator. The review feedback highlights several areas for improvement, including correcting a regex in the test suite that would cause failures, renaming variables and types to maintain consistency with the new schematic's purpose, removing an unused parameter, and updating documentation in the schema to accurately reflect default file naming.

Comment thread packages/schematics/angular/injectable/index_spec.ts Outdated
Comment thread packages/schematics/angular/injectable/index.ts Outdated
Comment thread packages/schematics/angular/injectable/index.ts Outdated
Comment thread packages/schematics/angular/injectable/index.ts Outdated
Comment thread packages/schematics/angular/injectable/index.ts Outdated
Comment thread packages/schematics/angular/injectable/index_spec.ts Outdated
Comment thread packages/schematics/angular/injectable/index_spec.ts Outdated
Comment thread packages/schematics/angular/injectable/schema.json Outdated
@crisbeto
crisbeto force-pushed the service-schematic branch from c2e241e to c324ad8 Compare April 30, 2026 09:19

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new schematic also needs to be added in

"@schematics/angular:service": {

@crisbeto
crisbeto force-pushed the service-schematic branch from c324ad8 to 551da86 Compare April 30, 2026 09:27
@crisbeto

Copy link
Copy Markdown
Member Author

Updated the config file.

@alan-agius4

Copy link
Copy Markdown
Collaborator

@crisbeto, I synced with @clydin on this. We’d prefer to update the existing service schematic with an --injectable flag rather than introducing a separate schematic. We're looking to consolidate our schematics where possible.

@alan-agius4 alan-agius4 added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 30, 2026
@crisbeto
crisbeto force-pushed the service-schematic branch from 551da86 to 33ed558 Compare May 1, 2026 08:28
@crisbeto crisbeto changed the title Update schematics for @Service fix(@schematics/angular): use service decorator in ng generate May 1, 2026
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels May 1, 2026
@crisbeto

crisbeto commented May 1, 2026

Copy link
Copy Markdown
Member Author

I've updated it to remove the injectable schematic and add a --injectable flag instead.

@crisbeto
crisbeto force-pushed the service-schematic branch from 33ed558 to dc52fe0 Compare May 1, 2026 08:43
Comment thread packages/schematics/angular/service/schema.json Outdated

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alan-agius4 alan-agius4 removed the action: review The PR is still awaiting reviews from at least one requested reviewer label May 4, 2026
Updates the `service` schematic in `ng generate` to use the `@Service` decorator instead of `@Injectable`. There's also a new `--injectable` flag to get back the old behavior.
@crisbeto
crisbeto force-pushed the service-schematic branch from dc52fe0 to 5ffde38 Compare May 4, 2026 16:01
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label May 4, 2026
@clydin
clydin merged commit 7fb59ea into angular:main May 4, 2026
35 checks passed
@clydin

clydin commented May 4, 2026

Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: @schematics/angular target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants