@@ -570,6 +570,48 @@ describe('StaticReflector', () => {
570570 expect ( annotation . providers ) . toEqual ( [ ] ) ;
571571 } ) ;
572572
573+ // #15424
574+ it ( 'should be able to inject a ctor parameter with a @Inject and a type expression' , ( ) => {
575+ const data = Object . create ( DEFAULT_TEST_DATA ) ;
576+ const file = '/tmp/src/invalid-component.ts' ;
577+ data [ file ] = `
578+ import {Injectable, Inject} from '@angular/core';
579+
580+ @Injectable()
581+ export class SomeClass {
582+ constructor (@Inject('some-token') a: {a: string, b: string}) {}
583+ }
584+ ` ;
585+ init ( data ) ;
586+
587+ const someClass = reflector . getStaticSymbol ( file , 'SomeClass' ) ;
588+ const parameters = reflector . parameters ( someClass ) ;
589+ expect ( parameters . toString ( ) ) . toEqual ( '@Inject' ) ;
590+ } ) ;
591+
592+ it ( 'should reject a ctor parameter without a @Inject and a type exprssion' , ( ) => {
593+ const data = Object . create ( DEFAULT_TEST_DATA ) ;
594+ const file = '/tmp/src/invalid-component.ts' ;
595+ data [ file ] = `
596+ import {Injectable} from '@angular/core';
597+
598+ @Injectable()
599+ export class SomeClass {
600+ constructor (a: {a: string, b: string}) {}
601+ }
602+ ` ;
603+
604+ let error : any = undefined ;
605+ init ( data , [ ] , ( err : any , filePath : string ) => {
606+ expect ( error ) . toBeUndefined ( ) ;
607+ error = err ;
608+ } ) ;
609+
610+ const someClass = reflector . getStaticSymbol ( file , 'SomeClass' ) ;
611+ expect ( reflector . parameters ( someClass ) ) . toEqual ( [ [ ] ] ) ;
612+ expect ( error ) . toBeUndefined ( ) ;
613+ } ) ;
614+
573615 describe ( 'inheritance' , ( ) => {
574616 class ClassDecorator {
575617 constructor ( public value : any ) { }
0 commit comments