@@ -66,6 +66,17 @@ fn test_skip() {
66
66
C ,
67
67
/// Comment for D
68
68
D ,
69
+ /// Comment for Struct
70
+ Struct {
71
+ #[ serde( skip) ]
72
+ field_a : bool ,
73
+ field_b : u8 ,
74
+ field_c : String ,
75
+ } ,
76
+ /// Comment for Tuple
77
+ Tuple ( #[ serde( skip) ] bool , u8 , String ) ,
78
+ /// Comment for NewType
79
+ NewType ( #[ serde( skip) ] bool ) ,
69
80
}
70
81
71
82
let expected = indoc ! { r#"
@@ -77,13 +88,69 @@ fn test_skip() {
77
88
* Comment for D
78
89
*/
79
90
export type D = "D";
91
+ /**
92
+ * Comment for Struct
93
+ */
94
+ export type Struct = { Struct: { field_b: number; field_c: string } };
95
+ /**
96
+ * Comment for Tuple
97
+ */
98
+ export type Tuple = { Tuple: [number, string] };
99
+ /**
100
+ * Comment for NewType
101
+ */
102
+ export type NewType = "NewType";
80
103
}
81
104
82
105
/**
83
106
* Comment for Enum
84
107
*/
85
- export type Enum = "D";"#
108
+ export type Enum = "D" | { Struct: { field_b: number; field_c: string } } | { Tuple: [number, string] } | "NewType" ;"#
86
109
} ;
87
110
88
111
assert_eq ! ( Enum :: DECL , expected) ;
112
+
113
+ /// Comment for InternalTagEnum
114
+ #[ derive( Tsify ) ]
115
+ #[ serde( tag = "type" ) ]
116
+ #[ tsify( namespace) ]
117
+ enum InternalTagEnum {
118
+ /// Comment for Unit
119
+ Unit ,
120
+ /// Comment for Struct
121
+ Struct {
122
+ #[ serde( skip) ]
123
+ field_a : bool ,
124
+ field_b : u8 ,
125
+ } ,
126
+ /// Comment for NewType
127
+ NewType ( #[ serde( skip) ] bool ) ,
128
+ }
129
+
130
+ let expected = indoc ! { r#"
131
+ /**
132
+ * Comment for InternalTagEnum
133
+ */
134
+ declare namespace InternalTagEnum {
135
+ /**
136
+ * Comment for Unit
137
+ */
138
+ export type Unit = { type: "Unit" };
139
+ /**
140
+ * Comment for Struct
141
+ */
142
+ export type Struct = { type: "Struct"; field_b: number };
143
+ /**
144
+ * Comment for NewType
145
+ */
146
+ export type NewType = { type: "NewType" };
147
+ }
148
+
149
+ /**
150
+ * Comment for InternalTagEnum
151
+ */
152
+ export type InternalTagEnum = { type: "Unit" } | { type: "Struct"; field_b: number } | { type: "NewType" };"#
153
+ } ;
154
+
155
+ assert_eq ! ( InternalTagEnum :: DECL , expected) ;
89
156
}
0 commit comments