Skip to content

Simplify abstract constructor type assignability checking #6111

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

Merged
merged 2 commits into from
Dec 19, 2015

Conversation

ahejlsberg
Copy link
Member

This PR simplifies checking of abstract constructor type assignability. The current code is overly convoluted and inefficient and even includes some out of bounds indexing of arrays.

@@ -15396,20 +15368,6 @@ namespace ts {
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
}

function instantiateSingleCallFunctionType(functionType: Type, typeArguments: Type[]): Type {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't lint unused functions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out @sandersn, I sent out a linting PR if you'd like to take a look: #6140

@sandersn
Copy link
Member

:1+:

@@ -5782,6 +5740,20 @@ namespace ts {
}
}

// Return true if the given type is the constructor type for an abstract class
function isAbstractConstructorType(type: Type) {
if (type.flags & TypeFlags.Anonymous) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate why this needs to be anonymous?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the static side of a class is an anonymous object type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add that in as a quick comment then? It's not entirely obvious at first glance.

@DanielRosenwasser
Copy link
Member

Other than my last comment, 👍

ahejlsberg added a commit that referenced this pull request Dec 19, 2015
Simplify abstract constructor type assignability checking
@ahejlsberg ahejlsberg merged commit 66a0f1d into master Dec 19, 2015
@ahejlsberg ahejlsberg deleted the simplifyAbstractCheck branch December 19, 2015 03:09
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants