refactor(compiler): tighten Binary.operation type

Improve `Binary.operation` types

(cherry picked from commit 07a08ab9f8)
This commit is contained in:
fisker
2026-01-09 08:06:30 +08:00
committed by Jessica Janiuk
parent 491a1569ad
commit 9b97a1dfa3
+30 -2
View File
@@ -246,11 +246,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,
) {
@@ -327,7 +355,7 @@ export class Unary extends Binary {
sourceSpan: AbsoluteSourceSpan,
public operator: string,
public expr: AST,
binaryOp: string,
binaryOp: BinaryOperation,
binaryLeft: AST,
binaryRight: AST,
) {