Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -30398,7 +30398,7 @@ func (c *Checker) getSymbolAtLocation(node *ast.Node, ignoreErrors bool) *ast.Sy
} else if ast.IsJSDocParameterTag(parent) && parent.Name() == node {
if fn := ast.GetNodeAtPosition(ast.GetSourceFileOfNode(node), node.Pos(), false); fn != nil && ast.IsFunctionLike(fn) {
for _, param := range fn.Parameters() {
if param.Name().Text() == node.Text() {
if ast.IsIdentifier(param.Name()) && param.Name().Text() == node.Text() {
return c.getSymbolOfNode(param)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/testutil"
)

// Regression test for panic: "Unhandled case in Node.Text: *ast.BindingPattern"
// This tests array binding patterns specifically.
func TestFindAllRefsJSDocArrayDestructuredParam(t *testing.T) {
t.Parallel()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `
/**
* @param /*1*/arr - array destructured parameter
*/
function f([x, y]) {}
`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyBaselineFindAllReferences(t, "1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/testutil"
)

// Regression test for panic: "Unhandled case in Node.Text: *ast.BindingPattern"
// This occurred when requesting findAllReferences with a JSDoc parameter tag
// that referenced a destructured parameter.
func TestFindAllRefsJSDocDestructuredParam(t *testing.T) {
t.Parallel()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `
/**
* @param /*1*/obj - object destructured parameter
*/
function f({ x, y }) {}
`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyBaselineFindAllReferences(t, "1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// === findAllReferences ===
// === /findAllRefsJSDocArrayDestructuredParam.ts ===
// /**
// * @param /*FIND ALL REFS*/arr - array destructured parameter
// */
// function f([x, y]) {}
//
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// === findAllReferences ===
// === /findAllRefsJSDocDestructuredParam.ts ===
// /**
// * @param /*FIND ALL REFS*/obj - object destructured parameter
// */
// function f({ x, y }) {}
//
Loading