Skip to content

Commit 55eb7b5

Browse files
petebacondarwinzarend
authored andcommitted
fix(compiler): ensure JIT compilation of ɵɵngDeclarePipe() works (#40929)
Previously the compiler was not evaluating the JIT compilation of `ɵɵngDeclarePipe()` but there was no test to check it. PR Close #40929
1 parent ca271b8 commit 55eb7b5

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages/compiler/src/jit_compiler_facade.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export class CompilerFacadeImpl implements CompilerFacade {
5454
angularCoreEnv: CoreEnvironment, sourceMapUrl: string,
5555
declaration: R3DeclarePipeFacade): any {
5656
const meta = convertDeclarePipeFacadeToMetadata(declaration);
57-
return compilePipeFromMetadata(meta);
57+
const res = compilePipeFromMetadata(meta);
58+
return this.jitExpression(res.expression, angularCoreEnv, sourceMapUrl, []);
5859
}
5960

6061
compileInjectable(
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {ɵɵngDeclarePipe} from '@angular/core';
10+
import {PipeDef} from '../../../src/render3';
11+
12+
describe('Pipe declaration jit compilation', () => {
13+
it('should compile a named Pipe declaration', () => {
14+
const def = ɵɵngDeclarePipe({type: TestClass, name: 'foo'}) as PipeDef<TestClass>;
15+
16+
expect(def.type).toBe(TestClass);
17+
expect(def.name).toEqual('foo');
18+
expect(def.pure).toEqual(true);
19+
});
20+
21+
it('should compile an impure Pipe declaration', () => {
22+
const def = ɵɵngDeclarePipe({type: TestClass, name: 'foo', pure: false}) as PipeDef<TestClass>;
23+
24+
expect(def.type).toBe(TestClass);
25+
expect(def.name).toEqual('foo');
26+
expect(def.pure).toEqual(false);
27+
});
28+
});
29+
30+
class TestClass {}

0 commit comments

Comments
 (0)