Skip to content

Commit

Permalink
Real fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jan 4, 2023
1 parent 0cc308c commit 663732a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions crates/swc_ecma_parser/src/lexer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,7 @@ impl<'a, I: Input> Iterator for Lexer<'a, I> {
if c == '<' {
self.input.bump();
return Ok(Some(tok!('<')));
} else if c == '>'
&& !self.ctx.prefer_bin_op_over_type_arg_closing
&& !(self.state.is_expr_allowed || self.input.peek() != Some('>'))
{
} else if c == '>' && !self.ctx.prefer_bin_op_over_type_arg_closing {
self.input.bump();
return Ok(Some(tok!('>')));
}
Expand Down
6 changes: 5 additions & 1 deletion crates/swc_ecma_parser/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,11 @@ impl<I: Tokens> Parser<I> {
return_if_arrow!(self, obj);

let type_args = if self.syntax().typescript() && is!(self, '<') {
self.try_parse_ts_type_args()
self.with_ctx(Context {
prefer_bin_op_over_type_arg_closing: true,
..self.ctx()
})
.try_parse_ts_type_args()
} else {
None
};
Expand Down
6 changes: 1 addition & 5 deletions crates/swc_ecma_parser/src/parser/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,7 @@ impl<I: Tokens> Parser<I> {
pub(super) fn try_parse_ts_type_args(&mut self) -> Option<Box<TsTypeParamInstantiation>> {
debug_assert!(self.input.syntax().typescript());

self.with_ctx(Context {
prefer_bin_op_over_type_arg_closing: true,
..self.ctx()
})
.try_parse_ts(|p| {
self.try_parse_ts(|p| {
let type_args = p.parse_ts_type_args()?;
if is_one_of!(
p, '<', // invalid syntax
Expand Down

0 comments on commit 663732a

Please sign in to comment.