wuchale 0.14.5 → 0.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -112,10 +112,17 @@ export class Transformer {
112
112
  visitObjectExpression = (node) => node.properties.map(this.visit).flat();
113
113
  visitObjectPattern = (node) => node.properties.map(this.visit).flat();
114
114
  visitRestElement = (node) => this.visit(node.argument);
115
- visitProperty = (node) => [
116
- ...this.visit(node.key),
117
- ...this.visit(node.value),
118
- ];
115
+ visitProperty = (node) => {
116
+ const msgs = this.visit(node.key);
117
+ if (msgs.length && node.key.type === 'Literal' && typeof node.key.value === 'string' && !node.computed) {
118
+ // @ts-expect-error
119
+ this.mstr.appendRight(node.key.start, '[');
120
+ // @ts-expect-error
121
+ this.mstr.appendLeft(node.key.end, ']');
122
+ }
123
+ msgs.push(...this.visit(node.value));
124
+ return msgs;
125
+ };
119
126
  visitSpreadElement = (node) => this.visit(node.argument);
120
127
  visitMemberExpression = (node) => [
121
128
  ...this.visit(node.object),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuchale",
3
- "version": "0.14.5",
3
+ "version": "0.14.6",
4
4
  "description": "Protobuf-like i18n from plain code",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",