@@ -176,6 +176,13 @@ pub struct TsSyntax {
176176 #[ serde( skip, default ) ]
177177 pub dts : bool ,
178178
179+ #[ serde( default ) ]
180+ /// When enabled, the parser will not create ParenExpr nodes for
181+ /// parenthesized expressions. Instead, it returns the inner expression
182+ /// directly. This aligns with the ESTree spec, which does not have a
183+ /// ParenthesizedExpression type.
184+ pub no_paren : bool ,
185+
179186 #[ serde( skip, default ) ]
180187 pub no_early_errors : bool ,
181188
@@ -203,6 +210,9 @@ impl TsSyntax {
203210 if self . decorators {
204211 flags |= SyntaxFlags :: DECORATORS ;
205212 }
213+ if self . no_paren {
214+ flags |= SyntaxFlags :: NO_PAREN ;
215+ }
206216 if self . dts {
207217 flags |= SyntaxFlags :: DTS ;
208218 }
@@ -227,6 +237,13 @@ pub struct EsSyntax {
227237 #[ serde( default ) ]
228238 pub fn_bind : bool ,
229239
240+ #[ serde( default ) ]
241+ /// When enabled, the parser will not create ParenExpr nodes for
242+ /// parenthesized expressions. Instead, it returns the inner expression
243+ /// directly. This aligns with the ESTree spec, which does not have a
244+ /// ParenthesizedExpression type.
245+ pub no_paren : bool ,
246+
230247 /// Enable decorators.
231248 #[ serde( default ) ]
232249 pub decorators : bool ,
@@ -271,6 +288,9 @@ impl EsSyntax {
271288 if self . decorators {
272289 flags |= SyntaxFlags :: DECORATORS ;
273290 }
291+ if self . no_paren {
292+ flags |= SyntaxFlags :: NO_PAREN ;
293+ }
274294 if self . decorators_before_export {
275295 flags |= SyntaxFlags :: DECORATORS_BEFORE_EXPORT ;
276296 }
@@ -318,6 +338,11 @@ impl SyntaxFlags {
318338 self . contains ( SyntaxFlags :: FN_BIND )
319339 }
320340
341+ #[ inline( always) ]
342+ pub const fn no_paren ( & self ) -> bool {
343+ self . contains ( SyntaxFlags :: NO_PAREN )
344+ }
345+
321346 #[ inline( always) ]
322347 pub const fn decorators ( & self ) -> bool {
323348 self . contains ( SyntaxFlags :: DECORATORS )
@@ -395,5 +420,6 @@ bitflags::bitflags! {
395420 const NO_EARLY_ERRORS = 1 << 11 ;
396421 const DISALLOW_AMBIGUOUS_JSX_LIKE = 1 << 12 ;
397422 const TS = 1 << 13 ;
423+ const NO_PAREN = 1 << 14 ;
398424 }
399425}
0 commit comments