feat(ivy): emit metadata along with all Angular types (#26860)
This commit causes a call to setClassMetadata() to be emitted for every type being compiled by ngtsc (every Angular type). With this metadata, the TestBed should be able to recompile these classes when overriding decorator information. Testing strategy: Tests in the previous commit for generateSetClassMetadataCall() verify that the metadata as generated is correct. This commit enables the generation for each DecoratorHandler, and a test is added to ngtsc_spec to verify all decorated types have metadata generated for them. PR Close #26860
This commit is contained in:

committed by
Matias Niemelä

parent
492576114d
commit
8634d0bcd8
@ -748,4 +748,25 @@ describe('ngtsc behavioral tests', () => {
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('directives: function () { return [CmpB]; }');
|
||||
});
|
||||
|
||||
it('should emit setClassMetadata calls for all types', () => {
|
||||
env.tsconfig();
|
||||
env.write('test.ts', `
|
||||
import {Component, Directive, Injectable, NgModule, Pipe} from '@angular/core';
|
||||
|
||||
@Component({selector: 'cmp', template: 'I am a component!'}) class TestComponent {}
|
||||
@Directive({selector: 'dir'}) class TestDirective {}
|
||||
@Injectable() class TestInjectable {}
|
||||
@NgModule({declarations: [TestComponent, TestDirective]}) class TestNgModule {}
|
||||
@Pipe({name: 'pipe'}) class TestPipe {}
|
||||
`);
|
||||
|
||||
env.driveMain();
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('ɵsetClassMetadata(TestComponent, ');
|
||||
expect(jsContents).toContain('ɵsetClassMetadata(TestDirective, ');
|
||||
expect(jsContents).toContain('ɵsetClassMetadata(TestInjectable, ');
|
||||
expect(jsContents).toContain('ɵsetClassMetadata(TestNgModule, ');
|
||||
expect(jsContents).toContain('ɵsetClassMetadata(TestPipe, ');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user