https://github.com/angular/angular
Revision 7de1469be62b08037681ee9e75614fb800700ef8 authored by Alex Rickabaugh on 05 October 2022, 19:14:41 UTC, committed by Jessica Janiuk on 07 October 2022, 21:03:13 UTC
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
1 parent c5a1b90
History
Tip revision: 7de1469be62b08037681ee9e75614fb800700ef8 authored by Alex Rickabaugh on 05 October 2022, 19:14:41 UTC
feat(core): introduce EnvironmentProviders wrapper type (#47669)
Tip revision: 7de1469
File Mode Size
.circleci
.devcontainer
.github
.husky
.ng-dev
.vscode
.yarn
aio
devtools
docs
goldens
integration
modules
packages
scripts
third_party
tools
.bazelignore -rw-r--r-- 2.8 KB
.bazelrc -rw-r--r-- 5.4 KB
.bazelversion -rw-r--r-- 6 bytes
.clang-format -rw-r--r-- 73 bytes
.editorconfig -rw-r--r-- 245 bytes
.gitattributes -rw-r--r-- 146 bytes
.gitignore -rw-r--r-- 915 bytes
.gitmessage -rw-r--r-- 7.2 KB
.mailmap -rw-r--r-- 51 bytes
.npmrc -rw-r--r-- 21 bytes
.nvmrc -rw-r--r-- 8 bytes
.prettierrc -rw-r--r-- 157 bytes
.pullapprove.yml -rw-r--r-- 50.3 KB
.yarnrc -rw-r--r-- 130 bytes
BUILD.bazel -rw-r--r-- 2.1 KB
CHANGELOG.md -rw-r--r-- 339.8 KB
CHANGELOG_ARCHIVE.md -rw-r--r-- 742.5 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.2 KB
CONTRIBUTING.md -rw-r--r-- 15.9 KB
LICENSE -rw-r--r-- 1.1 KB
README.md -rw-r--r-- 5.0 KB
SECURITY.md -rw-r--r-- 397 bytes
WORKSPACE -rw-r--r-- 6.2 KB
browser-providers.conf.js -rw-r--r-- 1.9 KB
gulpfile.js -rw-r--r-- 572 bytes
karma-js.conf.js -rw-r--r-- 6.3 KB
package.json -rw-r--r-- 9.9 KB
renovate.json -rw-r--r-- 2.8 KB
tsconfig-tslint.json -rw-r--r-- 171 bytes
tslint.json -rw-r--r-- 5.5 KB
yarn.lock -rw-r--r-- 756.3 KB
yarn.lock.readme.md -rw-r--r-- 1.3 KB

README.md

back to top