Skip to main content

TsTypeWrapper

Struct TsTypeWrapper 

Source
pub struct TsTypeWrapper(pub TsType);
Expand description

Wrapper for swc_core::ecma::ast::TsType that implements [Display].

This allows TypeScript types to be interpolated into string-based templates.

§Example

use macroforge_ts_syn::TsTypeWrapper;

let ty: TsType = /* ... */;
let wrapped = TsTypeWrapper(ty);
println!("type Alias = {};", wrapped); // Emits: type Alias = <type>;

Tuple Fields§

§0: TsType

Methods from Deref<Target = TsType>§

Source

pub fn is_ts_keyword_type(&self) -> bool

Returns true if self is of variant TsKeywordType.

Source

pub fn as_ts_keyword_type(&self) -> Option<&TsKeywordType>

Returns Some if self is a reference of variant TsKeywordType, and None otherwise.

Source

pub fn is_ts_this_type(&self) -> bool

Returns true if self is of variant TsThisType.

Source

pub fn as_ts_this_type(&self) -> Option<&TsThisType>

Returns Some if self is a reference of variant TsThisType, and None otherwise.

Source

pub fn is_ts_fn_or_constructor_type(&self) -> bool

Returns true if self is of variant TsFnOrConstructorType.

Source

pub fn as_ts_fn_or_constructor_type(&self) -> Option<&TsFnOrConstructorType>

Returns Some if self is a reference of variant TsFnOrConstructorType, and None otherwise.

Source

pub fn is_ts_type_ref(&self) -> bool

Returns true if self is of variant TsTypeRef.

Source

pub fn as_ts_type_ref(&self) -> Option<&TsTypeRef>

Returns Some if self is a reference of variant TsTypeRef, and None otherwise.

Source

pub fn is_ts_type_query(&self) -> bool

Returns true if self is of variant TsTypeQuery.

Source

pub fn as_ts_type_query(&self) -> Option<&TsTypeQuery>

Returns Some if self is a reference of variant TsTypeQuery, and None otherwise.

Source

pub fn is_ts_type_lit(&self) -> bool

Returns true if self is of variant TsTypeLit.

Source

pub fn as_ts_type_lit(&self) -> Option<&TsTypeLit>

Returns Some if self is a reference of variant TsTypeLit, and None otherwise.

Source

pub fn is_ts_array_type(&self) -> bool

Returns true if self is of variant TsArrayType.

Source

pub fn as_ts_array_type(&self) -> Option<&TsArrayType>

Returns Some if self is a reference of variant TsArrayType, and None otherwise.

Source

pub fn is_ts_tuple_type(&self) -> bool

Returns true if self is of variant TsTupleType.

Source

pub fn as_ts_tuple_type(&self) -> Option<&TsTupleType>

Returns Some if self is a reference of variant TsTupleType, and None otherwise.

Source

pub fn is_ts_optional_type(&self) -> bool

Returns true if self is of variant TsOptionalType.

Source

pub fn as_ts_optional_type(&self) -> Option<&TsOptionalType>

Returns Some if self is a reference of variant TsOptionalType, and None otherwise.

Source

pub fn is_ts_rest_type(&self) -> bool

Returns true if self is of variant TsRestType.

Source

pub fn as_ts_rest_type(&self) -> Option<&TsRestType>

Returns Some if self is a reference of variant TsRestType, and None otherwise.

Source

pub fn is_ts_union_or_intersection_type(&self) -> bool

Returns true if self is of variant TsUnionOrIntersectionType.

Source

pub fn as_ts_union_or_intersection_type( &self, ) -> Option<&TsUnionOrIntersectionType>

Returns Some if self is a reference of variant TsUnionOrIntersectionType, and None otherwise.

Source

pub fn is_ts_conditional_type(&self) -> bool

Returns true if self is of variant TsConditionalType.

Source

pub fn as_ts_conditional_type(&self) -> Option<&TsConditionalType>

Returns Some if self is a reference of variant TsConditionalType, and None otherwise.

Source

pub fn is_ts_infer_type(&self) -> bool

Returns true if self is of variant TsInferType.

Source

pub fn as_ts_infer_type(&self) -> Option<&TsInferType>

Returns Some if self is a reference of variant TsInferType, and None otherwise.

Source

pub fn is_ts_parenthesized_type(&self) -> bool

Returns true if self is of variant TsParenthesizedType.

Source

pub fn as_ts_parenthesized_type(&self) -> Option<&TsParenthesizedType>

Returns Some if self is a reference of variant TsParenthesizedType, and None otherwise.

Source

pub fn is_ts_type_operator(&self) -> bool

Returns true if self is of variant TsTypeOperator.

Source

pub fn as_ts_type_operator(&self) -> Option<&TsTypeOperator>

Returns Some if self is a reference of variant TsTypeOperator, and None otherwise.

Source

pub fn is_ts_indexed_access_type(&self) -> bool

Returns true if self is of variant TsIndexedAccessType.

Source

pub fn as_ts_indexed_access_type(&self) -> Option<&TsIndexedAccessType>

Returns Some if self is a reference of variant TsIndexedAccessType, and None otherwise.

Source

pub fn is_ts_mapped_type(&self) -> bool

Returns true if self is of variant TsMappedType.

Source

pub fn as_ts_mapped_type(&self) -> Option<&TsMappedType>

Returns Some if self is a reference of variant TsMappedType, and None otherwise.

Source

pub fn is_ts_lit_type(&self) -> bool

Returns true if self is of variant TsLitType.

Source

pub fn as_ts_lit_type(&self) -> Option<&TsLitType>

Returns Some if self is a reference of variant TsLitType, and None otherwise.

Source

pub fn is_ts_type_predicate(&self) -> bool

Returns true if self is of variant TsTypePredicate.

Source

pub fn as_ts_type_predicate(&self) -> Option<&TsTypePredicate>

Returns Some if self is a reference of variant TsTypePredicate, and None otherwise.

Source

pub fn is_ts_import_type(&self) -> bool

Returns true if self is of variant TsImportType.

Source

pub fn as_ts_import_type(&self) -> Option<&TsImportType>

Returns Some if self is a reference of variant TsImportType, and None otherwise.

Trait Implementations§

Source§

impl Clone for TsTypeWrapper

Source§

fn clone(&self) -> TsTypeWrapper

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 TsTypeWrapper

Source§

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

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

impl Deref for TsTypeWrapper

Available on crate feature swc only.
Source§

type Target = TsType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Display for TsTypeWrapper

Available on crate feature swc only.
Source§

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

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

impl From<TsType> for TsTypeWrapper

Available on crate feature swc only.
Source§

fn from(ty: TsType) -> Self

Converts to this type from the input type.

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

Source§

fn clone_quote_var(&self) -> Self

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

fn to_compact_string(&self) -> CompactString

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

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

Source§

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