-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix default property assigned prototype #40836
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
Conversation
The check in getAssignedClassSymbol forgot to allow for default-property assignment declarations, in part because it wasn't using a utility function to do so.
@@ -24828,7 +24829,7 @@ namespace ts { | |||
const exprType = checkJsxAttribute(attributeDecl, checkMode); | |||
objectFlags |= getObjectFlags(exprType) & ObjectFlags.PropagatingFlags; | |||
|
|||
const attributeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.escapedName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a drive-by fix; createSymbol always adds Transient
.
isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); | ||
const prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype" as __String); | ||
const init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); | ||
const assignmentSymbol = decl && getSymbolOfExpando(decl, /*allowDeclaration*/ true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the actual fix
return init ? getSymbolOfNode(init) : undefined; | ||
} | ||
|
||
function getSymbolOfExpando(node: Node, allowDeclaration?: boolean): Symbol | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes from the move:
- Return a Symbol instead of a Node, since all callers immediately do that anyway. This is why I moved it into the checker.
- Add a parameter
allowDeclaration
that allowsnode
to be either the expando or its declaration. The parameter disables the checks that assert thatnode
is theexpando
initialiser. - Add a FunctionDeclaration case when
allowDeclaration
is true.
The check in getAssignedClassSymbol forgot to allow for default-property assignment declarations, in part because it wasn't using a utility function to do so.
Fixes #39167