@@ -525,7 +525,8 @@ export class LuaLoopTests
525525 public forofLuaIterator ( ) : void {
526526 const code = `const arr = ["a", "b", "c"];
527527 /** @luaIterator */
528- function luaIter(): Iterable<string> {
528+ interface Iter extends Iterable<string> {}
529+ function luaIter(): Iter {
529530 let i = 0;
530531 return (() => arr[i++]) as any;
531532 }
@@ -545,7 +546,8 @@ export class LuaLoopTests
545546 public forofLuaIteratorExistingVar ( ) : void {
546547 const code = `const arr = ["a", "b", "c"];
547548 /** @luaIterator */
548- function luaIter(): Iterable<string> {
549+ interface Iter extends Iterable<string> {}
550+ function luaIter(): Iter {
549551 let i = 0;
550552 return (() => arr[i++]) as any;
551553 }
@@ -566,7 +568,8 @@ export class LuaLoopTests
566568 public forofLuaIteratorDestructuring ( ) : void {
567569 const code = `const arr = ["a", "b", "c"];
568570 /** @luaIterator */
569- function luaIter(): Iterable<[string, string]> {
571+ interface Iter extends Iterable<[string, string]> {}
572+ function luaIter(): Iter {
570573 let i = 0;
571574 return (() => arr[i] && [i.toString(), arr[i++]]) as any;
572575 }
@@ -586,7 +589,8 @@ export class LuaLoopTests
586589 public forofLuaIteratorDestructuringExistingVar ( ) : void {
587590 const code = `const arr = ["a", "b", "c"];
588591 /** @luaIterator */
589- function luaIter(): Iterable<[string, string]> {
592+ interface Iter extends Iterable<[string, string]> {}
593+ function luaIter(): Iter {
590594 let i = 0;
591595 return (() => arr[i] && [i.toString(), arr[i++]]) as any;
592596 }
@@ -609,7 +613,8 @@ export class LuaLoopTests
609613 const code = `const arr = ["a", "b", "c"];
610614 /** @luaIterator */
611615 /** @tupleReturn */
612- function luaIter(): Iterable<[string, string]> {
616+ interface Iter extends Iterable<[string, string]> {}
617+ function luaIter(): Iter {
613618 let i = 0;
614619 /** @tupleReturn */
615620 function iter() { return arr[i] && [i.toString(), arr[i++]] || []; }
@@ -632,7 +637,8 @@ export class LuaLoopTests
632637 const code = `const arr = ["a", "b", "c"];
633638 /** @luaIterator */
634639 /** @tupleReturn */
635- function luaIter(): Iterable<[string, string]> {
640+ interface Iter extends Iterable<[string, string]> {}
641+ function luaIter(): Iter {
636642 let i = 0;
637643 /** @tupleReturn */
638644 function iter() { return arr[i] && [i.toString(), arr[i++]] || []; }
@@ -656,7 +662,8 @@ export class LuaLoopTests
656662 public forofLuaIteratorTupleReturnSingleVar ( ) : void {
657663 const code = `/** @luaIterator */
658664 /** @tupleReturn */
659- declare function luaIter(): Iterable<[string, string]>;
665+ interface Iter extends Iterable<[string, string]> {}
666+ declare function luaIter(): Iter;
660667 for (let x of luaIter()) {}` ;
661668 const compilerOptions = {
662669 luaLibImport : LuaLibImportKind . Require ,
@@ -674,7 +681,8 @@ export class LuaLoopTests
674681 public forofLuaIteratorTupleReturnSingleExistingVar ( ) : void {
675682 const code = `/** @luaIterator */
676683 /** @tupleReturn */
677- declare function luaIter(): Iterable<[string, string]>;
684+ interface Iter extends Iterable<[string, string]> {}
685+ declare function luaIter(): Iter;
678686 let x: [string, string];
679687 for (x of luaIter()) {}` ;
680688 const compilerOptions = {
@@ -694,14 +702,15 @@ export class LuaLoopTests
694702 const code =
695703 `const arr = ["a", "b", "c"];
696704 /** @luaIterator */
697- function luaIter(): Iterable<string> {
705+ interface Iter extends Iterable<string> {}
706+ function luaIter(): Iter {
698707 let i = 0;
699708 function iter() { return arr[i++]; }
700709 return iter as any;
701710 }
702- /** @luaIterator */
703- function forward(): Iterable<string> {
704- return luaIter() ;
711+ function forward() {
712+ const iter = luaIter();
713+ return iter ;
705714 }
706715 let result = "";
707716 for (let a of forward()) { result += a; }
@@ -721,16 +730,16 @@ export class LuaLoopTests
721730 `const arr = ["a", "b", "c"];
722731 /** @luaIterator */
723732 /** @tupleReturn */
724- function luaIter(): Iterable<[string, string]> {
733+ interface Iter extends Iterable<[string, string]> {}
734+ function luaIter(): Iter {
725735 let i = 0;
726736 /** @tupleReturn */
727737 function iter() { return arr[i] && [i.toString(), arr[i++]] || []; }
728738 return iter as any;
729739 }
730- /** @luaIterator */
731- /** @tupleReturn */
732- function forward(): Iterable<[string, string]> {
733- return luaIter();
740+ function forward() {
741+ const iter = luaIter();
742+ return iter;
734743 }
735744 let result = "";
736745 for (let [a, b] of forward()) { result += a + b; }
0 commit comments