fix(tsickle): support ctorParams in function closure (#12876)
See https://github.com/angular/tsickle/issues/261 for context.
This commit is contained in:

committed by
Victor Berchet

parent
46d150266b
commit
75277cd94b
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler-cli/src/static_reflector';
|
||||
import {HostListener, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
|
||||
import {HostListener, Inject, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
|
||||
import {MetadataCollector} from '@angular/tsc-wrapped';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
@ -410,6 +410,13 @@ describe('StaticReflector', () => {
|
||||
expect(props).toEqual({foo: []});
|
||||
});
|
||||
|
||||
it('should read ctor parameters with forwardRef', () => {
|
||||
const src = '/tmp/src/forward-ref.ts';
|
||||
const dep = host.getStaticSymbol(src, 'Dep');
|
||||
const props = reflector.parameters(host.getStaticSymbol(src, 'Forward'));
|
||||
expect(props).toEqual([[dep, new Inject(dep)]]);
|
||||
});
|
||||
|
||||
it('should report an error for invalid function calls', () => {
|
||||
expect(
|
||||
() =>
|
||||
@ -1068,6 +1075,18 @@ class MockReflectorHost implements StaticReflectorHost {
|
||||
providers: [ { provider: 'a', useValue: (() => 1)() }]
|
||||
})
|
||||
export class InvalidMetadata {}
|
||||
`,
|
||||
'/tmp/src/forward-ref.ts': `
|
||||
import {forwardRef} from 'angular2/core';
|
||||
import {Component} from 'angular2/src/core/metadata';
|
||||
import {Inject} from 'angular2/src/core/di/metadata';
|
||||
@Component({})
|
||||
export class Forward {
|
||||
constructor(@Inject(forwardRef(() => Dep)) d: Dep) {}
|
||||
}
|
||||
export class Dep {
|
||||
@Input f: Forward;
|
||||
}
|
||||
`
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user