fix(ivy): generate explicit type annotation for NgModuleFactory calls in ngfactories (#30708)
Prior to this commit there were no explicit types setup for NgModuleFactory calls in ngfactories, so TypeScript inferred the type based on a given call. In some cases (when generic types were used for Components/Directives) that turned out to be problematic, so we add explicit typing for NgModuleFactory calls. PR Close #30708
This commit is contained in:

committed by
Matias Niemelä

parent
5e0f982961
commit
7a0f8ac36c
@ -2149,6 +2149,22 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(emptyFactory).toContain(`export var \u0275NonEmptyModule = true;`);
|
||||
});
|
||||
|
||||
it('should generate correct type annotation for NgModuleFactory calls in ngfactories', () => {
|
||||
env.tsconfig({'allowEmptyCodegenFiles': true});
|
||||
env.write('test.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: '...',
|
||||
})
|
||||
export class TestCmp {}
|
||||
`);
|
||||
env.driveMain();
|
||||
|
||||
const ngfactoryContents = env.getContents('test.ngfactory.d.ts');
|
||||
expect(ngfactoryContents).toContain(`i0.ɵNgModuleFactory<any>`);
|
||||
});
|
||||
|
||||
it('should copy a top-level comment into a factory stub', () => {
|
||||
env.tsconfig({'allowEmptyCodegenFiles': true});
|
||||
|
||||
|
Reference in New Issue
Block a user