Skip to content

Simplify and improve enum transform - #685

Merged
Perryvw merged 5 commits into
TypeScriptToLua:masterfrom
ark120202:simplify-and-improve-enum-transform
Aug 3, 2019
Merged

Simplify and improve enum transform#685
Perryvw merged 5 commits into
TypeScriptToLua:masterfrom
ark120202:simplify-and-improve-enum-transform

Conversation

@ark120202

@ark120202 ark120202 commented Jul 24, 2019

Copy link
Copy Markdown
Contributor

Fixes #683, fixes #684.
Fixes string literal references:

enum Foo {
    ["A"],
    B = A,
}

Tests depend on #609.

@ark120202
ark120202 force-pushed the simplify-and-improve-enum-transform branch from 740f7bf to 91313ae Compare August 1, 2019 06:41
@ark120202
ark120202 marked this pull request as ready for review August 1, 2019 06:42
Comment thread src/LuaTransformer.ts
} else {
valueExpression = tstl.createNumericLiteral(numericValue);
numericValue++;
valueExpression = tstl.createNilLiteral();

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.

Looking at this again, is this actually correct? In what case would an enum value be nil?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Original transformer has the same branch: https://github.com/microsoft/TypeScript/blob/master/src/compiler/transformers/ts.ts#L2442.
I have thought it'd be used for some syntactically incorrect enums, but couldn't find any cases where TS goes there.

@Perryvw
Perryvw merged commit 532d09d into TypeScriptToLua:master Aug 3, 2019
@ark120202
ark120202 deleted the simplify-and-improve-enum-transform branch November 26, 2019 08:13
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.

Const enums with own member references are emitted Enum values shouldn't be assumed to be pure

2 participants