We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5974e27 commit b0f04e7Copy full SHA for b0f04e7
src/TSHelper.ts
@@ -101,10 +101,13 @@ export class TSHelper {
101
}
102
103
public static hasCustomDecorator(type: ts.Type, checker: ts.TypeChecker, decorator: string): boolean {
104
- const comment = type.symbol.getDocumentationComment(checker);
105
- const decorators =
106
- comment.filter((_) => _.kind === "text").map((_) => _.text.trim()).filter((_) => _[0] === "!");
107
- return decorators.indexOf(decorator) > -1;
+ if (type.symbol) {
+ const comment = type.symbol.getDocumentationComment(checker);
+ const decorators =
+ comment.filter((_) => _.kind === "text").map((_) => _.text.trim()).filter((_) => _[0] === "!");
108
+ return decorators.indexOf(decorator) > -1;
109
+ }
110
+ return false;
111
112
113
// Search up until finding a node satisfying the callback
src/Transpiler.ts
@@ -361,21 +361,17 @@ export class LuaTranspiler {
361
362
363
public transpileFor(node: ts.ForStatement): string {
364
- // Get iterator variable
365
- const variableDeclaration = (node.initializer as ts.VariableDeclarationList).declarations[0];
366
- const variable = this.transpileVariableDeclaration(variableDeclaration);
367
- const condition = this.transpileExpression(node.condition);
368
- const incrementor = this.transpileExpression(node.incrementor);
369
-
370
// Add header
371
- let result = `--for(${variable.trim()}; ${condition}; ${incrementor};)\n`;
372
- result += this.indent + variable;
+ let result = "";
+ for (const variableDeclaration of (node.initializer as ts.VariableDeclarationList).declarations) {
+ result += this.transpileVariableDeclaration(variableDeclaration);
373
result += this.indent + `while(${this.transpileExpression(node.condition)}) do\n`;
374
375
// Add body
376
this.pushIndent();
377
result += this.transpileStatement(node.statement);
378
- result += this.indent + incrementor + "\n";
+ result += this.indent + this.transpileExpression(node.incrementor) + "\n";
379
this.popIndent();
380
381
result += this.indent + "end\n";
test/translation/lua/classExtension.lua test/translation/lua/classExtension1.luatest/translation/lua/classExtension.lua renamed to test/translation/lua/classExtension1.lua
test/translation/lua/classExtension2.lua
@@ -0,0 +1,2 @@
1
+function TestClass.myFunction(self)
2
+end
test/translation/lua/classStaticMembers.lua
@@ -0,0 +1,10 @@
+MyClass = MyClass or {}
+MyClass.__index = MyClass
3
+function MyClass.new(construct, ...)
4
+ local instance = setmetatable({}, MyClass)
5
+ if construct and MyClass.constructor then MyClass.constructor(instance, ...) end
6
+ return instance
7
8
+MyClass.test = 0
9
+function MyClass.constructor(self)
10
test/translation/ts/classExtension.ts test/translation/ts/classExtension1.tstest/translation/ts/classExtension.ts renamed to test/translation/ts/classExtension1.ts
test/translation/ts/classExtension2.ts
@@ -0,0 +1,9 @@
+/** !Extension */
+class TestClass {
+}
+
+class MyClass extends TestClass {
+ myFunction() {}
test/translation/ts/classStaticMembers.ts
@@ -0,0 +1,3 @@
+class MyClass {
+ public static test = 0;
test/unit/loops.spec.ts
@@ -102,8 +102,7 @@ export class LuaLoopTests {
@TestCase([0, 1, 2, 3], [1, 2, 3, 4], "let i = 0; arrTest.length > i; i++")
@TestCase([0, 1, 2, 3], [1, 2, 3, 4], "let i = 0; arrTest.length - 1 >= i; i++")
@TestCase([0, 1, 2, 3], [1, 1, 3, 3], "let i = 0; i < arrTest.length; i += 2")
- // @TestCase([0, 1, 2, 3], [1, 2, 3, 4], "let i = arrTest.length - 1; i <= 0; i--")
- // @TestCase([0, 1, 2, 3], [0, 2, 2, 4], "let i = arrTest.length - 1; i <= 0; i -= 2")
+ @TestCase([0, 1, 2, 3], [1, 2, 3, 4 ], "let i = arrTest.length - 1; i >= 0; i--")
@TestCase([0, 1, 2, 3], [0, 2, 2, 4], "let i = arrTest.length - 1; i >= 0; i -= 2")
@TestCase([0, 1, 2, 3], [0, 2, 2, 4], "let i = arrTest.length - 1; i > 0; i -= 2")
@Test("forheader")
0 commit comments