pub struct BinaryOpEvaluator<'a> { /* private fields */ }Expand description
Evaluates binary operations on types.
Implementations§
Source§impl<'a> BinaryOpEvaluator<'a>
impl<'a> BinaryOpEvaluator<'a>
Sourcepub fn new(interner: &'a dyn QueryDatabase) -> Self
pub fn new(interner: &'a dyn QueryDatabase) -> Self
Create a new binary operation evaluator.
Sourcepub fn is_valid_instanceof_left_operand(&self, type_id: TypeId) -> bool
pub fn is_valid_instanceof_left_operand(&self, type_id: TypeId) -> bool
Check if a type is valid for the left side of an instanceof expression.
TS2358: “The left-hand side of an ‘instanceof’ expression must be of type ‘any’, an object type or a type parameter.”
Sourcepub fn is_valid_instanceof_right_operand<F>(
&self,
type_id: TypeId,
func_ty: TypeId,
assignable_check: &mut F,
) -> bool
pub fn is_valid_instanceof_right_operand<F>( &self, type_id: TypeId, func_ty: TypeId, assignable_check: &mut F, ) -> bool
Check if a type is valid for the right side of an instanceof expression.
TS2359: “The right-hand side of an ‘instanceof’ expression must be either of type ‘any’, a class, function, or other type assignable to the ‘Function’ interface type…”
Sourcepub fn is_arithmetic_operand(&self, type_id: TypeId) -> bool
pub fn is_arithmetic_operand(&self, type_id: TypeId) -> bool
Check if a type is valid for arithmetic operations (number, bigint, enum, or any). This is used for TS2362/TS2363 error checking.
Also returns true for ERROR and UNKNOWN types to prevent cascading errors. If a type couldn’t be resolved (TS2304, etc.), we don’t want to add noise with arithmetic errors - the primary error is more useful.
Sourcepub fn evaluate(
&self,
left: TypeId,
right: TypeId,
op: &'static str,
) -> BinaryOpResult
pub fn evaluate( &self, left: TypeId, right: TypeId, op: &'static str, ) -> BinaryOpResult
Evaluate a binary operation on two types.
Sourcepub fn has_overlap(&self, left: TypeId, right: TypeId) -> bool
pub fn has_overlap(&self, left: TypeId, right: TypeId) -> bool
Check if two types have any overlap (can be compared).
Sourcepub fn is_symbol_like(&self, type_id: TypeId) -> bool
pub fn is_symbol_like(&self, type_id: TypeId) -> bool
Check if a type is symbol-like (symbol or unique symbol).
Sourcepub fn is_valid_computed_property_name_type(&self, type_id: TypeId) -> bool
pub fn is_valid_computed_property_name_type(&self, type_id: TypeId) -> bool
Check if a type is a valid computed property name type (TS2464).
Valid types: string, number, symbol, any (including literals, enums, template literals, unique symbols). For unions, ALL members must be valid. This check is independent of strictNullChecks.
Sourcepub fn is_boolean_like(&self, type_id: TypeId) -> bool
pub fn is_boolean_like(&self, type_id: TypeId) -> bool
Check if a type is boolean-like (boolean or boolean literal).