Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(core): deprecate providedIn: NgModule and providedIn: 'any' #47616

Closed
wants to merge 1 commit into from

Conversation

alxhub
Copy link
Member

@alxhub alxhub commented Oct 3, 2022

This commit deprecates the above two forms of providedIn.

DEPRECATED:

  • The ability to pass an NgModule to the providedIn option for @Injectable and InjectionToken is now deprecated.

providedIn: NgModule was intended to be a tree-shakable alternative to NgModule providers. It does not have wide usage, and in most cases is used incorrectly, in circumstances where providedIn: 'root' should be preferred. If providers should truly be scoped to a specific NgModule, use NgModule.providers instead.

  • The ability to set providedIn: 'any' for an @Injectable or InjectionToken is now deprecated.

providedIn: 'any' is an option with confusing semantics and is almost never used apart from a handful of esoteric cases internal to the framework.

@ngbot ngbot bot added this to the Backlog milestone Oct 3, 2022
This commit deprecates the above two forms of `providedIn`.

DEPRECATED:

- The ability to pass an `NgModule` to the `providedIn` option for
`@Injectable` and `InjectionToken` is now deprecated.

`providedIn: NgModule` was intended to be a tree-shakable alternative to
NgModule providers. It does not have wide usage, and in most cases is used
incorrectly, in circumstances where `providedIn: 'root'` should be
preferred. If providers should truly be scoped to a specific NgModule, use
`NgModule.providers` instead.

- The ability to set `providedIn: 'any'` for an `@Injectable` or
`InjectionToken` is now deprecated.

`providedIn: 'any'` is an option with confusing semantics and is almost
never used apart from a handful of esoteric cases internal to the framework.
@alxhub alxhub force-pushed the v15/deprecations/providedIn branch from 6674034 to f1043d9 Compare October 3, 2022 21:12
@pkozlowski-opensource pkozlowski-opensource added the action: merge The PR is ready for merge by the caretaker label Oct 4, 2022
@ngbot
Copy link

ngbot bot commented Oct 4, 2022

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google3" is failing
    pending missing required labels: target: *

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@pkozlowski-opensource pkozlowski-opensource added the target: major This PR is targeted for the next major release label Oct 4, 2022
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit e3cef4a.

mprobst pushed a commit to mprobst/angular that referenced this pull request Oct 5, 2022
…ngular#47616)

This commit deprecates the above two forms of `providedIn`.

DEPRECATED:

- The ability to pass an `NgModule` to the `providedIn` option for
`@Injectable` and `InjectionToken` is now deprecated.

`providedIn: NgModule` was intended to be a tree-shakable alternative to
NgModule providers. It does not have wide usage, and in most cases is used
incorrectly, in circumstances where `providedIn: 'root'` should be
preferred. If providers should truly be scoped to a specific NgModule, use
`NgModule.providers` instead.

- The ability to set `providedIn: 'any'` for an `@Injectable` or
`InjectionToken` is now deprecated.

`providedIn: 'any'` is an option with confusing semantics and is almost
never used apart from a handful of esoteric cases internal to the framework.

PR Close angular#47616
yharaskrik pushed a commit to yharaskrik/angular that referenced this pull request Oct 5, 2022
…ngular#47616)

This commit deprecates the above two forms of `providedIn`.

DEPRECATED:

- The ability to pass an `NgModule` to the `providedIn` option for
`@Injectable` and `InjectionToken` is now deprecated.

`providedIn: NgModule` was intended to be a tree-shakable alternative to
NgModule providers. It does not have wide usage, and in most cases is used
incorrectly, in circumstances where `providedIn: 'root'` should be
preferred. If providers should truly be scoped to a specific NgModule, use
`NgModule.providers` instead.

- The ability to set `providedIn: 'any'` for an `@Injectable` or
`InjectionToken` is now deprecated.

`providedIn: 'any'` is an option with confusing semantics and is almost
never used apart from a handful of esoteric cases internal to the framework.

PR Close angular#47616
@mcalmus
Copy link
Contributor

mcalmus commented Oct 6, 2022

Can the providers docs be updated based on this as well?

https://next.angular.io/guide/providers

@angular-automatic-lock-bot
Copy link

This issue 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 Nov 6, 2022
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 target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants