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::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

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

This method normalizes the type only if the underlying type is the required variant.

This method normalizes the type only if the underlying type is the required variant.

Panics

Panics if the underlying type is not the required variant.

If self is Type::Lit, convert it to Type::Keyword.

Returns Some if self is an array or an readonly array.

TODO

Respan but preserve SyntaxContext

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.

Converts this type to foldable type.

TODO(kdy1): Remove if possible

Type::Arc is normalized.

Type::Arc and Type::Instance are normalized.

Type::Static is normalized.

Return true if self is a Type::Ref pointing to name.

Returns true if self is a string or a string literal.

Returns true if self is a boolean or a boolean literal.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Returns true if `Clone::clone is cheap.
Make `Clone::clone cheap.
Call Self::freeze and return self.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Removes falsy values from self.
Removes truthy values from self.
Serialize this value into the given Serde serializer. Read more
Get span of self.
Note: This method should return true for non-type values.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Assert that self is cheap to clone. This noop on production build.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Gets a custom text range to use when emitting comments.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more