mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor: _ParseAST.isAssignmentOperator to type guard
Update `_ParseAST.isAssignmentOperator` to type guard
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user