fix(compiler): support interface types in injectable constuctors (#14894)
Fixes #12631
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
|
||||
import {Component, Inject, LOCALE_ID, TRANSLATIONS_FORMAT} from '@angular/core';
|
||||
|
||||
import {CUSTOM, Named} from './custom_token';
|
||||
|
||||
@Component({
|
||||
selector: 'basic',
|
||||
@ -21,7 +22,8 @@ export class BasicComp {
|
||||
ctxArr: any[] = [];
|
||||
constructor(
|
||||
@Inject(LOCALE_ID) public localeId: string,
|
||||
@Inject(TRANSLATIONS_FORMAT) public translationsFormat: string) {
|
||||
@Inject(TRANSLATIONS_FORMAT) public translationsFormat: string,
|
||||
@Inject(CUSTOM) public custom: Named) {
|
||||
this.ctxProp = 'initialValue';
|
||||
}
|
||||
}
|
||||
|
13
packages/compiler-cli/integrationtest/src/custom_token.ts
Normal file
13
packages/compiler-cli/integrationtest/src/custom_token.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {InjectionToken} from '@angular/core';
|
||||
|
||||
export interface Named { name: string; }
|
||||
|
||||
export const CUSTOM = new InjectionToken<Named>('CUSTOM');
|
@ -20,6 +20,7 @@ import {MultipleComponentsMyComp, NextComp} from './a/multiple_components';
|
||||
import {AnimateCmp} from './animate';
|
||||
import {BasicComp} from './basic';
|
||||
import {ComponentUsingThirdParty} from './comp_using_3rdp';
|
||||
import {CUSTOM, Named} from './custom_token';
|
||||
import {CompWithAnalyzeEntryComponentsProvider, CompWithEntryComponents} from './entry_components';
|
||||
import {CompConsumingEvents, CompUsingPipes, CompWithProviders, CompWithReferences, DirPublishingEvents, ModuleUsingCustomElements} from './features';
|
||||
import {CompUsingRootModuleDirectiveAndPipe, SomeDirectiveInRootModule, SomeLibModule, SomePipeInRootModule, SomeService} from './module_fixtures';
|
||||
@ -75,6 +76,7 @@ export const SERVER_ANIMATIONS_PROVIDERS: Provider[] = [{
|
||||
providers: [
|
||||
SomeService,
|
||||
SERVER_ANIMATIONS_PROVIDERS,
|
||||
{provide: CUSTOM, useValue: {name: 'some name'}},
|
||||
],
|
||||
entryComponents: [
|
||||
AnimateCmp,
|
||||
|
Reference in New Issue
Block a user