-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Abstract Constructor Assignability Not Restricted Enough #4190
Comments
If this is a bug how do I do this #2947 (comment)?
And @RyanCavanaugh suggested:
I think that there should be a modifier for declaring derivative of an abstract class that is not abstract. var A2: new () => implementationof A; |
Let me check my understanding. Suppose our class hierarchy looks like
where Then you want to have an object AA = B;
AA = C;
new AA; but forbids AA = A; If my understanding is correct, that's precisely the capability that should be provided by If I'm misunderstanding, can you clarify where I'm going astray? |
This is the only way that I know of that can do the capability we are talking about. Though personally I also feel that this is a bug. Though I want to have the capability to declare a non abstract class declaration type. If you fix this bug, then I don't know how to do it(except using |
Could you clarify what you mean by "a non abstract class declaration type"? |
@aozgaa don't know the real name of it. but just to clarify my meaning: abstract class A {}
typeof A // abstract class declaration type
class B extends A {}
typeof B //non-abstract class declaration type |
I see. So what's missing from the constructor function type |
I think this is already handled?
As I mentioned in the quoted comments above. I want pass a "non-abstract class declaration type" to a function and instantiate using new. |
Today, the following code will work: class A {}
function factory(AA: typeof A) {
return new AA;
} |
@aozgaa thanks! |
Consider the following code snippet:
The first assignment should fail because
A2
is new-able (it isn't an abstract constructor type), but no error is reported.EDIT: simplified the sample.
The text was updated successfully, but these errors were encountered: