Skip to content

Commit

Permalink
fix(compiler): ensure JIT compilation of ɵɵngDeclarePipe() works (#40929
Browse files Browse the repository at this point in the history
)

Previously the compiler was not evaluating the JIT compilation
of `ɵɵngDeclarePipe()` but there was no test to check it.

PR Close #40929
  • Loading branch information
petebacondarwin authored and zarend committed Feb 24, 2021
1 parent ca271b8 commit 55eb7b5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/compiler/src/jit_compiler_facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export class CompilerFacadeImpl implements CompilerFacade {
angularCoreEnv: CoreEnvironment, sourceMapUrl: string,
declaration: R3DeclarePipeFacade): any {
const meta = convertDeclarePipeFacadeToMetadata(declaration);
return compilePipeFromMetadata(meta);
const res = compilePipeFromMetadata(meta);
return this.jitExpression(res.expression, angularCoreEnv, sourceMapUrl, []);
}

compileInjectable(
Expand Down
30 changes: 30 additions & 0 deletions packages/core/test/render3/jit/declare_pipe_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {ɵɵngDeclarePipe} from '@angular/core';
import {PipeDef} from '../../../src/render3';

describe('Pipe declaration jit compilation', () => {
it('should compile a named Pipe declaration', () => {
const def = ɵɵngDeclarePipe({type: TestClass, name: 'foo'}) as PipeDef<TestClass>;

expect(def.type).toBe(TestClass);
expect(def.name).toEqual('foo');
expect(def.pure).toEqual(true);
});

it('should compile an impure Pipe declaration', () => {
const def = ɵɵngDeclarePipe({type: TestClass, name: 'foo', pure: false}) as PipeDef<TestClass>;

expect(def.type).toBe(TestClass);
expect(def.name).toEqual('foo');
expect(def.pure).toEqual(false);
});
});

class TestClass {}

0 comments on commit 55eb7b5

Please sign in to comment.