fix(ivy): emit generic type arguments in Pipe metadata (#29403)
Previously, only directives and services with generic type parameters would emit `any` as generic type when emitting Ivy metadata into .d.ts files. Pipes can also have generic type parameters but did not emit `any` for all type parameters, resulting in the omission of those parameters which causes compilation errors. This commit adds support for pipes with generic type arguments and emits `any` as generic type in the Ivy metadata. Fixes #29400 PR Close #29403
This commit is contained in:
@ -792,6 +792,26 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(jsContents).toContain('return new (t || TestPipe)(i0.ɵdirectiveInject(Dep));');
|
||||
});
|
||||
|
||||
it('should compile Pipes with generic types', () => {
|
||||
env.tsconfig();
|
||||
env.write('test.ts', `
|
||||
import {Pipe} from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'test-pipe',
|
||||
})
|
||||
export class TestPipe<T> {}
|
||||
`);
|
||||
|
||||
env.driveMain();
|
||||
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('TestPipe.ngPipeDef =');
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents)
|
||||
.toContain('static ngPipeDef: i0.ɵPipeDefWithMeta<TestPipe<any>, "test-pipe">;');
|
||||
});
|
||||
|
||||
it('should include @Pipes in @NgModule scopes', () => {
|
||||
env.tsconfig();
|
||||
env.write('test.ts', `
|
||||
|
Reference in New Issue
Block a user