Skip to content

Commit

Permalink
fix: Improve output for object's computed property names (#1275)
Browse files Browse the repository at this point in the history
Co-authored-by: Laszlo Radics <laszlo.radics@labcup.net>
  • Loading branch information
garaboncias and Laszlo Radics committed Apr 20, 2020
1 parent 2f38fc5 commit 8c2b698
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 102 deletions.
2 changes: 1 addition & 1 deletion src/lib/converter/factories/declaration.ts
Expand Up @@ -56,7 +56,7 @@ export function createDeclaration(context: Context, node: ts.Declaration, kind:
const match = builtInSymbolRegExp.exec(name);
if (match) {
name = `[Symbol.${match[1]}]`;
} else if (kind & ReflectionKind.ClassMember && name === '__computed') {
} else if (kind & (ReflectionKind.ClassMember | ReflectionKind.VariableOrProperty) && name === '__computed') {
// rename computed properties
const declName = ts.getNameOfDeclaration(node);
const symbol = declName && context.checker.getSymbolAtLocation(declName);
Expand Down
6 changes: 5 additions & 1 deletion src/test/converter/variables/literal.ts
@@ -1,3 +1,4 @@
const x = 'literal';
/**
* An object literal.
*/
Expand All @@ -10,7 +11,10 @@ const objectLiteral = {
valueA: [100, 200, 300]
},
valueA: 100,
valueB: true
valueB: true,
[Symbol.toStringTag]: 'computed',
[x]: true,
['literal2']: true,
};

/**
Expand Down

0 comments on commit 8c2b698

Please sign in to comment.