diff --git a/packages/compiler-cli/src/ngtsc/annotations/index.ts b/packages/compiler-cli/src/ngtsc/annotations/index.ts index f56e3074cc..4328de07ba 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/index.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/index.ts @@ -10,4 +10,5 @@ export {ComponentDecoratorHandler} from './src/component'; export {DirectiveDecoratorHandler} from './src/directive'; export {InjectableDecoratorHandler} from './src/injectable'; export {NgModuleDecoratorHandler} from './src/ng_module'; +export {PipeDecoratorHandler} from './src/pipe'; export {CompilationScope, SelectorScopeRegistry} from './src/selector_scope'; diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts b/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts new file mode 100644 index 0000000000..365d1ce33a --- /dev/null +++ b/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts @@ -0,0 +1,39 @@ +/** + * @license + * Copyright Google Inc. 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 {Expression, ExpressionType, LiteralExpr, R3DependencyMetadata, R3InjectableMetadata, R3ResolvedDependencyType, WrappedNodeExpr, compileInjectable as compileIvyInjectable} from '@angular/compiler'; +import * as ts from 'typescript'; + +import {Decorator, ReflectionHost} from '../../host'; +import {AnalysisOutput, CompileResult, DecoratorHandler} from '../../transform'; + +import {isAngularCore} from './util'; + +export class PipeDecoratorHandler implements DecoratorHandler { + constructor(private reflector: ReflectionHost, private isCore: boolean) {} + + detect(decorator: Decorator[]): Decorator|undefined { + return decorator.find( + decorator => decorator.name === 'Pipe' && (this.isCore || isAngularCore(decorator))); + } + + analyze(node: ts.ClassDeclaration, decorator: Decorator): AnalysisOutput { + return { + analysis: 'test', + }; + } + + compile(node: ts.ClassDeclaration, analysis: string): CompileResult { + return { + name: 'ngPipeDef', + initializer: new LiteralExpr(null), + statements: [], + type: new ExpressionType(new LiteralExpr(null)), + }; + } +} diff --git a/packages/compiler-cli/src/ngtsc/program.ts b/packages/compiler-cli/src/ngtsc/program.ts index bd3dcb537c..314718e948 100644 --- a/packages/compiler-cli/src/ngtsc/program.ts +++ b/packages/compiler-cli/src/ngtsc/program.ts @@ -12,7 +12,7 @@ import * as ts from 'typescript'; import * as api from '../transformers/api'; -import {ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, SelectorScopeRegistry} from './annotations'; +import {ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, SelectorScopeRegistry} from './annotations'; import {CompilerHost} from './compiler_host'; import {TypeScriptReflectionHost} from './metadata'; import {IvyCompilation, ivyTransformFactory} from './transform'; @@ -101,6 +101,7 @@ export class NgtscProgram implements api.Program { new DirectiveDecoratorHandler(checker, reflector, scopeRegistry, isCore), new InjectableDecoratorHandler(reflector, isCore), new NgModuleDecoratorHandler(checker, reflector, scopeRegistry, isCore), + new PipeDecoratorHandler(reflector, isCore), ]; const coreImportsFrom = isCore && getR3SymbolsFile(this.tsProgram) || null;