The following should work:
declare namespace string {
/** @tupleReturn @luaIterator */
export function gmatch(s: string, pattern: string): Iterable<string[]>
}
/** @tupleReturn @luaIterator */
function parse(text: string) {
return string.gmatch(text, "%S+");
}
for (const [s] of parse("foo bar baz")) {
print(s);
}
But won't, because the return value in parse is wrapped in a table by mistake:
parse = function(text)
return ({string.gmatch(text, "%S+")});
end;
This should work since normal tupleReturn decorated functions will correctly forward the return value.
The following should work:
But won't, because the return value in parse is wrapped in a table by mistake:
This should work since normal tupleReturn decorated functions will correctly forward the return value.