@@ -895,11 +895,11 @@ export class Context {
895
895
return ts . createIdentifier ( `_t${ this . nextId ++ } ` ) ;
896
896
}
897
897
898
- getPipeByName ( name : string ) : ts . Expression | null {
898
+ getPipeByName ( name : string ) : Reference < ClassDeclaration < ts . ClassDeclaration > > | null {
899
899
if ( ! this . pipes . has ( name ) ) {
900
900
return null ;
901
901
}
902
- return this . env . pipeInst ( this . pipes . get ( name ) ! ) ;
902
+ return this . pipes . get ( name ) ! ;
903
903
}
904
904
}
905
905
@@ -1389,19 +1389,20 @@ class TcbExpressionTranslator {
1389
1389
return ts . createIdentifier ( 'ctx' ) ;
1390
1390
} else if ( ast instanceof BindingPipe ) {
1391
1391
const expr = this . translate ( ast . exp ) ;
1392
+ const pipeRef = this . tcb . getPipeByName ( ast . name ) ;
1392
1393
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 ) ;
1402
1403
} 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 ;
1405
1406
}
1406
1407
const args = ast . args . map ( arg => this . translate ( arg ) ) ;
1407
1408
const result = tsCallMethod ( pipe , 'transform' , [ expr , ...args ] ) ;
0 commit comments