pub enum TypeValue {
Show 17 variants
ERROR,
String(Token),
Boolean(Token),
Nil(Token),
Wrap(Bracketed<Pointer<TypeValue>>),
Function {
generics: Option<Pointer<GenericDeclaration>>,
parameters: BracketedList<ParameterTypeName>,
arrow: Token,
return_type: Pointer<TypeValue>,
},
Basic {
base: Token,
generics: Option<Pointer<BracketedList<Pointer<TypeValue>>>>,
},
GenericPack {
name: Token,
ellipsis: Token,
},
Intersection {
left: Pointer<TypeValue>,
ampersand: Token,
right: Pointer<TypeValue>,
},
Union {
left: Pointer<TypeValue>,
pipe: Token,
right: Pointer<TypeValue>,
},
Module {
module: Token,
dot: Token,
name: Token,
generics: Option<Pointer<BracketedList<Pointer<TypeValue>>>>,
},
Optional {
base: Pointer<TypeValue>,
question_mark: Token,
},
Table(Table),
Typeof {
typeof_token: Token,
inner: Bracketed<Pointer<Expression>>,
},
Tuple(BracketedList<Pointer<TypeValue>>),
Variadic {
ellipsis: Token,
type_value: Pointer<TypeValue>,
},
VariadicPack {
ellipsis: Token,
name: Token,
},
}Expand description
Possible values for a type.
Variants§
ERROR
This TypeValue had a syntax error.
String(Token)
A singleton string.
type Foo = "Bar"Boolean(Token)
A boolean value
type Foo = true
type Bar = falseNil(Token)
nil
type Foo = nilWrap(Bracketed<Pointer<TypeValue>>)
A wrap of another type, the difference between this and a
tuple is that this item always have one type and only one
type in it, while a tuple can have any, even 0.
type Foo = (bar)Function
A function type.
type Foo = (arg1: number) -> (boolean, string)`Fields
generics: Option<Pointer<GenericDeclaration>>Optional generics provided for the function.
type Foo = <P, R>(parameter: P) -> Rparameters: BracketedList<ParameterTypeName>The parameters this function accepts.
Basic
A reference to a different type.
type Foo = Bar
type FooBar = Qux<string>Fields
GenericPack
A generic pack.
<T...>Intersection
An intersection between two types.
type Foo = Bar & QuxFields
Union
An union between two types.
type Foo = Bar & QuxFields
Module
An access to an exported type from a module.
Fields
Optional
An optional type.
type Foo = Bar?This is just equivalent to:
type Foo = Bar | nilTable(Table)
A table type.
type Foo = { string }
type Bar = { Qux: Foo }Typeof
A typeof expression.
Fields
inner: Bracketed<Pointer<Expression>>The expression passed to typeof.
Tuple(BracketedList<Pointer<TypeValue>>)
A tuple of types
type Foo = () -> (string, number)The tuple here is the return type (string, number). In luau, tuples can’t be
their own type, meaning, this is a syntax error:
type Foo = (string, number)Variadic
A variadic type.
...FooThe difference between this and a variadic pack is that
this one can be with a type and not just a name:
...{ Foo: "Bar" }And is that variadic types are used in function parameters and returns, while variadic packs are used for generics.
VariadicPack
Trait Implementations§
Source§impl Ord for TypeValue
impl Ord for TypeValue
Source§impl PartialOrd for TypeValue
impl PartialOrd for TypeValue
Source§impl Print for TypeValue
impl Print for TypeValue
Source§fn print_final_trivia(&self) -> String
fn print_final_trivia(&self) -> String
Print::print, which just joins Print::print_without_final_trivia
and this function.