#[non_exhaustive]
pub enum TypeInfo {
Show 16 variants
Array {
braces: ContainedSpan,
type_info: Box<TypeInfo>,
},
Basic(TokenReference),
String(TokenReference),
Boolean(TokenReference),
Callback {
generics: Option<GenericDeclaration>,
parentheses: ContainedSpan,
arguments: Punctuated<TypeArgument>,
arrow: TokenReference,
return_type: Box<TypeInfo>,
},
Generic {
base: TokenReference,
arrows: ContainedSpan,
generics: Punctuated<TypeInfo>,
},
GenericPack {
name: TokenReference,
ellipse: TokenReference,
},
Intersection {
left: Box<TypeInfo>,
ampersand: TokenReference,
right: Box<TypeInfo>,
},
Module {
module: TokenReference,
punctuation: TokenReference,
type_info: Box<IndexedTypeInfo>,
},
Optional {
base: Box<TypeInfo>,
question_mark: TokenReference,
},
Table {
braces: ContainedSpan,
fields: Punctuated<TypeField>,
},
Typeof {
typeof_token: TokenReference,
parentheses: ContainedSpan,
inner: Box<Expression>,
},
Tuple {
parentheses: ContainedSpan,
types: Punctuated<TypeInfo>,
},
Union {
left: Box<TypeInfo>,
pipe: TokenReference,
right: Box<TypeInfo>,
},
Variadic {
ellipse: TokenReference,
type_info: Box<TypeInfo>,
},
VariadicPack {
ellipse: TokenReference,
name: TokenReference,
},
}
Expand description
Any type, such as string
, boolean?
, number | boolean
, etc.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Array
Fields
braces: ContainedSpan
The braces ({}
) containing the type info.
A shorthand type annotating the structure of an array: { number }
Basic(TokenReference)
A standalone type, such as string
or Foo
.
String(TokenReference)
A singleton string type, such as "hello"
Boolean(TokenReference)
A singleton boolean type, such as true
Callback
Fields
generics: Option<GenericDeclaration>
Optional generics provided for the arguments, such as in <T>(T) -> string
parentheses: ContainedSpan
The parentheses for the arguments.
arguments: Punctuated<TypeArgument>
The argument types: (string, number)
.
arrow: TokenReference
The “thin arrow” (->
) in between the arguments and the return type.
A callback type, such as (string, number) => boolean
.
Generic
Fields
base: TokenReference
The type that has generics: map
.
arrows: ContainedSpan
The arrows (<>
) containing the type parameters.
generics: Punctuated<TypeInfo>
The type parameters: number, string
.
A type using generics, such as map<number, string>
.
GenericPack
Fields
name: TokenReference
The name of the type that is generic: T
.
ellipse: TokenReference
The ellipse: ...
.
A generic pack: T...
.
Note, these are only available as return types, when annotating a vararg (...
) in a function parameter, or as a generic type argument.
Intersection
Fields
ampersand: TokenReference
The ampersand (&
) to separate the types.
An intersection type: string & number
, denoting both types.
Module
Fields
module: TokenReference
The module the type is coming from: module
.
punctuation: TokenReference
The punctuation (.
) to index the module.
type_info: Box<IndexedTypeInfo>
The indexed type info: Foo
.
A type coming from a module, such as module.Foo
Optional
Fields
question_mark: TokenReference
The question mark: ?
.
An optional type, such as string?
.
Table
Fields
braces: ContainedSpan
The braces ({}
) containing the fields.
fields: Punctuated<TypeField>
The fields: foo: number, bar: string
.
A type annotating the structure of a table: { foo: number, bar: string }
Typeof
Fields
typeof_token: TokenReference
The token typeof
.
parentheses: ContainedSpan
The parentheses used to contain the expression.
inner: Box<Expression>
The inner expression: foo
.
A type in the form of typeof(foo)
.
Tuple
Fields
parentheses: ContainedSpan
The parentheses used to contain the types
types: Punctuated<TypeInfo>
The types: (string, number)
.
A tuple expression: (string, number)
.
Union
Fields
pipe: TokenReference
The pipe (|
) to separate the types.
A union type: string | number
, denoting one or the other.
Variadic
Fields
ellipse: TokenReference
The ellipse: ...
.
A variadic type: ...number
.
VariadicPack
Fields
ellipse: TokenReference
The ellipse: ...
name: TokenReference
The name of the type that is variadic: T
A variadic type pack: ...T
in Function<...T>
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
The start position of a node. None if can’t be determined
The end position of a node. None if it can’t be determined
Whether another node of the same type is the same as this one semantically, ignoring position
The token references that comprise a node
The full range of a node, if it has both start and end positions
Auto Trait Implementations
impl RefUnwindSafe for TypeInfo
impl UnwindSafe for TypeInfo
Blanket Implementations
Mutably borrows from an owned value. Read more