ts-generator icon indicating copy to clipboard operation
ts-generator copied to clipboard

Issue #4 - sealed classes

Open bernerbrau opened this issue 7 years ago • 6 comments

bernerbrau avatar Mar 27 '18 23:03 bernerbrau

This is too complex.

ntrrgc avatar Mar 29 '18 23:03 ntrrgc

It's hard to follow what has changed and what hasn't even using git diff -w.

ntrrgc avatar Mar 29 '18 23:03 ntrrgc

Yeah, I moved too much around. Let me revert and try again.

On Thu, Mar 29, 2018, 5:12 PM Alicia Boya García [email protected] wrote:

It's hard to follow what has changed and what hasn't even using git diff -w.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ntrrgc/ts-generator/pull/5#issuecomment-377400142, or mute the thread https://github.com/notifications/unsubscribe-auth/AC4SgGBmRJ8f8fVyV79ek52GIqE56JLlks5tjWpxgaJpZM4S9y3X .

bernerbrau avatar Mar 30 '18 14:03 bernerbrau

My worry is that the patch to implement this feature is so big and far reaching that it becomes not worth it for maintainability sake.

ntrrgc avatar Mar 30 '18 14:03 ntrrgc

This was my attempt. It does not handle non-nested sealed class children, but it's much simpler. https://github.com/ntrrgc/ts-generator/commit/a12e9f2f1ece6bec97ac4c2ea4450003534e9557

ntrrgc avatar Mar 30 '18 14:03 ntrrgc

Right, agreed. In addition to your initial concerns, I realized that typescript's type erasure makes it difficult at runtime to determine which member of the union is being used; hence why I found it necessary to include code generation that does runtime type validation. To do this, I had to make the class visitor repeatable, and that was enough to confuse git diff beyond hopefulness.

So it may simply be that sealed classes are too complicated to be worth including. :(

On Fri, Mar 30, 2018, 8:43 AM Alicia Boya García [email protected] wrote:

This was my attempt. It does not handle non-nested sealed class children, but it's much simpler. a12e9f2 https://github.com/ntrrgc/ts-generator/commit/a12e9f2f1ece6bec97ac4c2ea4450003534e9557

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ntrrgc/ts-generator/pull/5#issuecomment-377538939, or mute the thread https://github.com/notifications/unsubscribe-auth/AC4SgF56ucpxHY3aaH3MDISkBHEP0AFMks5tjkScgaJpZM4S9y3X .

bernerbrau avatar Mar 30 '18 14:03 bernerbrau