Skip to content

Commit f9db4c3

Browse files
Copilotjakebailey
andauthored
Fix panic when @callback/@overload @param has a qualified name (#3922)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
1 parent 3436b95 commit f9db4c3

5 files changed

Lines changed: 131 additions & 0 deletions

File tree

internal/parser/reparser.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD
135135
}
136136
} else if param.Kind == ast.KindJSDocParameterTag || param.Kind == ast.KindJSDocPropertyTag {
137137
jsparam := param.AsJSDocParameterOrPropertyTag()
138+
// Skip sub-property parameters (e.g., @param x.y) - these have QualifiedNames
139+
// and describe properties of a parent parameter, not standalone parameters.
140+
if ast.IsQualifiedName(jsparam.Name()) {
141+
continue
142+
}
138143
var dotDotDotToken *ast.Node
139144
var paramType *ast.TypeNode
140145

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
bug.js(23,14): error TS2339: Property 'y' does not exist on type 'object'.
2+
3+
4+
==== bug.js (1 errors) ====
5+
/**
6+
* @callback cb
7+
* @param x.y
8+
*/
9+
10+
/**
11+
* @callback cb2
12+
* @param {object} x
13+
* @param {string} x.y
14+
*/
15+
16+
/**
17+
* @overload
18+
* @param {object} x
19+
* @param {string} x.y
20+
* @returns {string}
21+
*/
22+
/**
23+
* @param {object} x
24+
* @returns {string}
25+
*/
26+
function foo(x) {
27+
return x.y;
28+
~
29+
!!! error TS2339: Property 'y' does not exist on type 'object'.
30+
}
31+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//// [tests/cases/compiler/jsdocCallbackParamQualifiedName.ts] ////
2+
3+
=== bug.js ===
4+
/**
5+
* @callback cb
6+
* @param x.y
7+
*/
8+
9+
/**
10+
* @callback cb2
11+
* @param {object} x
12+
* @param {string} x.y
13+
*/
14+
15+
/**
16+
* @overload
17+
* @param {object} x
18+
* @param {string} x.y
19+
* @returns {string}
20+
*/
21+
/**
22+
* @param {object} x
23+
* @returns {string}
24+
*/
25+
function foo(x) {
26+
>foo : Symbol(foo, Decl(bug.js, 12, 4), Decl(bug.js, 0, 0))
27+
>x : Symbol(x, Decl(bug.js, 21, 13))
28+
29+
return x.y;
30+
>x : Symbol(x, Decl(bug.js, 21, 13))
31+
}
32+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [tests/cases/compiler/jsdocCallbackParamQualifiedName.ts] ////
2+
3+
=== bug.js ===
4+
/**
5+
* @callback cb
6+
* @param x.y
7+
*/
8+
9+
/**
10+
* @callback cb2
11+
* @param {object} x
12+
* @param {string} x.y
13+
*/
14+
15+
/**
16+
* @overload
17+
* @param {object} x
18+
* @param {string} x.y
19+
* @returns {string}
20+
*/
21+
/**
22+
* @param {object} x
23+
* @returns {string}
24+
*/
25+
function foo(x) {
26+
>foo : (x: { y: string; }) => string
27+
>x : object
28+
29+
return x.y;
30+
>x.y : any
31+
>x : object
32+
>y : any
33+
}
34+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @noEmit: true
4+
5+
// @filename: bug.js
6+
/**
7+
* @callback cb
8+
* @param x.y
9+
*/
10+
11+
/**
12+
* @callback cb2
13+
* @param {object} x
14+
* @param {string} x.y
15+
*/
16+
17+
/**
18+
* @overload
19+
* @param {object} x
20+
* @param {string} x.y
21+
* @returns {string}
22+
*/
23+
/**
24+
* @param {object} x
25+
* @returns {string}
26+
*/
27+
function foo(x) {
28+
return x.y;
29+
}

0 commit comments

Comments
 (0)