fix(ivy): use the imported name of decorators for detection (#29061)
Currently, ngtsc has a bug where if you alias the name of a decorator when importing it, it won't be detected properly. This is because the compiler uses the aliased name and not the original, declared name of the decorator for detection. This commit fixes the compiler to compare against the declared name of decorators when available, and adds a test to prevent regression. PR Close #29061
This commit is contained in:

committed by
Andrew Kushnir

parent
3e5c1bcb9f
commit
b1df9a30f4
@ -160,6 +160,24 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵInjectableDef<Service>;');
|
||||
});
|
||||
|
||||
it('should compile @Injectable with an @Optional dependency', () => {
|
||||
env.tsconfig();
|
||||
env.write('test.ts', `
|
||||
import {Injectable, Optional as Opt} from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
class Dep {}
|
||||
|
||||
@Injectable()
|
||||
class Service {
|
||||
constructor(@Opt() dep: Dep) {}
|
||||
}
|
||||
`);
|
||||
env.driveMain();
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('inject(Dep, 8)');
|
||||
});
|
||||
|
||||
it('should compile Components (inline template) without errors', () => {
|
||||
env.tsconfig();
|
||||
env.write('test.ts', `
|
||||
|
Reference in New Issue
Block a user