mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor: _ParseAST.isAssignmentOperator to type guard
Update `_ParseAST.isAssignmentOperator` to type guard
This commit is contained in:
parent
07a08ab9f8
commit
4d19408e9b
2 changed files with 16 additions and 2 deletions
|
|
@ -268,7 +268,17 @@ export class Interpolation extends AST {
|
|||
}
|
||||
}
|
||||
|
||||
type AssignmentOperation = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '**=' | '&&=' | '||=' | '??=';
|
||||
export type AssignmentOperation =
|
||||
| '='
|
||||
| '+='
|
||||
| '-='
|
||||
| '*='
|
||||
| '/='
|
||||
| '%='
|
||||
| '**='
|
||||
| '&&='
|
||||
| '||='
|
||||
| '??=';
|
||||
type BinaryOperation =
|
||||
| AssignmentOperation
|
||||
// Logical
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import {
|
|||
Unary,
|
||||
VariableBinding,
|
||||
VoidExpression,
|
||||
type AssignmentOperation,
|
||||
} from './ast';
|
||||
import {EOF, Lexer, StringTokenKind, Token, TokenType} from './lexer';
|
||||
export interface InterpolationPiece {
|
||||
|
|
@ -730,7 +731,10 @@ class _ParseAST {
|
|||
}
|
||||
}
|
||||
|
||||
private isAssignmentOperator(token: Token): boolean {
|
||||
private isAssignmentOperator(token: Token): token is Token & {
|
||||
type: typeof TokenType.Operator;
|
||||
strValue: AssignmentOperation;
|
||||
} {
|
||||
return token.type === TokenType.Operator && Binary.isAssignmentOperation(token.strValue);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue