-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Abstract class expressions #4578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure whether this omission was intentional. We could presumably allow it if there's some compelling reason to, seems unlikely to be something that would be used much though. |
That was intentional. We should reconsider thought. |
I feel like not having them breaks the class/class expression duality a bit. Plus, it makes it so I can't blanket rewrite all classes into class expressions. As far as non-style related usefulness goes... having abstract class expressions lets you get more typesafety in abstract class factory patterns, I guess? (Wow that sounds java-y) It also has utility for mixin factories which require functionality on the thing they're mixed into to function. I think the biggest reason is simply class/class expression symmetry though. |
We would like to keep the syntax as simple as possible; Could not find any blocked scenarios by now allowing abstract on class expressions. So, use an abstract class declaration instead. |
@mhegazy, I would like this to be reconsidered. Perhaps prior to addition of mixins to TypeScript, there wasn't much reason for having this feature, but now, at least I have cases where it would be convenient to have a mixin produce an abstract class and that requires abstract class expressions. Currently I can walk around this issue, but I would prefer not to. I don't know TypeScript compiler's internals much, but I would expect all necessary tooling to be available to allow this feature. If the only reason not to allow this is simplicity, then this approach may seem simple only because there is no documentation (I'm aware of) saying this is intentionally not supported and there are no useful error messages from the parser (#17416). |
You don't need to use a class expression to create a mixin though. You can create a local class inside the function and then return it. That class may be |
Unfortunately this doesn't work with |
Aren't a thing?
Just curious if they're supposed to be, since class expressions and
abstract
were both added in 1.6.The text was updated successfully, but these errors were encountered: