Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit f3b3447

Browse files
chore: 🤖 more doc
1 parent 90b759b commit f3b3447

File tree

1 file changed

+10
-6
lines changed
  • crates/rome_js_parser/src/syntax/typescript

1 file changed

+10
-6
lines changed

crates/rome_js_parser/src/syntax/typescript/types.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,9 @@ fn can_follow_type_arguments_in_expr(p: &mut Parser) -> bool {
13051305
}
13061306
}
13071307

1308-
/// You could refer to https://github.com/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/parser.ts#L4475
1308+
/// Checking if parser is at start of expression with some error recovery logic in it, e.g.
1309+
/// we counted `binary_operator` as start of an expression, but `binary_operator` is not part of expression actually
1310+
/// For more details, you could refer to https://github.com/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/parser.ts#L4475
13091311
fn is_start_of_expr(p: &mut Parser) -> bool {
13101312
if is_start_of_left_hand_side_expression(p) {
13111313
return true;
@@ -1328,19 +1330,21 @@ fn is_start_of_expr(p: &mut Parser) -> bool {
13281330
// that the start of an expression. That way we'll parse out a missing identifier,
13291331
// give a good message about an identifier being missing, and then consume the
13301332
// rest of the binary expression.
1331-
_ => is_binary_operator(p) || is_at_identifier(p),
1333+
_ => is_binary_operator(p),
13321334
}
13331335
}
13341336

1335-
/// Please refer to https://github.com/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/parser.ts#L5141-L5147
13361337
fn is_binary_operator(p: &mut Parser) -> bool {
1337-
// TODO: https://github.dev/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/parser.ts#L5142-L5144 Optional variance
1338+
// TODO: support Optional Variance Annotations
1339+
// https://github.dev/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/parser.ts#L5142-L5144
1340+
1341+
// In typescript, the operatorPrecedence of `Comma` is 0,which means we need to ensure the `OperatorPrecedence` is bigger than `Comma`
1342+
// For more details, you could refer to (https://github.com/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/utilities.ts#L3555), https://github.com/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/parser.ts#L5146
13381343

1339-
// In typescript, the operatorPrecedence of `Comma` is 0(https://github.com/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/utilities.ts#L3555), so https://github.com/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/parser.ts#L5146 means we need to ensure the `OperatorPrecedence` is bigger than `Comma`
13401344
matches!(OperatorPrecedence::try_from_binary_operator(p.cur()), Some(precedence) if precedence > OperatorPrecedence::Comma)
13411345
}
13421346

1343-
/// You could refer to https://github.com/microsoft/TypeScript/blob/42b1049aee8c655631cb4f0065de86ec1023d20a/src/compiler/parser.ts#L4446
1347+
/// Checking if parser at left_hand_side_expression
13441348
fn is_start_of_left_hand_side_expression(p: &mut Parser) -> bool {
13451349
match p.cur() {
13461350
T![super]

0 commit comments

Comments
 (0)