@@ -20,7 +20,11 @@ use oxc_syntax::number::{BigintBase, NumberBase};
2020#[ ast( visit) ]
2121#[ derive( Debug , Clone ) ]
2222#[ generate_derive( CloneIn , GetSpan , GetSpanMut , ContentEq , ESTree ) ]
23- #[ estree( rename = "Literal" , via = crate :: serialize:: ESTreeLiteral , add_ts = "raw: string | null" ) ]
23+ #[ estree(
24+ rename = "Literal" ,
25+ add_fields( raw = crate :: serialize:: boolean_literal_raw( self ) ) ,
26+ add_ts = "raw: string | null" ,
27+ ) ]
2428pub struct BooleanLiteral {
2529 /// Node location in source code
2630 pub span : Span ,
@@ -34,7 +38,14 @@ pub struct BooleanLiteral {
3438#[ ast( visit) ]
3539#[ derive( Debug , Clone ) ]
3640#[ generate_derive( CloneIn , GetSpan , GetSpanMut , ContentEq , ESTree ) ]
37- #[ estree( rename = "Literal" , via = crate :: serialize:: ESTreeLiteral , add_ts = "value: null, raw: \" null\" | null" ) ]
41+ #[ estree(
42+ rename = "Literal" ,
43+ add_fields(
44+ value = ( ) ,
45+ raw = crate :: serialize:: null_literal_raw( self ) ,
46+ ) ,
47+ add_ts = "value: null, raw: \" null\" | null" ,
48+ ) ]
3849pub struct NullLiteral {
3950 /// Node location in source code
4051 pub span : Span ,
@@ -46,7 +57,7 @@ pub struct NullLiteral {
4657#[ ast( visit) ]
4758#[ derive( Debug , Clone ) ]
4859#[ generate_derive( CloneIn , ContentEq , GetSpan , GetSpanMut , ESTree ) ]
49- #[ estree( rename = "Literal" , via = crate :: serialize :: ESTreeLiteral ) ]
60+ #[ estree( rename = "Literal" ) ]
5061pub struct NumericLiteral < ' a > {
5162 /// Node location in source code
5263 pub span : Span ,
@@ -69,7 +80,7 @@ pub struct NumericLiteral<'a> {
6980#[ ast( visit) ]
7081#[ derive( Debug , Clone ) ]
7182#[ generate_derive( CloneIn , ContentEq , GetSpan , GetSpanMut , ESTree ) ]
72- #[ estree( rename = "Literal" , via = crate :: serialize :: ESTreeLiteral ) ]
83+ #[ estree( rename = "Literal" ) ]
7384pub struct StringLiteral < ' a > {
7485 /// Node location in source code
7586 pub span : Span ,
@@ -89,7 +100,14 @@ pub struct StringLiteral<'a> {
89100#[ ast( visit) ]
90101#[ derive( Debug , Clone ) ]
91102#[ generate_derive( CloneIn , ContentEq , GetSpan , GetSpanMut , ESTree ) ]
92- #[ estree( rename = "Literal" , via = crate :: serialize:: ESTreeLiteral , add_ts = "value: null, bigint: string" ) ]
103+ #[ estree(
104+ rename = "Literal" ,
105+ add_fields(
106+ value = ( ) ,
107+ bigint = crate :: serialize:: bigint_literal_bigint( self ) ,
108+ ) ,
109+ add_ts = "value: null, bigint: string" ,
110+ ) ]
93111pub struct BigIntLiteral < ' a > {
94112 /// Node location in source code
95113 pub span : Span ,
@@ -109,16 +127,15 @@ pub struct BigIntLiteral<'a> {
109127#[ derive( Debug ) ]
110128#[ generate_derive( CloneIn , ContentEq , GetSpan , GetSpanMut , ESTree ) ]
111129#[ estree(
112- rename = "Literal" ,
113- via = crate :: serialize:: ESTreeLiteral ,
114- add_ts = "value: {} | null, regex: { pattern: string, flags: string }"
130+ rename = "Literal" ,
131+ add_fields ( value = crate :: serialize:: EmptyObject ) ,
132+ add_ts = "value: {} | null" ,
115133) ]
116134pub struct RegExpLiteral < ' a > {
117135 /// Node location in source code
118136 pub span : Span ,
119137 /// The parsed regular expression. See [`oxc_regular_expression`] for more
120138 /// details.
121- #[ estree( skip) ]
122139 pub regex : RegExp < ' a > ,
123140 /// The regular expression as it appears in source code
124141 ///
@@ -136,8 +153,10 @@ pub struct RegExpLiteral<'a> {
136153#[ estree( no_type) ]
137154pub struct RegExp < ' a > {
138155 /// The regex pattern between the slashes
156+ #[ estree( ts_type = "string" ) ]
139157 pub pattern : RegExpPattern < ' a > ,
140158 /// Regex flags after the closing slash
159+ #[ estree( ts_type = "string" ) ]
141160 pub flags : RegExpFlags ,
142161}
143162
@@ -147,6 +166,7 @@ pub struct RegExp<'a> {
147166#[ ast]
148167#[ derive( Debug ) ]
149168#[ generate_derive( CloneIn , ESTree ) ]
169+ #[ estree( custom_serialize, no_ts_def) ]
150170pub enum RegExpPattern < ' a > {
151171 /// Unparsed pattern. Contains string slice of the pattern.
152172 /// Pattern was not parsed, so may be valid or invalid.
@@ -204,28 +224,6 @@ bitflags! {
204224/// Dummy type to communicate the content of `RegExpFlags` to `oxc_ast_tools`.
205225#[ ast( foreign = RegExpFlags ) ]
206226#[ generate_derive( ESTree ) ]
207- #[ estree(
208- custom_serialize,
209- custom_ts_def = "
210- type RegExpFlags = {
211- /** Global flag */
212- G: 1;
213- /** Ignore case flag */
214- I: 2;
215- /** Multiline flag */
216- M: 4;
217- /** DotAll flag */
218- S: 8;
219- /** Unicode flag */
220- U: 16;
221- /** Sticky flag */
222- Y: 32;
223- /** Indices flag */
224- D: 64;
225- /** Unicode sets flag */
226- V: 128;
227- }
228- "
229- ) ]
227+ #[ estree( custom_serialize, no_ts_def) ]
230228#[ expect( dead_code) ]
231229struct RegExpFlagsAlias ( u8 ) ;
0 commit comments