Skip to main content

TsExpr

Enum TsExpr 

Source
pub enum TsExpr {
Show 18 variants Lit(TsLit), Var(String), BinOp(String, Box<TsExpr>, Box<TsExpr>), UnaryOp(String, Box<TsExpr>), Call(Box<TsExpr>, Vec<TsExpr>), MethodCall(Box<TsExpr>, String, Vec<TsExpr>), New(Box<TsExpr>, Vec<TsExpr>), Arrow(Vec<(String, Option<TsType>)>, Box<TsExpr>), Ternary(Box<TsExpr>, Box<TsExpr>, Box<TsExpr>), As(Box<TsExpr>, TsType), Satisfies(Box<TsExpr>, TsType), TypeAssert(Box<TsExpr>), ObjectLit(Vec<(String, TsExpr)>), ArrayLit(Vec<TsExpr>), Template(Vec<TsTemplatePart>), Await(Box<TsExpr>), Nullish(Box<TsExpr>, Box<TsExpr>), OptChain(Box<TsExpr>, String),
}
Expand description

TypeScript expression AST node.

Variants§

§

Lit(TsLit)

A literal value.

§

Var(String)

A variable reference: x, myVar

§

BinOp(String, Box<TsExpr>, Box<TsExpr>)

A binary operation: lhs + rhs

§

UnaryOp(String, Box<TsExpr>)

A unary operation: !x, -n

§

Call(Box<TsExpr>, Vec<TsExpr>)

A function/method call: f(a, b)

§

MethodCall(Box<TsExpr>, String, Vec<TsExpr>)

A method call: obj.method(a, b)

§

New(Box<TsExpr>, Vec<TsExpr>)

Constructor call: new Foo(a, b)

§

Arrow(Vec<(String, Option<TsType>)>, Box<TsExpr>)

Arrow function: (x: T) => expr

§

Ternary(Box<TsExpr>, Box<TsExpr>, Box<TsExpr>)

Ternary expression: cond ? then : else

§

As(Box<TsExpr>, TsType)

Type assertion: expr as T

§

Satisfies(Box<TsExpr>, TsType)

Satisfies expression: expr satisfies T

§

TypeAssert(Box<TsExpr>)

Non-null assertion: expr!

§

ObjectLit(Vec<(String, TsExpr)>)

Object literal: { key: val }

§

ArrayLit(Vec<TsExpr>)

Array literal: [a, b, c]

§

Template(Vec<TsTemplatePart>)

Template literal: `Hello ${name}!`

§

Await(Box<TsExpr>)

Await expression: await p

§

Nullish(Box<TsExpr>, Box<TsExpr>)

Nullish coalescing: a ?? b

§

OptChain(Box<TsExpr>, String)

Optional chaining: obj?.prop

Trait Implementations§

Source§

impl Clone for TsExpr

Source§

fn clone(&self) -> TsExpr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TsExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TsExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TsExpr

Source§

fn eq(&self, other: &TsExpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TsExpr

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.