Skip to content

Commit b3775fc

Browse files
committed
Remove now obsolete isTupleType call, add test
1 parent 8fc3761 commit b3775fc

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/Transpiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ export class LuaTranspiler {
11581158
const index = this.transpileExpression(node.argumentExpression);
11591159

11601160
const type = this.checker.getTypeAtLocation(node.expression);
1161-
if (tsHelper.isArrayType(type, this.checker) || tsHelper.isTupleType(type, this.checker)) {
1161+
if (tsHelper.isArrayType(type, this.checker)) {
11621162
return `${element}[${index}+1]`;
11631163
} else if (tsHelper.isStringType(type)) {
11641164
return `string.sub(${element},${index}+1,${index}+1)`;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
for _, value in ipairs(tuple) do
2+
end
3+
TS_forEach(tuple, function(v)
4+
end
5+
)
6+
local num = tuple[1+1]
7+
8+
local len = #tuple
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// test cases where tuples are used as arrays
2+
declare const tuple: [string, number, boolean];
3+
4+
// tslint:disable:no-empty no-unused-expression
5+
for (const value of tuple) {} // for-of loop
6+
tuple.forEach(v => {}); // Array.prototype.forEach
7+
const num = tuple[1]; // array access
8+
const len = tuple.length; // array length

0 commit comments

Comments
 (0)