refactor(compiler): produce binary expressions instead of dedicated write ones (#61682)

Currently our expression parser produces two different expressions for writes: `PropertyWrite` (e.g. `foo.bar = 123`) or `KeyedWrite` (e.g. `foo[0] = 123`). This is inconsistent with other ASTs, like TypeScript's, where writes are represented as binary expressions with a `=` operator and it makes it difficult to implement more write operators like `??=`, because we'd essentially have to duplicate them.

These changes switch the expression parser over to produce binary expressions instead.

PR Close #61682
This commit is contained in:
Kristiyan Kostadinov
2025-05-26 12:58:15 +02:00
committed by kirjs
parent c663277df6
commit 08ee693995
2 changed files with 15 additions and 15 deletions
@@ -532,13 +532,13 @@ describe('parser', () => {
it('should record property write span', () => {
const ast = parseAction('a = b');
expect(unparseWithSpan(ast)).toContain(['a = b', 'a = b']);
expect(unparseWithSpan(ast)).toContain(['a = b', '[nameSpan] a']);
expect(unparseWithSpan(ast)).toContain(['a', '[nameSpan] a']);
});
it('should record accessed property write span', () => {
const ast = parseAction('a.b = c');
expect(unparseWithSpan(ast)).toContain(['a.b = c', 'a.b = c']);
expect(unparseWithSpan(ast)).toContain(['a.b = c', '[nameSpan] b']);
expect(unparseWithSpan(ast)).toContain(['a.b', '[nameSpan] b']);
});
it('should record spans for untagged template literals with no interpolations', () => {