Skip to content

Commit 02d88f2

Browse files
committed
Simpler lookahead, let the tryParse do the hard work
1 parent 9636142 commit 02d88f2

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

src/compiler/parser.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,34 +3221,13 @@ module ts {
32213221
}
32223222
}
32233223

3224-
// If encounter "([", this could be the start of an array binding pattern.
3224+
// If encounter "([" or "({", this could be the start of a binding pattern.
32253225
// Examples:
32263226
// ([ x ]) => { }
3227-
// ([ x ])
3228-
if (second === SyntaxKind.OpenBracketToken) {
3229-
// If the next token is not ",", "...", "[", "{", or an identifier, then this could either be
3230-
// an arrow function with an array binding pattern or a parenthesized array literal expression.
3231-
// Otherwise, it cannot be an array binding pattern.
3232-
let third = nextToken();
3233-
if (isIdentifierOrPattern() || third === SyntaxKind.CommaToken || third === SyntaxKind.DotDotDotToken) {
3234-
return Tristate.Unknown;
3235-
}
3236-
3237-
return Tristate.False;
3238-
}
3239-
3240-
// If we encounter "({", this could be the start of an object binding pattern.
3241-
// Examples:
32423227
// ({ x }) => { }
3228+
// ([ x ])
32433229
// ({ x })
3244-
// ({ *x() { })
3245-
if (second === SyntaxKind.OpenBraceToken) {
3246-
// If we encountered an asterisk, then this is a generator method on an
3247-
// object literal and cannot be a binding pattern.
3248-
if (nextToken() === SyntaxKind.AsteriskToken) {
3249-
return Tristate.False;
3250-
}
3251-
3230+
if (second === SyntaxKind.OpenBracketToken || second === SyntaxKind.OpenBraceToken) {
32523231
return Tristate.Unknown;
32533232
}
32543233

0 commit comments

Comments
 (0)