Skip to content

Allow string initializer for enums - #139

Merged
Perryvw merged 3 commits into
TypeScriptToLua:masterfrom
zengjie:feat-add-string-enum
Jul 15, 2018
Merged

Allow string initializer for enums#139
Perryvw merged 3 commits into
TypeScriptToLua:masterfrom
zengjie:feat-add-string-enum

Conversation

@zengjie

@zengjie zengjie commented Jul 10, 2018

Copy link
Copy Markdown
Contributor

String enum is a useful language feature, I think we should support it.

@Perryvw

Perryvw commented Jul 10, 2018

Copy link
Copy Markdown
Member

What about testcase:

enum abc {
    a,
    b = "def",
    c,
}

@zengjie

zengjie commented Jul 10, 2018

Copy link
Copy Markdown
Contributor Author

Did you mean creating a new test case with this input? or just modifying the current one?

@Perryvw

Perryvw commented Jul 10, 2018

Copy link
Copy Markdown
Member

I meant adding a new testcase with that specific enum, it is not allowed in typescript and should error out (which you can test)

@Perryvw

Perryvw commented Jul 10, 2018

Copy link
Copy Markdown
Member

Also you probably shouldn't change old tests, just add some new ones.

@zengjie

zengjie commented Jul 11, 2018

Copy link
Copy Markdown
Contributor Author

Yes. You are right, this test case will result an error.

@zengjie
zengjie force-pushed the feat-add-string-enum branch from 9b89ada to 2b76593 Compare July 14, 2018 17:21
@zengjie

zengjie commented Jul 15, 2018

Copy link
Copy Markdown
Contributor Author

@Perryvw I've updated the test cases.

@Perryvw Perryvw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! There is one more testcase I would like you to revert back to what it originally was (enum.ts), once that is done I think this can be merged!

Comment thread test/translation/lua/enum.lua Outdated
TestEnum.val2=2
TestEnum.val3=3 No newline at end of file
TestEnum.val3=3
TestEnum.val4="bye" No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert this file back to just a generic enum as it was before, this case is covered by enumHeterogeneous.lua

Comment thread test/translation/ts/enum.ts Outdated
} No newline at end of file
val3,
val4 = "bye"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also revert this file

@zengjie

zengjie commented Jul 15, 2018

Copy link
Copy Markdown
Contributor Author

@Perryvw I've reverted the test case. 😄

@Perryvw
Perryvw merged commit 0887fd4 into TypeScriptToLua:master Jul 15, 2018
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