Closed sam-bunger closed 1 year ago
St.:grey_question: |
Category | Percentage | Covered / Total |
---|---|---|---|
🟢 | Statements | 94.22% (-0.1% 🔻) |
945/1003 |
🟢 | Branches | 88.95% (-0.25% 🔻) |
459/516 |
🟢 | Functions | 94.36% (+0.06% 🔼) |
184/195 |
🟢 | Lines | 95.41% (+0.06% 🔼) |
893/936 |
32 tests passing in 4 suites.
Report generated by 🧪jest coverage report action from e95199ed212926e30da320f0bbea8287c7fba106
Ok @sam-bunger if you look in TaggedUnionGenerator, you'll see a few interesting lines:
Now, the compiler assumes that you're building your tagged unions off string unions, and hadn't considered that you would already have an enum ready to use instead.
What you'll want to do is add some conditional logic around those lines (or inside https://github.com/asarazan/martok/blob/main/src/martok/declarations/TaggedUnionGenerator.ts#L108) which detects when the tag candidate is of enum type, and uses that instead. Unfortunately you'll also then need to override the naming scheme that the compiler uses (title(tag.name)
or something like that).
I've got a decent amount of free time tomorrow so hmu and I can walk you through it.
Also if you debug npm run special
and set a breakpoint at line 74, you should be able to look around the execution state and get a good feel for what things needs to be changed.
Base: 95.06% // Head: 95.03% // Decreases project coverage by -0.02%
:warning:
Coverage data is based on head (
855758e
) compared to base (71f5ec9
). Patch coverage: 95.00% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
@asarazan Just added in an extra test, and added a new typeName
property onto the tagged union mapping type. This feels like it's good to go, let me know your thoughts.
Not sure if a PR is a place to request this... BUT there is a feature that would really help Faceoff resolve some duplicate type issues.
Fixes #67 Resolves FACE-1206
The Problem
When Martok transpiles tagged union types, a new enum always gets created inside the generated sealed class, even if we want the tagged union type to reference an enum outside of the sealed class.
For example, our
GameSession
type is tagged using thisGameType
enum:When this transpiles we get two enum types, one outside the sealed class, and one inside the sealed class:
This makes it difficult because if we want multiple classes to reference the same enum then we'll need to manually delete the enum inside each sealed class.
The Solution
I really don't know! BUT I added in some tests in this PR that test against this use case