@playcanvas/attribute-parser 1.4.0 → 1.5.0
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.
package/package.json
CHANGED
|
@@ -154,7 +154,7 @@ export class AttributeParser {
|
|
|
154
154
|
|
|
155
155
|
// Check if the declaration is a TypeScript enum
|
|
156
156
|
if (ts.isEnumDeclaration(declaration)) {
|
|
157
|
-
members = declaration.members.map(member => ({ [member.name.
|
|
157
|
+
members = declaration.members.map(member => ({ [member.name.text]: member.initializer.text }));
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
// Additionally check for JSDoc enum tag
|
|
@@ -187,7 +187,8 @@ export class AttributeParser {
|
|
|
187
187
|
node.properties.forEach((property) => {
|
|
188
188
|
|
|
189
189
|
if (ts.isPropertyAssignment(property)) {
|
|
190
|
-
const
|
|
190
|
+
const isValidName = ts.isIdentifier(property.name) || ts.isStringLiteral(property.name);
|
|
191
|
+
const name = isValidName && property.name.text;
|
|
191
192
|
const value = getLiteralValue(property.initializer, this.typeChecker);
|
|
192
193
|
members.push({ [name]: value });
|
|
193
194
|
}
|
|
@@ -56,10 +56,11 @@ function runTests(fileName) {
|
|
|
56
56
|
expect(data[0].example.attributes.h.name).to.equal('h');
|
|
57
57
|
expect(data[0].example.attributes.h.type).to.equal('string');
|
|
58
58
|
expect(data[0].example.attributes.h.array).to.equal(false);
|
|
59
|
-
expect(data[0].example.attributes.h.enum).to.be.an('array').with.lengthOf(
|
|
59
|
+
expect(data[0].example.attributes.h.enum).to.be.an('array').with.lengthOf(4);
|
|
60
60
|
expect(data[0].example.attributes.h.enum[0]).to.deep.equal({ A: 'a' });
|
|
61
61
|
expect(data[0].example.attributes.h.enum[1]).to.deep.equal({ B: 'b' });
|
|
62
62
|
expect(data[0].example.attributes.h.enum[2]).to.deep.equal({ C: 'c' });
|
|
63
|
+
expect(data[0].example.attributes.h.enum[3]).to.deep.equal({ 'A string key': 'd' });
|
|
63
64
|
expect(data[0].example.attributes.h.default).to.equal('');
|
|
64
65
|
});
|
|
65
66
|
|