-
Notifications
You must be signed in to change notification settings - Fork 421
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
Emit classes instead of vars #222
Comments
The ability to emit classes would help implement my proposed solution to the WebGL declarations' use of empty interfaces: microsoft/TypeScript#5855 (comment) |
I will submit a PR if someone gives Accepting PR tag. |
On the other hand, emitting classes makes it much harder to extend built-in types with optional extensions, since class declarations cannot be merged together, but interfaces can. |
This works: declare class Merge {
x: string;
}
interface Merge {
y: string;
}
new Merge().y; It can't extend static properties, but it never worked anyway. |
@saschanaz Yeah I'm trying to fix that right now actually, because ran into a problem with polyfilling static methods :) #812 |
To be clear - I came across this issue because I'd also be happy if there was a way to reduce all that clutter and just use Hopefully this can be somehow fixed on TypeScript side in the future by allowing merging classes with classes, or adding |
There is a relevant issue on TS: microsoft/TypeScript#2957 |
Actually... I've just realised that something like this might work for extending statics: declare class Merge {
x: string;
static X: string;
}
interface Merge {
y: string;
}
declare namespace Merge {
const Y: string;
}
new Merge().x;
new Merge().y;
Merge.X;
Merge.Y; So if we implement this, then #812 would be unnecessary. Either option is fine by me and better than current status quo that doesn't allow any extensions, but this one would probably be even cleaner. |
FWIW - just so that our work doesn't conflict - I'm giving this a try. |
Update: I have a working implementation of this, but waiting for #813 to be merged first. |
Now that we can extend both class instance type and static type, can we now directly emit classes? Is there any remaining blocking problems?
The text was updated successfully, but these errors were encountered: