fix(ivy): pipes are pure by default (#24750)

PR Close #24750
This commit is contained in:
cexbrayat 2018-07-04 01:13:54 +02:00 committed by Miško Hevery
parent fddd2af4fc
commit f62876bbcb
2 changed files with 26 additions and 1 deletions

View File

@ -50,7 +50,7 @@ export class PipeDecoratorHandler implements DecoratorHandler<R3PipeMetadata> {
}
this.scopeRegistry.registerPipe(clazz, pipeName);
let pure = false;
let pure = true;
if (pipe.has('pure')) {
const pureValue = staticallyResolve(pipe.get('pure') !, this.checker);
if (typeof pureValue !== 'boolean') {

View File

@ -270,6 +270,31 @@ describe('ngtsc behavioral tests', () => {
expect(dtsContents).toContain('static ngPipeDef: i0.ɵPipeDef<TestPipe, \'test-pipe\'>;');
});
it('should compile pure Pipes without errors', () => {
writeConfig();
write('test.ts', `
import {Pipe} from '@angular/core';
@Pipe({
name: 'test-pipe',
})
export class TestPipe {}
`);
const exitCode = main(['-p', basePath], errorSpy);
expect(errorSpy).not.toHaveBeenCalled();
expect(exitCode).toBe(0);
const jsContents = getContents('test.js');
const dtsContents = getContents('test.d.ts');
expect(jsContents)
.toContain(
'TestPipe.ngPipeDef = i0.ɵdefinePipe({ name: "test-pipe", type: TestPipe, ' +
'factory: function TestPipe_Factory() { return new TestPipe(); }, pure: true })');
expect(dtsContents).toContain('static ngPipeDef: i0.ɵPipeDef<TestPipe, \'test-pipe\'>;');
});
it('should compile Pipes with dependencies', () => {
writeConfig();
write('test.ts', `