Skip to content

Allow string initializer for enums#139

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

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

Conversation

@zengjie
Copy link
Copy Markdown
Contributor

@zengjie zengjie commented Jul 10, 2018

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

@Perryvw
Copy link
Copy Markdown
Member

Perryvw commented Jul 10, 2018

What about testcase:

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

@zengjie
Copy link
Copy Markdown
Contributor Author

zengjie commented Jul 10, 2018

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

@Perryvw
Copy link
Copy Markdown
Member

Perryvw commented Jul 10, 2018

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
Copy link
Copy Markdown
Member

Perryvw commented Jul 10, 2018

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

@zengjie
Copy link
Copy Markdown
Contributor Author

zengjie commented Jul 11, 2018

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
Copy link
Copy Markdown
Contributor Author

zengjie commented Jul 15, 2018

@Perryvw I've updated the test cases.

Copy link
Copy Markdown
Member

@Perryvw Perryvw left a comment

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!

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

} 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
Copy link
Copy Markdown
Contributor Author

zengjie commented Jul 15, 2018

@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