parent
fddd2af4fc
commit
f62876bbcb
|
@ -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') {
|
||||
|
|
|
@ -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', `
|
||||
|
|
Loading…
Reference in New Issue