mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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 |
||
|---|---|---|
| .. | ||
| domino_adapter.ts | ||
| http.ts | ||
| location.ts | ||
| platform-server.ts | ||
| platform_state.ts | ||
| private_export.ts | ||
| server.ts | ||
| server_events.ts | ||
| server_renderer.ts | ||
| styles_host.ts | ||
| tokens.ts | ||
| transfer_state.ts | ||
| types.d.ts | ||
| utils.ts | ||
| version.ts | ||