typescript_ast/ast/
tstype.rs1
2#[derive(Debug)]
3pub enum TsType {
4 Any,
5 Number,
6 String,
7 Boolean,
8 Null,
9 Custom(String),
10}
11
12impl From<&str> for TsType {
13 fn from(s: &str) -> Self {
14 match s {
15 "any" => Self::Any,
16 "number" => Self::Number,
17 "string" => Self::String,
18 "boolean" => Self::Boolean,
19 "null" => Self::Null,
20 _ => Self::Custom(s.to_string()),
21 }
22 }
23}
24
25impl From<Option<&str>> for TsType {
26 fn from(s: Option<&str>) -> Self {
27 if let Some(s) = s {
28 s.into()
29 } else {
30 Self::Any
31 }
32 }
33}