Add LuaMap and LuaSet language extensions#1303
Merged
Perryvw merged 7 commits intoTypeScriptToLua:masterfrom Jul 14, 2022
Merged
Add LuaMap and LuaSet language extensions#1303Perryvw merged 7 commits intoTypeScriptToLua:masterfrom
Perryvw merged 7 commits intoTypeScriptToLua:masterfrom
Conversation
Perryvw
requested changes
Jul 14, 2022
| node | ||
| ) | ||
| ); | ||
| return lua.createNilLiteral(); |
Member
There was a problem hiding this comment.
Any thoughts on returning table instead? This is how sets work in TS:
const myset = new Set<number>().add(1).add(2).add(3);Though I guess that could get us in an annoying spot where we have to worry about side effects evaluating table, so I'd be fine leaving this as it is.
Contributor
Author
There was a problem hiding this comment.
This is possible to implement, however it would be inconsistent with existing lua table extension functions.
Perhaps this could be done in another PR.
Perryvw
approved these changes
Jul 14, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
LuaMapandLuaSetlanguage extensions. Readonly variants are also declared. They somewhat mimic ES maps and sets.LuaMapis like a table, except that thegetmethod may returnnil. This more closely matches the ES map interface.For
LuaSet, two language extensions are added:LuaTableAddwhich translates calls oftable.add(foo)totable[foo] = trueLuaPairsKeyIterable, which is likeLuaPairsIterableexcept only the key value is used (and multi-return is not used).