pub enum TypeAnnotationKind {
Show 15 variants
Name {
name: Ident,
args: Vec<TypeAnnotation>,
},
Qualified {
path: Vec<Ident>,
args: Vec<TypeAnnotation>,
},
StringLiteral(String),
NumberLiteral(LiteralF64),
BigIntLiteral(String),
BooleanLiteral(bool),
Array(Box<TypeAnnotation>),
Tuple(Vec<TypeAnnotation>),
Optional(Box<TypeAnnotation>),
Readonly(Box<TypeAnnotation>),
Object {
fields: Vec<TypeAnnotationField>,
index: Option<Box<IndexSignatureAnnotation>>,
},
Function {
params: Vec<TypeAnnotationField>,
return_type: Box<TypeAnnotation>,
},
Union(Vec<TypeAnnotation>),
KeyOf(Box<TypeAnnotation>),
TypeOf {
path: Vec<Ident>,
},
}Variants§
Name
name.span covers the identifier only; outer span includes any <…> args.
Qualified
Dotted type like Temporal.Instant. path.len() >= 2; last segment is the type name.
StringLiteral(String)
NumberLiteral(LiteralF64)
Parser canonicalizes -0.0 to 0.0.
BigIntLiteral(String)
Decimal digits with a leading - when negative, as in crate::Type::BigIntLiteral.
BooleanLiteral(bool)
Array(Box<TypeAnnotation>)
Tuple(Vec<TypeAnnotation>)
Element labels ([x: number, y: number]) are documentation only, so the
parser checks and drops them.
Optional(Box<TypeAnnotation>)
An omittable tuple element (T? or name?: T).
Readonly(Box<TypeAnnotation>)
Object
Function
Function type annotation. Only the named-parameter form is accepted.
Union(Vec<TypeAnnotation>)
Always ≥2 members; single-element unions are unwrapped by the parser.
KeyOf(Box<TypeAnnotation>)
keyof T — the union of T’s member names as string literal types.
Resolved eagerly, so this never reaches the typed AST.
TypeOf
typeof x — the type of the value x, looked up in the value namespace
rather than the type namespace. path is the dotted reference, one span per
segment (typeof o.k has two). Resolved eagerly, like KeyOf.