mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Don't treat object properties as potential JS contructors without JSDoc class tag (#49735)
This commit is contained in:
@@ -31906,12 +31906,15 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
const func = isFunctionDeclaration(node) || isFunctionExpression(node) ? node :
|
||||
isVariableDeclaration(node) && node.initializer && isFunctionExpression(node.initializer) ? node.initializer :
|
||||
(isVariableDeclaration(node) || isPropertyAssignment(node)) && node.initializer && isFunctionExpression(node.initializer) ? node.initializer :
|
||||
undefined;
|
||||
if (func) {
|
||||
// If the node has a @class tag, treat it like a constructor.
|
||||
// If the node has a @class or @constructor tag, treat it like a constructor.
|
||||
if (getJSDocClassTag(node)) return true;
|
||||
|
||||
// If the node is a property of an object literal.
|
||||
if (isPropertyAssignment(walkUpParenthesizedExpressions(func.parent))) return false;
|
||||
|
||||
// If the symbol of the node has members, treat it like a constructor.
|
||||
const symbol = getSymbolOfNode(func);
|
||||
return !!symbol?.members?.size;
|
||||
|
||||
Reference in New Issue
Block a user