@@ -895,11 +895,11 @@ export class Context {
895895 return ts . createIdentifier ( `_t${ this . nextId ++ } ` ) ;
896896 }
897897
898- getPipeByName ( name : string ) : ts . Expression | null {
898+ getPipeByName ( name : string ) : Reference < ClassDeclaration < ts . ClassDeclaration > > | null {
899899 if ( ! this . pipes . has ( name ) ) {
900900 return null ;
901901 }
902- return this . env . pipeInst ( this . pipes . get ( name ) ! ) ;
902+ return this . pipes . get ( name ) ! ;
903903 }
904904}
905905
@@ -1389,19 +1389,20 @@ class TcbExpressionTranslator {
13891389 return ts . createIdentifier ( 'ctx' ) ;
13901390 } else if ( ast instanceof BindingPipe ) {
13911391 const expr = this . translate ( ast . exp ) ;
1392+ const pipeRef = this . tcb . getPipeByName ( ast . name ) ;
13921393 let pipe : ts . Expression | null ;
1393- if ( this . tcb . env . config . checkTypeOfPipes ) {
1394- pipe = this . tcb . getPipeByName ( ast . name ) ;
1395- if ( pipe === null ) {
1396- // No pipe by that name exists in scope. Record this as an error.
1397- this . tcb . oobRecorder . missingPipe ( this . tcb . id , ast ) ;
1398-
1399- // Return an 'any' value to at least allow the rest of the expression to be checked.
1400- pipe = NULL_AS_ANY ;
1401- }
1394+ if ( pipeRef === null ) {
1395+ // No pipe by that name exists in scope. Record this as an error.
1396+ this . tcb . oobRecorder . missingPipe ( this . tcb . id , ast ) ;
1397+
1398+ // Use an 'any' value to at least allow the rest of the expression to be checked.
1399+ pipe = NULL_AS_ANY ;
1400+ } else if ( this . tcb . env . config . checkTypeOfPipes ) {
1401+ // Use a variable declared as the pipe's type.
1402+ pipe = this . tcb . env . pipeInst ( pipeRef ) ;
14021403 } else {
1403- pipe = ts . createParen ( ts . createAsExpression (
1404- ts . createNull ( ) , ts . createKeywordTypeNode ( ts . SyntaxKind . AnyKeyword ) ) ) ;
1404+ // Use an 'any' value when not checking the type of the pipe.
1405+ pipe = NULL_AS_ANY ;
14051406 }
14061407 const args = ast . args . map ( arg => this . translate ( arg ) ) ;
14071408 const result = tsCallMethod ( pipe , 'transform' , [ expr , ...args ] ) ;
0 commit comments