Skip to content

Commit

Permalink
chore(parser): explain the reason for omitting "}" and ">" in jsx tex…
Browse files Browse the repository at this point in the history
…t lexer (#2097)

closes #2094
  • Loading branch information
Boshen authored Jan 20, 2024
1 parent 3f2b48f commit 59e29f2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/oxc_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,11 @@ impl<'a> Lexer<'a> {
}
Some(_) => {
loop {
// `>` and `}` are errors in TypeScript but not Babel
// let's make this less strict so we can parse more code
if matches!(self.peek(), Some('{' | '<')) {
// The tokens `{`, `<`, `>` and `}` cannot appear in a jsx text.
// The TypeScript compiler raises the error "Unexpected token. Did you mean `{'>'}` or `&gt;`?".
// Where as the Babel compiler does not raise any errors.
// The following check omits `>` and `}` so that more Babel tests can be passed.
if self.peek().is_some_and(|c| c == '{' || c == '<') {
break;
}
if self.current.chars.next().is_none() {
Expand Down

0 comments on commit 59e29f2

Please sign in to comment.