Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions common/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,32 @@ Objects with reserved words as keys
(pair key: (property_identifier) value: (true))
(pair key: (property_identifier) value: (true))
(pair key: (property_identifier) value: (true)))))

====================================
Assignment to non-null LHS
====================================

foo! = bar;
foo! += bar;
(foo)! = bar;
(foo)! += bar;

---
(program
(expression_statement
(assignment_expression
(non_null_expression (identifier))
(identifier)))
(expression_statement
(augmented_assignment_expression
(non_null_expression (identifier))
(identifier)))
(expression_statement
(assignment_expression
(non_null_expression (parenthesized_expression (identifier)))
(identifier)))
(expression_statement
(augmented_assignment_expression
(non_null_expression
(parenthesized_expression (identifier)))
(identifier))))
4 changes: 4 additions & 0 deletions common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ module.exports = function defineGrammar(dialect) {
field('arguments', optional($.arguments))
)),

_augmented_assignment_lhs: ($, previous) => choice(previous, $.non_null_expression),

_lhs_expression: ($, previous) => choice(previous, $.non_null_expression),

// If the dialect is regular typescript, we exclude JSX expressions and
// include type assertions. If the dialect is TSX, we do the opposite.
_expression: ($, previous) => {
Expand Down