Enum stc_ts_file_analyzer::ty::Type
source · [−]pub enum Type {
Show 38 variants
Instance(Instance),
StaticThis(StaticThis),
This(ThisType),
Lit(LitType),
Query(QueryType),
Infer(InferType),
Import(ImportType),
Predicate(Predicate),
IndexedAccessType(IndexedAccessType),
Ref(Ref),
TypeLit(TypeLit),
Keyword(KeywordType),
Conditional(Conditional),
Tuple(Tuple),
Array(Array),
Union(Union),
Intersection(Intersection),
Function(Function),
Constructor(Constructor),
Index(Index),
Readonly(Readonly),
Unique(Unique),
Param(TypeParam),
EnumVariant(EnumVariant),
Interface(Interface),
Enum(ArcCow<Enum>),
Mapped(Mapped),
Alias(Alias),
Namespace(Namespace),
Module(Module),
Class(Class),
ClassDef(ArcCow<ClassDef>),
Arc(Freezed),
Rest(RestType),
Optional(OptionalType),
Symbol(Symbol),
Tpl(TplType),
StringMapping(StringMapping),
}
Expand description
A TypeScript type.
Invariants
-
Type::Union cannot have a single element.
-
Type::Intersection cannot have a single element.
-
Type::Union cannot have Type::Union as a element,
-
Type::Intersection cannot have Type::Intersection as a element,
Type::assert_valid
can be used to ensure invariants.
Note that this is noop in release build.
Clone
To reduce memory usage, this type should be freeze()
-ed.
Freezed type is immutable, and it’s cheap to clone.
When required, you can use normalize_mut()
or foldable()
to get mutable
version.
Note: You have to call normalize()
while pattern matching.
To enforce this, deep cloning is not allowed by default. If you want to
clone deeply, you have to clone this type in a closure passed to
ALLOW_DEEP_CLONE
. But this is not recommended, and should be avoided for
performance.
Variants
Instance(Instance)
StaticThis(StaticThis)
This(ThisType)
Lit(LitType)
Query(QueryType)
Infer(InferType)
Import(ImportType)
Predicate(Predicate)
IndexedAccessType(IndexedAccessType)
Ref(Ref)
TypeLit(TypeLit)
Keyword(KeywordType)
Conditional(Conditional)
Tuple(Tuple)
Array(Array)
Union(Union)
Intersection(Intersection)
Function(Function)
Constructor(Constructor)
Index(Index)
Readonly(Readonly)
Unique(Unique)
Param(TypeParam)
EnumVariant(EnumVariant)
Interface(Interface)
Enum(ArcCow<Enum>)
Mapped(Mapped)
Alias(Alias)
export type A = Foo;
Namespace(Namespace)
Module(Module)
Class(Class)
Instance of a class.
ClassDef(ArcCow<ClassDef>)
Class definition itself.
Arc(Freezed)
Rest(RestType)
Optional(OptionalType)
Symbol(Symbol)
Tpl(TplType)
StringMapping(StringMapping)
Implementations
sourceimpl Type
impl Type
pub fn is_this(&self) -> bool
pub fn as_this(&self) -> Option<&ThisType>
sourcepub fn as_this_mut(&mut self) -> Option<&mut ThisType>
pub fn as_this_mut(&mut self) -> Option<&mut ThisType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn this(self) -> Option<ThisType>
pub fn this(self) -> Option<ThisType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_this(self) -> ThisType
pub fn expect_this(self) -> ThisType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_lit(&self) -> bool
pub fn as_lit(&self) -> Option<&LitType>
sourcepub fn as_lit_mut(&mut self) -> Option<&mut LitType>
pub fn as_lit_mut(&mut self) -> Option<&mut LitType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn lit(self) -> Option<LitType>
pub fn lit(self) -> Option<LitType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_lit(self) -> LitType
pub fn expect_lit(self) -> LitType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_query(&self) -> bool
pub fn as_query(&self) -> Option<&QueryType>
sourcepub fn as_query_mut(&mut self) -> Option<&mut QueryType>
pub fn as_query_mut(&mut self) -> Option<&mut QueryType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn query(self) -> Option<QueryType>
pub fn query(self) -> Option<QueryType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_query(self) -> QueryType
pub fn expect_query(self) -> QueryType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_infer(&self) -> bool
pub fn as_infer(&self) -> Option<&InferType>
sourcepub fn as_infer_mut(&mut self) -> Option<&mut InferType>
pub fn as_infer_mut(&mut self) -> Option<&mut InferType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn infer(self) -> Option<InferType>
pub fn infer(self) -> Option<InferType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_infer(self) -> InferType
pub fn expect_infer(self) -> InferType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_import(&self) -> bool
pub fn as_import(&self) -> Option<&ImportType>
sourcepub fn as_import_mut(&mut self) -> Option<&mut ImportType>
pub fn as_import_mut(&mut self) -> Option<&mut ImportType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn import(self) -> Option<ImportType>
pub fn import(self) -> Option<ImportType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_import(self) -> ImportType
pub fn expect_import(self) -> ImportType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_predicate(&self) -> bool
pub fn as_predicate(&self) -> Option<&Predicate>
sourcepub fn as_predicate_mut(&mut self) -> Option<&mut Predicate>
pub fn as_predicate_mut(&mut self) -> Option<&mut Predicate>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn predicate(self) -> Option<Predicate>
pub fn predicate(self) -> Option<Predicate>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_predicate(self) -> Predicate
pub fn expect_predicate(self) -> Predicate
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_indexed_access_type(&self) -> bool
pub fn as_indexed_access_type(&self) -> Option<&IndexedAccessType>
sourcepub fn as_indexed_access_type_mut(&mut self) -> Option<&mut IndexedAccessType>
pub fn as_indexed_access_type_mut(&mut self) -> Option<&mut IndexedAccessType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn indexed_access_type(self) -> Option<IndexedAccessType>
pub fn indexed_access_type(self) -> Option<IndexedAccessType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_indexed_access_type(self) -> IndexedAccessType
pub fn expect_indexed_access_type(self) -> IndexedAccessType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_ref_type(&self) -> bool
pub fn as_ref_type(&self) -> Option<&Ref>
sourcepub fn as_ref_type_mut(&mut self) -> Option<&mut Ref>
pub fn as_ref_type_mut(&mut self) -> Option<&mut Ref>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn ref_type(self) -> Option<Ref>
pub fn ref_type(self) -> Option<Ref>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_ref_type(self) -> Ref
pub fn expect_ref_type(self) -> Ref
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_type_lit(&self) -> bool
pub fn as_type_lit(&self) -> Option<&TypeLit>
sourcepub fn as_type_lit_mut(&mut self) -> Option<&mut TypeLit>
pub fn as_type_lit_mut(&mut self) -> Option<&mut TypeLit>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn type_lit(self) -> Option<TypeLit>
pub fn type_lit(self) -> Option<TypeLit>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_type_lit(self) -> TypeLit
pub fn expect_type_lit(self) -> TypeLit
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_keyword(&self) -> bool
pub fn as_keyword(&self) -> Option<&KeywordType>
sourcepub fn as_keyword_mut(&mut self) -> Option<&mut KeywordType>
pub fn as_keyword_mut(&mut self) -> Option<&mut KeywordType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn keyword(self) -> Option<KeywordType>
pub fn keyword(self) -> Option<KeywordType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_keyword(self) -> KeywordType
pub fn expect_keyword(self) -> KeywordType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_conditional(&self) -> bool
pub fn as_conditional(&self) -> Option<&Conditional>
sourcepub fn as_conditional_mut(&mut self) -> Option<&mut Conditional>
pub fn as_conditional_mut(&mut self) -> Option<&mut Conditional>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn conditional(self) -> Option<Conditional>
pub fn conditional(self) -> Option<Conditional>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_conditional(self) -> Conditional
pub fn expect_conditional(self) -> Conditional
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_tuple(&self) -> bool
pub fn as_tuple(&self) -> Option<&Tuple>
sourcepub fn as_tuple_mut(&mut self) -> Option<&mut Tuple>
pub fn as_tuple_mut(&mut self) -> Option<&mut Tuple>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn tuple(self) -> Option<Tuple>
pub fn tuple(self) -> Option<Tuple>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_tuple(self) -> Tuple
pub fn expect_tuple(self) -> Tuple
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_array(&self) -> bool
pub fn as_array(&self) -> Option<&Array>
sourcepub fn as_array_mut(&mut self) -> Option<&mut Array>
pub fn as_array_mut(&mut self) -> Option<&mut Array>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn array(self) -> Option<Array>
pub fn array(self) -> Option<Array>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_array(self) -> Array
pub fn expect_array(self) -> Array
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_union_type(&self) -> bool
pub fn as_union_type(&self) -> Option<&Union>
sourcepub fn as_union_type_mut(&mut self) -> Option<&mut Union>
pub fn as_union_type_mut(&mut self) -> Option<&mut Union>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn union_type(self) -> Option<Union>
pub fn union_type(self) -> Option<Union>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_union_type(self) -> Union
pub fn expect_union_type(self) -> Union
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_intersection(&self) -> bool
pub fn as_intersection(&self) -> Option<&Intersection>
sourcepub fn as_intersection_mut(&mut self) -> Option<&mut Intersection>
pub fn as_intersection_mut(&mut self) -> Option<&mut Intersection>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn intersection(self) -> Option<Intersection>
pub fn intersection(self) -> Option<Intersection>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_intersection(self) -> Intersection
pub fn expect_intersection(self) -> Intersection
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_fn_type(&self) -> bool
pub fn as_fn_type(&self) -> Option<&Function>
sourcepub fn as_fn_type_mut(&mut self) -> Option<&mut Function>
pub fn as_fn_type_mut(&mut self) -> Option<&mut Function>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn fn_type(self) -> Option<Function>
pub fn fn_type(self) -> Option<Function>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_fn_type(self) -> Function
pub fn expect_fn_type(self) -> Function
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_constructor(&self) -> bool
pub fn as_constructor(&self) -> Option<&Constructor>
sourcepub fn as_constructor_mut(&mut self) -> Option<&mut Constructor>
pub fn as_constructor_mut(&mut self) -> Option<&mut Constructor>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn constructor(self) -> Option<Constructor>
pub fn constructor(self) -> Option<Constructor>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_constructor(self) -> Constructor
pub fn expect_constructor(self) -> Constructor
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_index(&self) -> bool
pub fn as_index(&self) -> Option<&Index>
sourcepub fn as_index_mut(&mut self) -> Option<&mut Index>
pub fn as_index_mut(&mut self) -> Option<&mut Index>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn index(self) -> Option<Index>
pub fn index(self) -> Option<Index>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_index(self) -> Index
pub fn expect_index(self) -> Index
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_readonly(&self) -> bool
pub fn as_readonly(&self) -> Option<&Readonly>
sourcepub fn as_readonly_mut(&mut self) -> Option<&mut Readonly>
pub fn as_readonly_mut(&mut self) -> Option<&mut Readonly>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn readonly(self) -> Option<Readonly>
pub fn readonly(self) -> Option<Readonly>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_readonly(self) -> Readonly
pub fn expect_readonly(self) -> Readonly
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_unique(&self) -> bool
pub fn as_unique(&self) -> Option<&Unique>
sourcepub fn as_unique_mut(&mut self) -> Option<&mut Unique>
pub fn as_unique_mut(&mut self) -> Option<&mut Unique>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn unique(self) -> Option<Unique>
pub fn unique(self) -> Option<Unique>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_unique(self) -> Unique
pub fn expect_unique(self) -> Unique
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_type_param(&self) -> bool
pub fn as_type_param(&self) -> Option<&TypeParam>
sourcepub fn as_type_param_mut(&mut self) -> Option<&mut TypeParam>
pub fn as_type_param_mut(&mut self) -> Option<&mut TypeParam>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn type_param(self) -> Option<TypeParam>
pub fn type_param(self) -> Option<TypeParam>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_type_param(self) -> TypeParam
pub fn expect_type_param(self) -> TypeParam
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_enum_variant(&self) -> bool
pub fn as_enum_variant(&self) -> Option<&EnumVariant>
sourcepub fn as_enum_variant_mut(&mut self) -> Option<&mut EnumVariant>
pub fn as_enum_variant_mut(&mut self) -> Option<&mut EnumVariant>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn enum_variant(self) -> Option<EnumVariant>
pub fn enum_variant(self) -> Option<EnumVariant>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_enum_variant(self) -> EnumVariant
pub fn expect_enum_variant(self) -> EnumVariant
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_interface(&self) -> bool
pub fn as_interface(&self) -> Option<&Interface>
sourcepub fn as_interface_mut(&mut self) -> Option<&mut Interface>
pub fn as_interface_mut(&mut self) -> Option<&mut Interface>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn interface(self) -> Option<Interface>
pub fn interface(self) -> Option<Interface>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_interface(self) -> Interface
pub fn expect_interface(self) -> Interface
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_enum_type(&self) -> bool
pub fn as_enum_type(&self) -> Option<&ArcCow<Enum>>
sourcepub fn as_enum_type_mut(&mut self) -> Option<&mut ArcCow<Enum>>
pub fn as_enum_type_mut(&mut self) -> Option<&mut ArcCow<Enum>>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn enum_type(self) -> Option<ArcCow<Enum>>
pub fn enum_type(self) -> Option<ArcCow<Enum>>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_enum_type(self) -> ArcCow<Enum>
pub fn expect_enum_type(self) -> ArcCow<Enum>
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_mapped(&self) -> bool
pub fn as_mapped(&self) -> Option<&Mapped>
sourcepub fn as_mapped_mut(&mut self) -> Option<&mut Mapped>
pub fn as_mapped_mut(&mut self) -> Option<&mut Mapped>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn mapped(self) -> Option<Mapped>
pub fn mapped(self) -> Option<Mapped>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_mapped(self) -> Mapped
pub fn expect_mapped(self) -> Mapped
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_alias(&self) -> bool
pub fn as_alias(&self) -> Option<&Alias>
sourcepub fn as_alias_mut(&mut self) -> Option<&mut Alias>
pub fn as_alias_mut(&mut self) -> Option<&mut Alias>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn alias(self) -> Option<Alias>
pub fn alias(self) -> Option<Alias>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_alias(self) -> Alias
pub fn expect_alias(self) -> Alias
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_namespace(&self) -> bool
pub fn as_namespace(&self) -> Option<&Namespace>
sourcepub fn as_namespace_mut(&mut self) -> Option<&mut Namespace>
pub fn as_namespace_mut(&mut self) -> Option<&mut Namespace>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn namespace(self) -> Option<Namespace>
pub fn namespace(self) -> Option<Namespace>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_namespace(self) -> Namespace
pub fn expect_namespace(self) -> Namespace
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_module(&self) -> bool
pub fn as_module(&self) -> Option<&Module>
sourcepub fn as_module_mut(&mut self) -> Option<&mut Module>
pub fn as_module_mut(&mut self) -> Option<&mut Module>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn module(self) -> Option<Module>
pub fn module(self) -> Option<Module>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_module(self) -> Module
pub fn expect_module(self) -> Module
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_class(&self) -> bool
pub fn as_class(&self) -> Option<&Class>
sourcepub fn as_class_mut(&mut self) -> Option<&mut Class>
pub fn as_class_mut(&mut self) -> Option<&mut Class>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn class(self) -> Option<Class>
pub fn class(self) -> Option<Class>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_class(self) -> Class
pub fn expect_class(self) -> Class
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_class_def(&self) -> bool
pub fn as_class_def(&self) -> Option<&ArcCow<ClassDef>>
sourcepub fn as_class_def_mut(&mut self) -> Option<&mut ArcCow<ClassDef>>
pub fn as_class_def_mut(&mut self) -> Option<&mut ArcCow<ClassDef>>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn class_def(self) -> Option<ArcCow<ClassDef>>
pub fn class_def(self) -> Option<ArcCow<ClassDef>>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_class_def(self) -> ArcCow<ClassDef>
pub fn expect_class_def(self) -> ArcCow<ClassDef>
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_rest(&self) -> bool
pub fn as_rest(&self) -> Option<&RestType>
sourcepub fn as_rest_mut(&mut self) -> Option<&mut RestType>
pub fn as_rest_mut(&mut self) -> Option<&mut RestType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn rest(self) -> Option<RestType>
pub fn rest(self) -> Option<RestType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_rest(self) -> RestType
pub fn expect_rest(self) -> RestType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_optional(&self) -> bool
pub fn as_optional(&self) -> Option<&OptionalType>
sourcepub fn as_optional_mut(&mut self) -> Option<&mut OptionalType>
pub fn as_optional_mut(&mut self) -> Option<&mut OptionalType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn optional(self) -> Option<OptionalType>
pub fn optional(self) -> Option<OptionalType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_optional(self) -> OptionalType
pub fn expect_optional(self) -> OptionalType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_symbol(&self) -> bool
pub fn as_symbol(&self) -> Option<&Symbol>
sourcepub fn as_symbol_mut(&mut self) -> Option<&mut Symbol>
pub fn as_symbol_mut(&mut self) -> Option<&mut Symbol>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn symbol(self) -> Option<Symbol>
pub fn symbol(self) -> Option<Symbol>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_symbol(self) -> Symbol
pub fn expect_symbol(self) -> Symbol
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_tpl(&self) -> bool
pub fn as_tpl(&self) -> Option<&TplType>
sourcepub fn as_tpl_mut(&mut self) -> Option<&mut TplType>
pub fn as_tpl_mut(&mut self) -> Option<&mut TplType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn tpl(self) -> Option<TplType>
pub fn tpl(self) -> Option<TplType>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_tpl(self) -> TplType
pub fn expect_tpl(self) -> TplType
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_string_mapping(&self) -> bool
pub fn as_string_mapping(&self) -> Option<&StringMapping>
sourcepub fn as_string_mapping_mut(&mut self) -> Option<&mut StringMapping>
pub fn as_string_mapping_mut(&mut self) -> Option<&mut StringMapping>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn string_mapping(self) -> Option<StringMapping>
pub fn string_mapping(self) -> Option<StringMapping>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_string_mapping(self) -> StringMapping
pub fn expect_string_mapping(self) -> StringMapping
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn is_instance(&self) -> bool
pub fn as_instance(&self) -> Option<&Instance>
sourcepub fn as_instance_mut(&mut self) -> Option<&mut Instance>
pub fn as_instance_mut(&mut self) -> Option<&mut Instance>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn instance(self) -> Option<Instance>
pub fn instance(self) -> Option<Instance>
This method normalizes the type only if the underlying type is the required variant.
sourcepub fn expect_instance(self) -> Instance
pub fn expect_instance(self) -> Instance
Panics
Panics if the underlying type is not the required variant.
sourceimpl Type
impl Type
pub fn assert_clone_cheap(&self)
pub fn new_intersection<I>(span: Span, iter: I) -> Typewhere
I: IntoIterator<Item = Type>,
pub fn new_union_without_dedup(span: Span, types: Vec<Type, Global>) -> Type
pub fn new_union<I>(span: Span, iter: I) -> Typewhere
I: IntoIterator<Item = Type> + Debug,
sourcepub fn force_generalize_top_level_literals(self) -> Type
pub fn force_generalize_top_level_literals(self) -> Type
If self
is Type::Lit, convert it to Type::Keyword.
pub fn is_void(&self) -> bool
pub fn contains_void(&self) -> bool
pub fn is_any(&self) -> bool
pub fn is_unknown(&self) -> bool
pub fn contains_undefined(&self) -> bool
sourcepub fn as_array_without_readonly(&self) -> Option<&Array>
pub fn as_array_without_readonly(&self) -> Option<&Array>
Returns Some if self
is an array or an readonly array.
sourceimpl Type
impl Type
sourcepub fn is_clone_cheap(&self) -> bool
pub fn is_clone_cheap(&self) -> bool
TODO
pub fn is_null(&self) -> bool
pub fn is_undefined(&self) -> bool
pub fn is_null_or_undefined(&self) -> bool
pub fn is_kwd(&self, k: TsKeywordTypeKind) -> bool
pub fn is_unique_symbol(&self) -> bool
pub fn is_symbol_like(&self) -> bool
pub fn is_never(&self) -> bool
pub fn never(span: Span, metadata: KeywordTypeMetadata) -> Type
pub fn undefined(span: Span, metadata: KeywordTypeMetadata) -> Type
pub fn any(span: Span, metadata: KeywordTypeMetadata) -> Type
pub fn void(span: Span, metadata: KeywordTypeMetadata) -> Type
pub fn unknown(span: Span, metadata: KeywordTypeMetadata) -> Type
pub fn is_str_like(&self) -> bool
pub fn is_num_like(&self) -> bool
pub fn is_bool_like(&self) -> bool
pub fn is_bigint_like(&self) -> bool
pub fn is_structured(&self) -> bool
pub fn is_substitution(&self) -> bool
pub fn is_instantiable_non_primitive(&self) -> bool
pub fn is_instantiable_primitive(&self) -> bool
pub fn is_instantiable(&self) -> bool
pub fn is_structured_or_instantiable(&self) -> bool
sourceimpl Type
impl Type
pub fn metadata(&self) -> CommonTypeMetadata
pub fn metadata_mut(&mut self) -> &mut CommonTypeMetadata
sourcepub fn reposition(&mut self, from: Span)
pub fn reposition(&mut self, from: Span)
Respan but preserve SyntaxContext
pub fn respan(&mut self, span: Span)
sourceimpl Type
impl Type
pub fn get_type_param_decl(&self) -> Option<&TypeParamDecl>
sourcepub fn assert_valid(&self)
pub fn assert_valid(&self)
Panics if type is invalid. This is debug-build only and it’s noop on a release build.
Validity
For example, any | any
is invalid because
union should not have duplicate elements.
pub fn is_global_this(&self) -> bool
sourceimpl Type
impl Type
sourcepub fn foldable(self) -> Type
pub fn foldable(self) -> Type
Converts this type to foldable type.
TODO(kdy1): Remove if possible
sourcepub fn normalize_instance<'s, 'c>(&'s self) -> &'c Typewhere
's: 'c,
pub fn normalize_instance<'s, 'c>(&'s self) -> &'c Typewhere
's: 'c,
Type::Arc and Type::Instance are normalized.
sourcepub fn normalize_mut(&mut self) -> &mut Type
pub fn normalize_mut(&mut self) -> &mut Type
Type::Static
is normalized.
pub fn iter_union(&self) -> impl Debug + Iterator<Item = &Type>
sourceimpl Type
impl Type
sourcepub fn is_builtin_interface(&self, name: &str) -> bool
pub fn is_builtin_interface(&self, name: &str) -> bool
Return true if self
is a Type::Ref pointing to name
.
pub fn is_str_lit(&self) -> bool
pub fn is_bool_lit(&self) -> bool
pub fn is_num(&self) -> bool
pub fn is_bigint(&self) -> bool
pub fn is_num_lit(&self) -> bool
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Type
impl<'de> Deserialize<'de> for Type
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Type, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Type, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
sourceimpl EqIgnoreSpan for Type
impl EqIgnoreSpan for Type
fn eq_ignore_span(&self, other: &Type) -> bool
sourceimpl Fold<Type> for ReturnTypeGeneralizer<'_, '_, '_>
impl Fold<Type> for ReturnTypeGeneralizer<'_, '_, '_>
sourceimpl Freeze for Type
impl Freeze for Type
sourcefn is_clone_cheap(&self) -> bool
fn is_clone_cheap(&self) -> bool
true
if `Clone::clone is cheap.sourcefn freeze(&mut self)
fn freeze(&mut self)
sourcefn freezed(self) -> Self
fn freezed(self) -> Self
Self::freeze
and return self
.sourceimpl From<Conditional> for Type
impl From<Conditional> for Type
sourcefn from(v: Conditional) -> Type
fn from(v: Conditional) -> Type
sourceimpl From<Constructor> for Type
impl From<Constructor> for Type
sourcefn from(v: Constructor) -> Type
fn from(v: Constructor) -> Type
sourceimpl From<EnumVariant> for Type
impl From<EnumVariant> for Type
sourcefn from(v: EnumVariant) -> Type
fn from(v: EnumVariant) -> Type
sourceimpl From<ImportType> for Type
impl From<ImportType> for Type
sourcefn from(v: ImportType) -> Type
fn from(v: ImportType) -> Type
sourceimpl From<IndexedAccessType> for Type
impl From<IndexedAccessType> for Type
sourcefn from(v: IndexedAccessType) -> Type
fn from(v: IndexedAccessType) -> Type
sourceimpl From<Intersection> for Type
impl From<Intersection> for Type
sourcefn from(v: Intersection) -> Type
fn from(v: Intersection) -> Type
sourceimpl From<KeywordType> for Type
impl From<KeywordType> for Type
sourcefn from(v: KeywordType) -> Type
fn from(v: KeywordType) -> Type
sourceimpl From<OptionalType> for Type
impl From<OptionalType> for Type
sourcefn from(v: OptionalType) -> Type
fn from(v: OptionalType) -> Type
sourceimpl From<StaticThis> for Type
impl From<StaticThis> for Type
sourcefn from(v: StaticThis) -> Type
fn from(v: StaticThis) -> Type
sourceimpl From<StringMapping> for Type
impl From<StringMapping> for Type
sourcefn from(v: StringMapping) -> Type
fn from(v: StringMapping) -> Type
sourceimpl MapWithMut for Type
impl MapWithMut for Type
sourceimpl RemoveTypes for Type
impl RemoveTypes for Type
sourcefn remove_falsy(self) -> Type
fn remove_falsy(self) -> Type
self
.sourcefn remove_truthy(self) -> Type
fn remove_truthy(self) -> Type
self
.sourceimpl Serialize for Type
impl Serialize for Type
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
sourceimpl VisitMut<Type> for FnReturnTypeHandler<'_, '_, '_>
impl VisitMut<Type> for FnReturnTypeHandler<'_, '_, '_>
sourceimpl VisitMut<Type> for IndexedAccessTypeReplacer<'_>
impl VisitMut<Type> for IndexedAccessTypeReplacer<'_>
sourceimpl VisitMut<Type> for MappedIndexTypeReplacer<'_>
impl VisitMut<Type> for MappedIndexTypeReplacer<'_>
sourceimpl VisitMut<Type> for ReturnTypeSimplifier<'_, '_, '_>
impl VisitMut<Type> for ReturnTypeSimplifier<'_, '_, '_>
sourceimpl VisitMut<Type> for ShallowNormalizer<'_, '_, '_>
impl VisitMut<Type> for ShallowNormalizer<'_, '_, '_>
sourceimpl VisitMut<Type> for TypeParamEscapeHandler<'_, '_, '_>
impl VisitMut<Type> for TypeParamEscapeHandler<'_, '_, '_>
sourceimpl<V> VisitMutWith<V> for Typewhere
V: ?Sized,
impl<V> VisitMutWith<V> for Typewhere
V: ?Sized,
fn visit_mut_children_with(&mut self, _visitor: &mut V)
fn visit_mut_with(&mut self, visitor: &mut V)where
V: VisitMut<Self>,
sourceimpl<V> VisitWith<V> for Typewhere
V: ?Sized,
impl<V> VisitWith<V> for Typewhere
V: ?Sized,
fn visit_children_with(&self, _visitor: &mut V)
fn visit_with(&self, visitor: &mut V)where
V: Visit<Self>,
impl StructuralPartialEq for Type
impl Visitable for Type
Auto Trait Implementations
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
Blanket Implementations
sourceimpl<T> AssertCloneCheap for Twhere
T: Freeze,
impl<T> AssertCloneCheap for Twhere
T: Freeze,
sourcefn assert_clone_cheap(&self)
fn assert_clone_cheap(&self)
self
is cheap to clone. This noop on production build.