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: TsTypeMethods from Deref<Target = TsType>§
Sourcepub fn is_ts_keyword_type(&self) -> bool
pub fn is_ts_keyword_type(&self) -> bool
Returns true if self is of variant TsKeywordType.
Sourcepub fn as_ts_keyword_type(&self) -> Option<&TsKeywordType>
pub fn as_ts_keyword_type(&self) -> Option<&TsKeywordType>
Returns Some if self is a reference of variant TsKeywordType, and None otherwise.
Sourcepub fn is_ts_this_type(&self) -> bool
pub fn is_ts_this_type(&self) -> bool
Returns true if self is of variant TsThisType.
Sourcepub fn as_ts_this_type(&self) -> Option<&TsThisType>
pub fn as_ts_this_type(&self) -> Option<&TsThisType>
Returns Some if self is a reference of variant TsThisType, and None otherwise.
Sourcepub fn is_ts_fn_or_constructor_type(&self) -> bool
pub fn is_ts_fn_or_constructor_type(&self) -> bool
Returns true if self is of variant TsFnOrConstructorType.
Sourcepub fn as_ts_fn_or_constructor_type(&self) -> Option<&TsFnOrConstructorType>
pub fn as_ts_fn_or_constructor_type(&self) -> Option<&TsFnOrConstructorType>
Returns Some if self is a reference of variant TsFnOrConstructorType, and None otherwise.
Sourcepub fn is_ts_type_ref(&self) -> bool
pub fn is_ts_type_ref(&self) -> bool
Returns true if self is of variant TsTypeRef.
Sourcepub fn as_ts_type_ref(&self) -> Option<&TsTypeRef>
pub fn as_ts_type_ref(&self) -> Option<&TsTypeRef>
Returns Some if self is a reference of variant TsTypeRef, and None otherwise.
Sourcepub fn is_ts_type_query(&self) -> bool
pub fn is_ts_type_query(&self) -> bool
Returns true if self is of variant TsTypeQuery.
Sourcepub fn as_ts_type_query(&self) -> Option<&TsTypeQuery>
pub fn as_ts_type_query(&self) -> Option<&TsTypeQuery>
Returns Some if self is a reference of variant TsTypeQuery, and None otherwise.
Sourcepub fn is_ts_type_lit(&self) -> bool
pub fn is_ts_type_lit(&self) -> bool
Returns true if self is of variant TsTypeLit.
Sourcepub fn as_ts_type_lit(&self) -> Option<&TsTypeLit>
pub fn as_ts_type_lit(&self) -> Option<&TsTypeLit>
Returns Some if self is a reference of variant TsTypeLit, and None otherwise.
Sourcepub fn is_ts_array_type(&self) -> bool
pub fn is_ts_array_type(&self) -> bool
Returns true if self is of variant TsArrayType.
Sourcepub fn as_ts_array_type(&self) -> Option<&TsArrayType>
pub fn as_ts_array_type(&self) -> Option<&TsArrayType>
Returns Some if self is a reference of variant TsArrayType, and None otherwise.
Sourcepub fn is_ts_tuple_type(&self) -> bool
pub fn is_ts_tuple_type(&self) -> bool
Returns true if self is of variant TsTupleType.
Sourcepub fn as_ts_tuple_type(&self) -> Option<&TsTupleType>
pub fn as_ts_tuple_type(&self) -> Option<&TsTupleType>
Returns Some if self is a reference of variant TsTupleType, and None otherwise.
Sourcepub fn is_ts_optional_type(&self) -> bool
pub fn is_ts_optional_type(&self) -> bool
Returns true if self is of variant TsOptionalType.
Sourcepub fn as_ts_optional_type(&self) -> Option<&TsOptionalType>
pub fn as_ts_optional_type(&self) -> Option<&TsOptionalType>
Returns Some if self is a reference of variant TsOptionalType, and None otherwise.
Sourcepub fn is_ts_rest_type(&self) -> bool
pub fn is_ts_rest_type(&self) -> bool
Returns true if self is of variant TsRestType.
Sourcepub fn as_ts_rest_type(&self) -> Option<&TsRestType>
pub fn as_ts_rest_type(&self) -> Option<&TsRestType>
Returns Some if self is a reference of variant TsRestType, and None otherwise.
Sourcepub fn is_ts_union_or_intersection_type(&self) -> bool
pub fn is_ts_union_or_intersection_type(&self) -> bool
Returns true if self is of variant TsUnionOrIntersectionType.
Sourcepub fn as_ts_union_or_intersection_type(
&self,
) -> Option<&TsUnionOrIntersectionType>
pub fn as_ts_union_or_intersection_type( &self, ) -> Option<&TsUnionOrIntersectionType>
Returns Some if self is a reference of variant TsUnionOrIntersectionType, and None otherwise.
Sourcepub fn is_ts_conditional_type(&self) -> bool
pub fn is_ts_conditional_type(&self) -> bool
Returns true if self is of variant TsConditionalType.
Sourcepub fn as_ts_conditional_type(&self) -> Option<&TsConditionalType>
pub fn as_ts_conditional_type(&self) -> Option<&TsConditionalType>
Returns Some if self is a reference of variant TsConditionalType, and None otherwise.
Sourcepub fn is_ts_infer_type(&self) -> bool
pub fn is_ts_infer_type(&self) -> bool
Returns true if self is of variant TsInferType.
Sourcepub fn as_ts_infer_type(&self) -> Option<&TsInferType>
pub fn as_ts_infer_type(&self) -> Option<&TsInferType>
Returns Some if self is a reference of variant TsInferType, and None otherwise.
Sourcepub fn is_ts_parenthesized_type(&self) -> bool
pub fn is_ts_parenthesized_type(&self) -> bool
Returns true if self is of variant TsParenthesizedType.
Sourcepub fn as_ts_parenthesized_type(&self) -> Option<&TsParenthesizedType>
pub fn as_ts_parenthesized_type(&self) -> Option<&TsParenthesizedType>
Returns Some if self is a reference of variant TsParenthesizedType, and None otherwise.
Sourcepub fn is_ts_type_operator(&self) -> bool
pub fn is_ts_type_operator(&self) -> bool
Returns true if self is of variant TsTypeOperator.
Sourcepub fn as_ts_type_operator(&self) -> Option<&TsTypeOperator>
pub fn as_ts_type_operator(&self) -> Option<&TsTypeOperator>
Returns Some if self is a reference of variant TsTypeOperator, and None otherwise.
Sourcepub fn is_ts_indexed_access_type(&self) -> bool
pub fn is_ts_indexed_access_type(&self) -> bool
Returns true if self is of variant TsIndexedAccessType.
Sourcepub fn as_ts_indexed_access_type(&self) -> Option<&TsIndexedAccessType>
pub fn as_ts_indexed_access_type(&self) -> Option<&TsIndexedAccessType>
Returns Some if self is a reference of variant TsIndexedAccessType, and None otherwise.
Sourcepub fn is_ts_mapped_type(&self) -> bool
pub fn is_ts_mapped_type(&self) -> bool
Returns true if self is of variant TsMappedType.
Sourcepub fn as_ts_mapped_type(&self) -> Option<&TsMappedType>
pub fn as_ts_mapped_type(&self) -> Option<&TsMappedType>
Returns Some if self is a reference of variant TsMappedType, and None otherwise.
Sourcepub fn is_ts_lit_type(&self) -> bool
pub fn is_ts_lit_type(&self) -> bool
Returns true if self is of variant TsLitType.
Sourcepub fn as_ts_lit_type(&self) -> Option<&TsLitType>
pub fn as_ts_lit_type(&self) -> Option<&TsLitType>
Returns Some if self is a reference of variant TsLitType, and None otherwise.
Sourcepub fn is_ts_type_predicate(&self) -> bool
pub fn is_ts_type_predicate(&self) -> bool
Returns true if self is of variant TsTypePredicate.
Sourcepub fn as_ts_type_predicate(&self) -> Option<&TsTypePredicate>
pub fn as_ts_type_predicate(&self) -> Option<&TsTypePredicate>
Returns Some if self is a reference of variant TsTypePredicate, and None otherwise.
Sourcepub fn is_ts_import_type(&self) -> bool
pub fn is_ts_import_type(&self) -> bool
Returns true if self is of variant TsImportType.
Sourcepub fn as_ts_import_type(&self) -> Option<&TsImportType>
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
impl Clone for TsTypeWrapper
Source§fn clone(&self) -> TsTypeWrapper
fn clone(&self) -> TsTypeWrapper
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TsTypeWrapper
impl Debug for TsTypeWrapper
Source§impl Deref for TsTypeWrapper
Available on crate feature swc only.
impl Deref for TsTypeWrapper
swc only.Source§impl Display for TsTypeWrapper
Available on crate feature swc only.
impl Display for TsTypeWrapper
swc only.Auto Trait Implementations§
impl Freeze for TsTypeWrapper
impl RefUnwindSafe for TsTypeWrapper
impl Send for TsTypeWrapper
impl Sync for TsTypeWrapper
impl Unpin for TsTypeWrapper
impl UnsafeUnpin for TsTypeWrapper
impl UnwindSafe for TsTypeWrapper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ImplicitClone for Twhere
T: Clone,
impl<T> ImplicitClone for Twhere
T: Clone,
fn clone_quote_var(&self) -> Self
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more