Repository navigation
fix(di): add better type information to injector.get() #13785
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| * found in the LICENSE file at https://angular.io/license | ||
| */ | ||
|
|
||
| import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Inject, OpaqueToken, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core'; | ||
| import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Inject, InjectionToken, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core'; | ||
|
|
||
| import {AnimationParser} from '../animation/animation_parser'; | ||
| import {CompilerConfig} from '../config'; | ||
|
|
@@ -40,7 +40,7 @@ const _NO_RESOURCE_LOADER: ResourceLoader = { | |
| `No ResourceLoader implementation has been provided. Can't read the url "${url}"`);} | ||
| }; | ||
|
|
||
| const baseHtmlParser = new OpaqueToken('HtmlParser'); | ||
| const baseHtmlParser = new InjectionToken('HtmlParser'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is several hundred of these in our code base. I started doing them, but then I realized that I could not determine the type for most of them so I gave up, and I am not planning on doing them. Only doing them for public visible InjectionTokens. |
||
|
|
||
| /** | ||
| * A set of providers that provide `JitCompiler` and its dependencies to use for | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| * found in the LICENSE file at https://angular.io/license | ||
| */ | ||
|
|
||
| import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, Attribute, ChangeDetectionStrategy, Component, ComponentFactory, Directive, Host, Inject, Injectable, ModuleWithProviders, OpaqueToken, Optional, Provider, Query, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef} from '@angular/core'; | ||
| import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, Attribute, ChangeDetectionStrategy, Component, ComponentFactory, Directive, Host, Inject, Injectable, InjectionToken, ModuleWithProviders, Optional, Provider, Query, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef} from '@angular/core'; | ||
|
|
||
| import {StaticSymbol, StaticSymbolCache} from './aot/static_symbol'; | ||
| import {ngfactoryFilePath} from './aot/util'; | ||
|
|
@@ -27,7 +27,7 @@ import {getUrlScheme} from './url_resolver'; | |
| import {MODULE_SUFFIX, SyntaxError, ValueTransformer, visitValue} from './util'; | ||
|
|
||
| export type ErrorCollector = (error: any, type?: any) => void; | ||
| export const ERROR_COLLECTOR_TOKEN = new OpaqueToken('ErrorCollector'); | ||
| export const ERROR_COLLECTOR_TOKEN = new InjectionToken('ErrorCollector'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same heere |
||
|
|
||
| // Design notes: | ||
| // - don't lazily create metadata: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
Token(orInjectionProvider, ...)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed in person