Skip to main content

BinaryOpEvaluator

Struct BinaryOpEvaluator 

Source
pub struct BinaryOpEvaluator<'a> { /* private fields */ }
Expand description

Evaluates binary operations on types.

Implementations§

Source§

impl<'a> BinaryOpEvaluator<'a>

Source

pub fn new(interner: &'a dyn QueryDatabase) -> Self

Create a new binary operation evaluator.

Source

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.”

Source

pub fn is_valid_instanceof_right_operand<F>( &self, type_id: TypeId, func_ty: TypeId, assignable_check: &mut F, ) -> bool
where F: FnMut(TypeId, TypeId) -> 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…”

Source

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.

Source

pub fn evaluate( &self, left: TypeId, right: TypeId, op: &'static str, ) -> BinaryOpResult

Evaluate a binary operation on two types.

Source

pub fn has_overlap(&self, left: TypeId, right: TypeId) -> bool

Check if two types have any overlap (can be compared).

Source

pub fn is_symbol_like(&self, type_id: TypeId) -> bool

Check if a type is symbol-like (symbol or unique symbol).

Source

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.

Source

pub fn is_boolean_like(&self, type_id: TypeId) -> bool

Check if a type is boolean-like (boolean or boolean literal).

Auto Trait Implementations§

§

impl<'a> Freeze for BinaryOpEvaluator<'a>

§

impl<'a> !RefUnwindSafe for BinaryOpEvaluator<'a>

§

impl<'a> !Send for BinaryOpEvaluator<'a>

§

impl<'a> !Sync for BinaryOpEvaluator<'a>

§

impl<'a> Unpin for BinaryOpEvaluator<'a>

§

impl<'a> UnsafeUnpin for BinaryOpEvaluator<'a>

§

impl<'a> !UnwindSafe for BinaryOpEvaluator<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more