File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,25 @@ func TestGetTokenAtPosition(t *testing.T) {
70
70
}
71
71
})
72
72
73
+ t .Run ("JSDoc type assertion with comment" , func (t * testing.T ) {
74
+ t .Parallel ()
75
+ // Exact code from the issue report
76
+ fileText := `function foo(x) {
77
+ const s = /**@type {string}*/(x) // Go-to-definition on x causes panic
78
+ }`
79
+ file := parser .ParseSourceFile (ast.SourceFileParseOptions {
80
+ FileName : "/test.js" ,
81
+ Path : "/test.js" ,
82
+ }, fileText , core .ScriptKindJS )
83
+
84
+ // Find position of 'x' in the type assertion
85
+ xPos := 52 // Position of 'x' in (x)
86
+
87
+ // This should not panic
88
+ token := astnav .GetTouchingPropertyName (file , xPos )
89
+ assert .Assert (t , token != nil , "Expected to get a token" )
90
+ })
91
+
73
92
t .Run ("pointer equality" , func (t * testing.T ) {
74
93
t .Parallel ()
75
94
fileText := `
You can’t perform that action at this time.
0 commit comments