Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): introduce EnvironmentProviders wrapper type (#47669)
This commit introduces a new type `EnvironmentProviders` which can be used in contexts where Angular accepted `Provider`s destined for `EnvironmentInjector`s. This includes contexts such as `@NgModule.providers` and `Route.providers`. The new type is useful for preventing such providers from accidentally ending up in `@Component.providers`. It can be used as the return type of provider functions (such as `provideRouter`) to enforce this safety. Because `Provider` allows `any[]` nested arrays, the compile-time safety provided by `EnvironmentProviders` is easily circumvented. However, the runtime shape of `EnvironmentProviders` is not compatible with component injectors and will result in a runtime error if it leaks through (NG0207). A new function `makeEnvironmentProviders` is used to construct this new type from an array of providers. The existing `importProvidersFrom` operation previously returned a very similar type `ImportedNgModuleProviders` which had the same goal. This machinery is switched over to use the new `EnvironmentProviders` interface instead (in fact, `ImportedNgModuleProviders` is now just an alias to `EnvironmentProviders`). PR Close #47669
- Loading branch information
1 parent
c5a1b90
commit 7de1469
Showing
25 changed files
with
145 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.