feat(compiler): adds support for quoted object keys in the parser
This commit is contained in:

committed by
Jason Aden

parent
7ae8ad6aab
commit
798947efa4
@ -165,7 +165,7 @@ export function main() {
|
||||
|
||||
it('should parse map', () => {
|
||||
checkAction('{}');
|
||||
checkAction('{a: 1}[2]');
|
||||
checkAction('{a: 1, "b": 2}[2]');
|
||||
checkAction('{}["a"]');
|
||||
});
|
||||
|
||||
@ -263,7 +263,7 @@ export function main() {
|
||||
checkBinding('a(b | c)', 'a((b | c))');
|
||||
checkBinding('a.b(c.d(e) | f)', 'a.b((c.d(e) | f))');
|
||||
checkBinding('[1, 2, 3] | a', '([1, 2, 3] | a)');
|
||||
checkBinding('{a: 1} | b', '({a: 1} | b)');
|
||||
checkBinding('{a: 1, "b": 2} | c', '({a: 1, "b": 2} | c)');
|
||||
checkBinding('a[b] | c', '(a[b] | c)');
|
||||
checkBinding('a?.b | c', '(a?.b | c)');
|
||||
checkBinding('true | a', '(true | a)');
|
||||
|
@ -124,7 +124,9 @@ class Unparser implements AstVisitor {
|
||||
for (let i = 0; i < ast.keys.length; i++) {
|
||||
if (!isFirst) this._expression += ', ';
|
||||
isFirst = false;
|
||||
this._expression += `${ast.keys[i]}: `;
|
||||
const key = ast.keys[i];
|
||||
this._expression += key.quoted ? JSON.stringify(key.key) : key.key;
|
||||
this._expression += ': ';
|
||||
this._visit(ast.values[i]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user