X Tutup
Skip to content

Lua table extensions#991

Merged
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
tomblind:luatable-extension
Feb 21, 2021
Merged

Lua table extensions#991
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
tomblind:luatable-extension

Conversation

@tomblind
Copy link
Collaborator

Next extension for #963

This adds a set of new extensions to replace functionality provided by @luaTable.

It adds LuaTableGet & LuaTableSet (and method variants) to allow declaring functions which map to value = table[index] and table[index] = value, similar to how operator overload mappings work.

It also adds a LuaTable interface and LuaTableConstructor extension to allow tables to be created directly:

const t = new LuaTable(); // local t = {}

@tomblind tomblind requested review from Perryvw and lolleko February 21, 2021 16:33
`
.setOptions(tableProjectOptions)
.expectToEqual(1);
});
Copy link
Member

@lolleko lolleko Feb 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why someone would do that, but could you add a test for new LuaTable().get/set("test"). Just to ensure that works and does not produce invalid Lua ({}["test"]).

);

export const invalidTableExtensionUse = createErrorDiagnosticFactory(
"This function must always be directly called and cannot be referred to."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"This function must always be directly called and cannot be referred to."
"This function must be called directly and cannot be referred to."

@Perryvw Perryvw merged commit e90fc31 into TypeScriptToLua:master Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup