diff --git a/packages/compiler/src/expression_parser/ast.ts b/packages/compiler/src/expression_parser/ast.ts index 2f6fcc18a94..099c40591a3 100644 --- a/packages/compiler/src/expression_parser/ast.ts +++ b/packages/compiler/src/expression_parser/ast.ts @@ -268,11 +268,39 @@ export class Interpolation extends AST { } } +type AssignmentOperation = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '**=' | '&&=' | '||=' | '??='; +type BinaryOperation = + | AssignmentOperation + // Logical + | '&&' + | '||' + | '??' + // Equality + | '==' + | '!=' + | '===' + | '!==' + // Relational + | '<' + | '>' + | '<=' + | '>=' + | 'in' + // Additive + | '+' + | '-' + // Multiplicative + | '*' + | '%' + | '/' + // Exponentiation + | '**'; + export class Binary extends AST { constructor( span: ParseSpan, sourceSpan: AbsoluteSourceSpan, - public operation: string, + public operation: BinaryOperation, public left: AST, public right: AST, ) { @@ -349,7 +377,7 @@ export class Unary extends Binary { sourceSpan: AbsoluteSourceSpan, public operator: string, public expr: AST, - binaryOp: string, + binaryOp: BinaryOperation, binaryLeft: AST, binaryRight: AST, ) {