Files
tsgo/internal/fourslash/tests/quickInfoDestructuredBinding_test.go
448132945a Fix destructured binding hover displaying wrong keyword (var instead of (parameter), const, or let) (#3327)
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: RyanCavanaugh <[email protected]>
Co-authored-by: ahejlsberg <[email protected]>
Co-authored-by: Ryan Cavanaugh <[email protected]>
2026-04-02 20:19:44 +00:00

36 lines
1.2 KiB
Go

package fourslash_test
import (
"testing"
"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/testutil"
)
func TestQuickInfoDestructuredBinding(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `
function f({ /*1*/x }: { x: number }) {}
function g([/*2*/y]: number[]) {}
function h({ a: { /*3*/b } }: { a: { b: string } }) {}
const { /*4*/c } = { c: 42 };
let { /*5*/d } = { d: "hello" };
var { /*6*/e } = { e: true };
`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
// Destructured object binding parameters should show "(parameter)" not "var"
f.VerifyQuickInfoAt(t, "1", "(parameter) x: number", "")
// Destructured array binding parameters should show "(parameter)" not "var"
f.VerifyQuickInfoAt(t, "2", "(parameter) y: number", "")
// Nested destructured parameters should also show "(parameter)"
f.VerifyQuickInfoAt(t, "3", "(parameter) b: string", "")
// Destructured const/let/var bindings should show their proper keyword
f.VerifyQuickInfoAt(t, "4", "const c: number", "")
f.VerifyQuickInfoAt(t, "5", "let d: string", "")
f.VerifyQuickInfoAt(t, "6", "var e: boolean", "")
}