fix: handle complex enum initializer expressions + cross-file references#120
Open
jpdutoit wants to merge 1 commit intounplugin:mainfrom
Open
fix: handle complex enum initializer expressions + cross-file references#120jpdutoit wants to merge 1 commit intounplugin:mainfrom
jpdutoit wants to merge 1 commit intounplugin:mainfrom
Conversation
|
|
- Support nested BinaryExpression (e.g. A | B | C) - Support MemberExpression initializers (e.g. Value = OtherEnum.Value) - Support bare Identifier referencing sibling members (e.g. Last = Third) - Support UnaryExpression on complex operands (e.g. ~Flags.ABCD) - Resolve cross-file enum references via lazy evaluation - Deduplicate reverse mappings for duplicate numeric values (last wins)
812acdd to
4a6f52e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for complex enum initializer expressions, and resolves cross-file enum dependencies via lazy evaluation. Also deduplicates reverse mappings for enums with shared numeric values.
Description
Expression handling
Fixes enum scanning for several initializer expression types that previously caused build failures with
unhandled BinaryExpression operand typeorunhandled initializer typeerrors.Reverse mapping deduplication
When multiple enum members share the same numeric value, only the last declared member gets a reverse mapping entry. This avoids duplicate keys in the generated object literal, matching TypeScript's runtime behavior.
Resolve cross-file references
Cross-file references fail when file A references an enum from file B, but B is scanned after A. Enum values are now stored as lazy resolvers. All resolvers are called once at the end when constructing
enumData, at which point every enum has been scanned.Tests
Added test enums covering nested binary expressions, self-referencing compound members, bare identifier references, unary on member expressions, duplicate numeric values, and cross-file enum references.
Linked Issues
None