typescript-to-lua 1.24.0 → 1.24.1

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.
@@ -16,6 +16,7 @@ const call_extension_1 = require("./language-extensions/call-extension");
16
16
  const multi_1 = require("./language-extensions/multi");
17
17
  const optional_chaining_1 = require("./optional-chaining");
18
18
  const typescript_2 = require("typescript");
19
+ const identifier_1 = require("./identifier");
19
20
  function addOneToArrayAccessArgument(context, node, index) {
20
21
  const type = context.checker.getTypeAtLocation(node.expression);
21
22
  const argumentType = context.checker.getTypeAtLocation(node.argumentExpression);
@@ -76,9 +77,14 @@ exports.transformElementAccessExpressionWithCapture = transformElementAccessExpr
76
77
  const transformPropertyAccessExpression = (node, context) => transformPropertyAccessExpressionWithCapture(context, node, undefined).expression;
77
78
  exports.transformPropertyAccessExpression = transformPropertyAccessExpression;
78
79
  function transformPropertyAccessExpressionWithCapture(context, node, thisValueCapture) {
79
- const property = node.name.text;
80
80
  const type = context.checker.getTypeAtLocation(node.expression);
81
81
  const isOptionalLeft = (0, optional_chaining_1.isOptionalContinuation)(node.expression);
82
+ let property = node.name.text;
83
+ const symbol = context.checker.getSymbolAtLocation(node.name);
84
+ const customName = (0, identifier_1.getCustomNameFromSymbol)(symbol);
85
+ if (customName) {
86
+ property = customName;
87
+ }
82
88
  const constEnumValue = (0, enum_1.tryGetConstEnumValue)(context, node);
83
89
  if (constEnumValue) {
84
90
  return { expression: constEnumValue };
@@ -130,9 +136,12 @@ function transformPropertyAccessExpressionWithCapture(context, node, thisValueCa
130
136
  };
131
137
  }
132
138
  if (node.expression.kind === typescript_2.SyntaxKind.SuperKeyword) {
133
- return {
134
- expression: (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.DescriptorGet, node, lua.createIdentifier("self"), table, lua.createStringLiteral(property)),
135
- };
139
+ const symbol = context.checker.getSymbolAtLocation(node);
140
+ if (symbol && symbol.flags & ts.SymbolFlags.GetAccessor) {
141
+ return {
142
+ expression: (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.DescriptorGet, node, lua.createIdentifier("self"), table, lua.createStringLiteral(property)),
143
+ };
144
+ }
136
145
  }
137
146
  return { expression: lua.createTableIndexExpression(table, lua.createStringLiteral(property), node) };
138
147
  }
@@ -57,11 +57,14 @@ lhs, right, rightHasPrecedingStatements, parent) {
57
57
  }
58
58
  if (ts.isPropertyAccessExpression(lhs) || ts.isElementAccessExpression(lhs)) {
59
59
  if (lhs.expression.kind === typescript_1.SyntaxKind.SuperKeyword) {
60
- return [
61
- lua.createExpressionStatement((0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.DescriptorSet, parent, lua.createIdentifier("self"), context.transformExpression(lhs.expression), ts.isPropertyAccessExpression(lhs)
62
- ? lua.createStringLiteral(lhs.name.text)
63
- : context.transformExpression(lhs.argumentExpression), right)),
64
- ];
60
+ const symbol = context.checker.getSymbolAtLocation(lhs);
61
+ if (symbol && symbol.flags & ts.SymbolFlags.SetAccessor) {
62
+ return [
63
+ lua.createExpressionStatement((0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.DescriptorSet, parent, lua.createIdentifier("self"), context.transformExpression(lhs.expression), ts.isPropertyAccessExpression(lhs)
64
+ ? lua.createStringLiteral(lhs.name.text)
65
+ : context.transformExpression(lhs.argumentExpression), right)),
66
+ ];
67
+ }
65
68
  }
66
69
  }
67
70
  const symbol = lhs.parent && ts.isShorthandPropertyAssignment(lhs.parent)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-to-lua",
3
- "version": "1.24.0",
3
+ "version": "1.24.1",
4
4
  "description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
5
5
  "repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
6
6
  "homepage": "https://typescripttolua.github.io/",