pub enum TsValue {
Show 37 variants
Undefined,
Null,
Boolean(bool),
Number(f64),
String(String),
Object(HashMap<String, TsValue>),
Array(Vec<TsValue>),
Function(Rc<dyn Fn(&[TsValue]) -> TsValue>),
Error(String),
Union(Vec<TsValue>),
Generic(String, Vec<TsValue>),
Symbol(String),
BigInt(i128),
Date(i64),
RegExp(String),
Map(Vec<(TsValue, TsValue)>),
Set(Vec<TsValue>),
Promise(Box<TsValue>),
Iterable(Box<dyn Iterator<Item = TsValue>>),
Conditional(Conditional),
Mapped(Mapped),
TemplateLiteral(TemplateLiteral),
KeyOf(Box<TsValue>),
TypeOf(Box<TsValue>),
IndexedAccess {
object_type: Box<TsValue>,
index_type: Box<TsValue>,
},
Tuple(Vec<TsValue>),
Readonly(Box<TsValue>),
Nullable(Box<TsValue>),
NonNullable(Box<TsValue>),
Infer {
type_param: String,
constraint: Option<Box<TsValue>>,
},
FunctionType {
params: Vec<(String, TsValue)>,
return_type: Box<TsValue>,
},
ConstructorType {
params: Vec<(String, TsValue)>,
return_type: Box<TsValue>,
},
ThisType,
Never,
Unknown,
Any,
Void,
}Expand description
TypeScript 值类型枚举
Variants§
Undefined
未定义
Null
空值
Boolean(bool)
布尔值
Number(f64)
数字
String(String)
字符串
Object(HashMap<String, TsValue>)
对象
Array(Vec<TsValue>)
数组
Function(Rc<dyn Fn(&[TsValue]) -> TsValue>)
函数
Error(String)
错误
Union(Vec<TsValue>)
联合类型
Generic(String, Vec<TsValue>)
泛型类型
Symbol(String)
符号
BigInt(i128)
大整数
Date(i64)
日期
RegExp(String)
正则表达式
Map(Vec<(TsValue, TsValue)>)
Map
Set(Vec<TsValue>)
Set
Promise(Box<TsValue>)
Promise
Iterable(Box<dyn Iterator<Item = TsValue>>)
可迭代对象
Conditional(Conditional)
条件类型 T extends U ? X : Y
Mapped(Mapped)
映射类型 { [K in keyof T]: V }
TemplateLiteral(TemplateLiteral)
模板字面量类型
KeyOf(Box<TsValue>)
keyof 类型操作符结果
TypeOf(Box<TsValue>)
typeof 类型操作符结果
IndexedAccess
索引访问类型 T[K]
Tuple(Vec<TsValue>)
元组类型
Readonly(Box<TsValue>)
只读类型
Nullable(Box<TsValue>)
可空类型 (T | null)
NonNullable(Box<TsValue>)
不可空类型 (NonNullable
Infer
推断类型 (infer U)
FunctionType
函数类型
ConstructorType
构造函数类型
ThisType
this 类型
Never
never 类型
Unknown
unknown 类型
Any
any 类型
Void
void 类型
Implementations§
Source§impl TsValue
impl TsValue
Sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
检查是否为未定义
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
检查是否为布尔值
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
检查是否为函数
Sourcepub fn is_generic(&self) -> bool
pub fn is_generic(&self) -> bool
检查是否为泛型类型
Sourcepub fn is_promise(&self) -> bool
pub fn is_promise(&self) -> bool
检查是否为 Promise
Sourcepub fn is_iterable(&self) -> bool
pub fn is_iterable(&self) -> bool
检查是否为可迭代对象
Sourcepub fn is_conditional(&self) -> bool
pub fn is_conditional(&self) -> bool
检查是否为条件类型
Sourcepub fn is_template_literal(&self) -> bool
pub fn is_template_literal(&self) -> bool
检查是否为模板字面量类型
Sourcepub fn is_indexed_access(&self) -> bool
pub fn is_indexed_access(&self) -> bool
检查是否为索引访问类型
Sourcepub fn is_readonly(&self) -> bool
pub fn is_readonly(&self) -> bool
检查是否为只读类型
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
检查是否为可空类型
Sourcepub fn is_non_nullable(&self) -> bool
pub fn is_non_nullable(&self) -> bool
检查是否为不可空类型
Sourcepub fn is_function_type(&self) -> bool
pub fn is_function_type(&self) -> bool
检查是否为函数类型
Sourcepub fn is_constructor_type(&self) -> bool
pub fn is_constructor_type(&self) -> bool
检查是否为构造函数类型
Sourcepub fn is_this_type(&self) -> bool
pub fn is_this_type(&self) -> bool
检查是否为 this 类型
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
检查是否为 unknown 类型
Sourcepub fn to_boolean(&self) -> bool
pub fn to_boolean(&self) -> bool
转换为布尔值
Sourcepub fn is_assignable_to(&self, target: &TsValue) -> bool
pub fn is_assignable_to(&self, target: &TsValue) -> bool
检查类型是否可赋值给目标类型
Sourcepub fn get_property_keys(&self) -> Vec<String>
pub fn get_property_keys(&self) -> Vec<String>
获取类型的所有属性键
Sourcepub fn get_property_type(&self, key: &str) -> Option<TsValue>
pub fn get_property_type(&self, key: &str) -> Option<TsValue>
获取指定属性的类型
Sourcepub fn evaluate_conditional(
&self,
check_type: &TsValue,
extends_type: &TsValue,
) -> Option<bool>
pub fn evaluate_conditional( &self, check_type: &TsValue, extends_type: &TsValue, ) -> Option<bool>
评估条件类型
Sourcepub fn infer_type_params(&self, target: &TsValue) -> InferenceResult
pub fn infer_type_params(&self, target: &TsValue) -> InferenceResult
推断类型参数
Sourcepub fn substitute_type_params(
&self,
substitutions: &HashMap<String, TsValue>,
) -> TsValue
pub fn substitute_type_params( &self, substitutions: &HashMap<String, TsValue>, ) -> TsValue
替换类型参数
Sourcepub fn intersection_with(&self, other: &TsValue) -> TsValue
pub fn intersection_with(&self, other: &TsValue) -> TsValue
Sourcepub fn apply_mapped_type(&self, mapped_type: &Mapped) -> TsValue
pub fn apply_mapped_type(&self, mapped_type: &Mapped) -> TsValue
Sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
Sourcepub fn is_complex(&self) -> bool
pub fn is_complex(&self) -> bool
Sourcepub fn difference(&self, other: &TsValue) -> TsValue
pub fn difference(&self, other: &TsValue) -> TsValue
计算类型差集
Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
检查类型是否为字面量类型
Sourcepub fn get_base_type(&self) -> TsValue
pub fn get_base_type(&self) -> TsValue
获取类型的基础类型
Sourcepub fn is_part_of_union(&self, union: &TsValue) -> bool
pub fn is_part_of_union(&self, union: &TsValue) -> bool
检查类型是否为联合类型的一部分
Sourcepub fn resolve_keyof(&self) -> TsValue
pub fn resolve_keyof(&self) -> TsValue
解析 keyof 类型
Sourcepub fn resolve_indexed_access(&self) -> TsValue
pub fn resolve_indexed_access(&self) -> TsValue
解析索引访问类型
Sourcepub fn resolve_mapped(&self) -> TsValue
pub fn resolve_mapped(&self) -> TsValue
解析映射类型
Trait Implementations§
impl Eq for TsValue
impl Send for TsValue
impl Sync for TsValue
Auto Trait Implementations§
impl Freeze for TsValue
impl !RefUnwindSafe for TsValue
impl Unpin for TsValue
impl UnsafeUnpin for TsValue
impl !UnwindSafe for TsValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more