Skip to content

Remove new from luaKeywords#583

Closed
hazzard993 wants to merge 1 commit intoTypeScriptToLua:masterfrom
hazzard993:new-is-not-a-lua-keyword
Closed

Remove new from luaKeywords#583
hazzard993 wants to merge 1 commit intoTypeScriptToLua:masterfrom
hazzard993:new-is-not-a-lua-keyword

Conversation

@hazzard993
Copy link
Copy Markdown
Contributor

new is not a Lua keyword

local new = 0
print(new)

Output: 0

Busted (a Lua testing framework) uses this keyword in spy.new(...).

It is possible to use new as a property name in TS.

const object = {
    new: () => {}
};
object.new();

At the moment TSTL thinks it is a keyword and disallows this from working.

@tomblind
Copy link
Copy Markdown
Collaborator

#581 will re-enable use of the keywords in that list. So, this probably isn't needed.

The reason new is listed is to prevent users from accidentally breaking classes:

class Foo {
    static new() {}
}
const bar = new Foo(); // uh oh

I think a special check for this case is the better way to go.

@hazzard993 hazzard993 closed this May 16, 2019
@hazzard993 hazzard993 deleted the new-is-not-a-lua-keyword branch May 17, 2019 07:28
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.

2 participants