@@ -2368,10 +2368,11 @@ func (c *Checker) checkJSDocComment(node *ast.Node, location *ast.Node) {
2368
2368
func (c *Checker) resolveJSDocMemberName(name *ast.Node, location *ast.Node) *ast.Symbol {
2369
2369
if name != nil && ast.IsEntityName(name) {
2370
2370
meaning := ast.SymbolFlagsType | ast.SymbolFlagsNamespace | ast.SymbolFlagsValue
2371
- symbol := c.resolveEntityName(name, meaning, true /*ignoreErrors*/, true /*dontResolveAlias*/, location)
2372
- if symbol == nil && ast.IsQualifiedName(name) {
2373
- symbol := c.resolveJSDocMemberName(name.AsQualifiedName().Left, location)
2374
- if symbol != nil {
2371
+ if symbol := c.resolveEntityName(name, meaning, true /*ignoreErrors*/, true /*dontResolveAlias*/, location); symbol != nil {
2372
+ return symbol
2373
+ }
2374
+ if ast.IsQualifiedName(name) {
2375
+ if symbol := c.resolveJSDocMemberName(name.AsQualifiedName().Left, location); symbol != nil {
2375
2376
var t *Type
2376
2377
if symbol.Flags&ast.SymbolFlagsValue != 0 {
2377
2378
proto := c.getPropertyOfType(c.getTypeOfSymbol(symbol), "prototype")
@@ -30203,19 +30204,15 @@ func (c *Checker) getSymbolAtLocation(node *ast.Node, ignoreErrors bool) *ast.Sy
30203
30204
return c.getSymbolOfDeclaration(grandParent)
30204
30205
}
30205
30206
30206
- if node.Kind == ast.KindIdentifier {
30207
+ if ast.IsIdentifier(node) {
30207
30208
if isInRightSideOfImportOrExportAssignment(node) {
30208
30209
return c.getSymbolOfNameOrPropertyAccessExpression(node)
30209
- } else if parent.Kind == ast.KindBindingElement &&
30210
- grandParent.Kind == ast.KindObjectBindingPattern &&
30211
- node == parent.AsBindingElement().PropertyName {
30210
+ } else if ast.IsBindingElement(parent) && ast.IsObjectBindingPattern(grandParent) && node == parent.PropertyName() {
30212
30211
typeOfPattern := c.getTypeOfNode(grandParent)
30213
- propertyDeclaration := c.getPropertyOfType(typeOfPattern, node.Text())
30214
-
30215
- if propertyDeclaration != nil {
30212
+ if propertyDeclaration := c.getPropertyOfType(typeOfPattern, node.Text()); propertyDeclaration != nil {
30216
30213
return propertyDeclaration
30217
30214
}
30218
- } else if ast.IsMetaProperty(parent) && parent.AsMetaProperty(). Name() == node {
30215
+ } else if ast.IsMetaProperty(parent) && parent.Name() == node {
30219
30216
metaProp := parent.AsMetaProperty()
30220
30217
if metaProp.KeywordToken == ast.KindNewKeyword && node.Text() == "target" {
30221
30218
// `target` in `new.target`
@@ -30230,6 +30227,14 @@ func (c *Checker) getSymbolAtLocation(node *ast.Node, ignoreErrors bool) *ast.Sy
30230
30227
}
30231
30228
// no other meta properties are valid syntax, thus no others should have symbols
30232
30229
return nil
30230
+ } else if ast.IsJSDocParameterTag(parent) && parent.Name() == node {
30231
+ if fn := ast.GetNodeAtPosition(ast.GetSourceFileOfNode(node), node.Pos(), false); fn != nil && ast.IsFunctionLike(fn) {
30232
+ for _, param := range fn.Parameters() {
30233
+ if param.Name().Text() == node.Text() {
30234
+ return c.getSymbolOfNode(param)
30235
+ }
30236
+ }
30237
+ }
30233
30238
}
30234
30239
}
30235
30240
@@ -30418,28 +30423,32 @@ func (c *Checker) getSymbolOfNameOrPropertyAccessExpression(name *ast.Node) *ast
30418
30423
// Missing entity name.
30419
30424
return nil
30420
30425
}
30421
-
30422
- if name.Kind == ast.KindIdentifier {
30426
+ isJSDoc := ast.IsJSDocNameReferenceContext(name)
30427
+ if ast.IsIdentifier(name) {
30423
30428
if ast.IsJsxTagName(name) && isJsxIntrinsicTagName(name) {
30424
30429
symbol := c.getIntrinsicTagSymbol(name.Parent)
30425
30430
return core.IfElse(symbol == c.unknownSymbol, nil, symbol)
30426
30431
}
30427
- result := c.resolveEntityName(
30428
- name,
30429
- ast.SymbolFlagsValue, /*meaning*/
30430
- true, /*ignoreErrors*/
30431
- true, /*dontResolveAlias*/
30432
- nil /*location*/)
30432
+ meaning := core.IfElse(isJSDoc, ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace, ast.SymbolFlagsValue)
30433
+ result := c.resolveEntityName(name, meaning, true /*ignoreErrors*/, true /*dontResolveAlias*/, nil /*location*/)
30434
+ if result == nil && isJSDoc {
30435
+ if container := ast.FindAncestor(name, ast.IsClassOrInterfaceLike); container != nil {
30436
+ symbol := c.getSymbolOfDeclaration(container)
30437
+ // Handle unqualified references to class static members and class or interface instance members
30438
+ if result = c.getMergedSymbol(c.getSymbol(c.getExportsOfSymbol(symbol), name.Text(), meaning)); result == nil {
30439
+ result = c.getPropertyOfType(c.getDeclaredTypeOfSymbol(symbol), name.Text())
30440
+ }
30441
+ }
30442
+ }
30433
30443
return result
30434
30444
} else if ast.IsPrivateIdentifier(name) {
30435
30445
return c.getSymbolForPrivateIdentifierExpression(name)
30436
- } else if name.Kind == ast.KindPropertyAccessExpression || name.Kind == ast.KindQualifiedName {
30446
+ } else if ast.IsPropertyAccessExpression(name) || ast.IsQualifiedName(name) {
30437
30447
links := c.symbolNodeLinks.Get(name)
30438
30448
if links.resolvedSymbol != nil {
30439
30449
return links.resolvedSymbol
30440
30450
}
30441
-
30442
- if name.Kind == ast.KindPropertyAccessExpression {
30451
+ if ast.IsPropertyAccessExpression(name) {
30443
30452
c.checkPropertyAccessExpression(name, CheckModeNormal, false /*writeOnly*/)
30444
30453
if links.resolvedSymbol == nil {
30445
30454
links.resolvedSymbol = c.getApplicableIndexSymbol(
@@ -30450,7 +30459,9 @@ func (c *Checker) getSymbolOfNameOrPropertyAccessExpression(name *ast.Node) *ast
30450
30459
} else {
30451
30460
c.checkQualifiedName(name, CheckModeNormal)
30452
30461
}
30453
-
30462
+ if links.resolvedSymbol == nil && isJSDoc && ast.IsQualifiedName(name) {
30463
+ return c.resolveJSDocMemberName(name, nil)
30464
+ }
30454
30465
return links.resolvedSymbol
30455
30466
}
30456
30467
} else if ast.IsEntityName(name) && isTypeReferenceIdentifier(name) {
0 commit comments