Emit declaration of class extending intersection#15537
Merged
sandersn merged 4 commits intoMay 5, 2017
Merged
Conversation
Classes that extend expressions will get a synthetic var declaration for the expression. This is required for classes that extend an expression that return an intersection type.
mhegazy
reviewed
May 4, 2017
| const baseTypeNode = getClassExtendsHeritageClauseElement(node); | ||
| let tempVarName: string; | ||
| if (isNonNullExpression(baseTypeNode)) { | ||
| tempVarName = emitTempVariableDeclaration(baseTypeNode.expression, `_${node.name.text}_intersection_base`, { |
Contributor
There was a problem hiding this comment.
i would remove the _intersection
Contributor
There was a problem hiding this comment.
do not think you need the leading "_" either
mhegazy
reviewed
May 4, 2017
| if (!noDeclare) { | ||
| write("declare "); | ||
| } | ||
| write("var "); |
mhegazy
reviewed
May 4, 2017
| resolveBaseTypesOfClass(classType); | ||
| const baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; | ||
| if (!baseType.symbol) { | ||
| if (!baseType.symbol && !(baseType.flags & TypeFlags.Intersection)) { |
Contributor
There was a problem hiding this comment.
this should not be necessary here, right? we never call this function with an expression..
mhegazy
approved these changes
May 5, 2017
Contributor
Contributor
|
Please port the change to release-2.3 as well. |
Member
Author
|
It should fix #15572 since the error arises from incorrect flattening of an expression in |
Member
Author
|
Yes, it fixes #15572. I also ported this change to 2.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Classes that extend expressions will get a synthetic var declaration for
the expression. This is required for classes that extend an expression
that return an intersection type.
Fixes #14075, but not #15066, which is the full mixin scenario. You still can't export a class that inherits from a class expression that was returned from a function. That probably requires more complicated type declarations to be generated.